Skip to content

Commit 9a9845a

Browse files
2.2_Branch: fix POC command bug [skip ci] (#879)
* fix POC command bug * using with temp file
1 parent 8aa09dd commit 9a9845a

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

nvflare/lighter/poc.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,16 @@ def clone_client(num_clients: int, dest_poc_folder):
3232
shutil.rmtree(src_folder)
3333

3434

35-
def unpack_poc() -> bool:
35+
def unpack_poc(dest_poc_folder) -> bool:
3636
file_dir_path = pathlib.Path(__file__).parent.absolute()
3737
poc_zip_path = file_dir_path.parent / "poc.zip"
3838
try:
39-
shutil.unpack_archive(poc_zip_path)
39+
import tempfile
40+
41+
with tempfile.TemporaryDirectory() as tmp_dir:
42+
shutil.unpack_archive(poc_zip_path, extract_dir=tmp_dir)
43+
copy_from_src(os.path.join(tmp_dir, "poc"), dest_poc_folder)
44+
4045
return True
4146
except shutil.ReadError:
4247
return False
@@ -52,7 +57,7 @@ def copy_from_src(src_poc_folder, dest_poc_folder):
5257

5358
def clone_poc_folder(src_poc_folder, dest_poc_folder):
5459
shutil.rmtree(dest_poc_folder, ignore_errors=True)
55-
success = unpack_poc()
60+
success = unpack_poc(dest_poc_folder)
5661
if not success:
5762
copy_from_src(src_poc_folder, dest_poc_folder)
5863

nvflare/lighter/poc_commands.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,6 @@ def def_poc_parser(sub_cmd):
329329
return {cmd: poc_parser}
330330

331331

332-
def is_poc(cmd_args) -> bool:
333-
return (
334-
hasattr(cmd_args, "start_poc")
335-
or hasattr(cmd_args, "prepare_poc")
336-
or hasattr(cmd_args, "stop_poc")
337-
or hasattr(cmd_args, "clean_poc")
338-
)
339-
340-
341332
def get_local_host_gpu_ids():
342333
try:
343334
return get_host_gpu_ids()

0 commit comments

Comments
 (0)