diff --git a/descarteslabs/core/compute/function.py b/descarteslabs/core/compute/function.py index f538ef70..7b0f44b4 100644 --- a/descarteslabs/core/compute/function.py +++ b/descarteslabs/core/compute/function.py @@ -811,14 +811,14 @@ def _data_globs_to_paths(self) -> List[str]: ) ) else: - data_files.append( - ( - path, - self._archive_path( - path, None, sys_path=self._sys_path_prefix(path) - ), - ), + archive_path = self._archive_path( + path, None, sys_path=self._sys_path_prefix(path) ) + if archive_path == "__main__.py": + raise ValueError( + f"{pattern} includes a file with the forbidden relative path `__main__.py`" + ) + data_files.append((path, archive_path)) else: raise ValueError(f"Data file does not exist: {path}")