Skip to content

Commit cae0cc7

Browse files
committed
Fix Spark module distribution: properly zip and distribute impc_etl to workers
1 parent 56fa69f commit cae0cc7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

impc_etl/utils/spark.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def wrapper():
9696
)
9797

9898
# Create a temporary zip file of the impc_etl module
99+
temp_zip_path = None
99100
temp_zip_fd, temp_zip_path = tempfile.mkstemp(suffix='.zip', prefix='impc_etl_')
100101
os.close(temp_zip_fd) # Close the file descriptor
101102

@@ -123,7 +124,7 @@ def wrapper():
123124
task_logger.info(f"Added impc_etl module to Spark workers")
124125
except Exception as e:
125126
task_logger.error(f"Failed to prepare impc_etl module: {e}")
126-
if os.path.exists(temp_zip_path):
127+
if temp_zip_path and os.path.exists(temp_zip_path):
127128
os.unlink(temp_zip_path)
128129
raise
129130

@@ -146,7 +147,7 @@ def wrapper():
146147
# Continue execution as the task may have completed successfully
147148
finally:
148149
# Clean up temporary zip file
149-
if 'temp_zip_path' in locals() and os.path.exists(temp_zip_path):
150+
if temp_zip_path and os.path.exists(temp_zip_path):
150151
try:
151152
os.unlink(temp_zip_path)
152153
task_logger.info("Cleaned up temporary impc_etl zip file")

0 commit comments

Comments
 (0)