Skip to content

Commit b4cb7c5

Browse files
Making sure the unzipped file is a directory during initial deployment.
1 parent 6d5f62b commit b4cb7c5

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

python/fedml/computing/scheduler/scheduler_core/scheduler_base_job_runner.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,13 @@ def get_client_id_list(self, server_edge_id_list):
138138

139139
@staticmethod
140140
def unzip_file(zip_file, unzip_file_path) -> str:
141+
unzipped_file_name = ""
141142
if zipfile.is_zipfile(zip_file):
142-
with zipfile.ZipFile(zip_file, "r") as zipf:
143+
with (zipfile.ZipFile(zip_file, "r") as zipf):
143144
zipf.extractall(unzip_file_path)
144-
unzipped_file_name = zipf.namelist()[0]
145+
# Make sure the unzipped file is a directory.
146+
if zipf.namelist()[0].endswith("/"):
147+
unzipped_file_name = zipf.namelist()[0]
145148
else:
146149
raise Exception("Invalid zip file {}".format(zip_file))
147150

@@ -156,7 +159,7 @@ def package_download_progress(self, count, blksize, filesize):
156159
progress_int = int(progress)
157160
downloaded_kb = format(downloaded / 1024, '.2f')
158161

159-
# since this hook funtion is stateless, we need a state to avoid print progress repeatly
162+
# Since this hook function is stateless, we need a state to avoid print progress repeatedly.
160163
if count == 0:
161164
self.prev_download_progress = 0
162165
if progress_int != self.prev_download_progress and progress_int % 5 == 0:

0 commit comments

Comments
 (0)