|
10 | 10 | import yaml |
11 | 11 | from fedml.computing.scheduler.comm_utils.job_utils import JobRunnerUtils |
12 | 12 | from fedml.core.mlops import MLOpsRuntimeLog |
| 13 | +from fedml.computing.scheduler.comm_utils import file_utils |
13 | 14 | from .device_client_constants import ClientConstants |
14 | 15 | from .device_model_cache import FedMLModelCache |
15 | 16 | from ..scheduler_core.general_constants import GeneralConstants |
@@ -205,7 +206,7 @@ def run_impl(self, run_extend_queue_list, sender_message_center, |
205 | 206 | # Check if the package is already downloaded |
206 | 207 | unzip_package_path = "" |
207 | 208 | if os.path.exists(os.path.join(models_root_dir, parent_fd)): |
208 | | - unzip_package_path = self.find_previous_downloaded_pkg(os.path.join(models_root_dir, parent_fd), model_name) |
| 209 | + unzip_package_path = self.find_previous_downloaded_pkg(os.path.join(models_root_dir, parent_fd)) |
209 | 210 |
|
210 | 211 | # Download the package if not found |
211 | 212 | if unzip_package_path == "": |
@@ -510,30 +511,13 @@ def build_dynamic_constrain_variables(self, run_id, run_config): |
510 | 511 | pass |
511 | 512 |
|
512 | 513 | @staticmethod |
513 | | - def find_previous_downloaded_pkg(parent_dir: str, model_name: str) -> str: |
514 | | - unzip_fd = "" |
515 | | - res = "" |
516 | | - |
517 | | - for folder in os.listdir(parent_dir): |
518 | | - if folder.startswith("unzip_fedml_run"): |
519 | | - unzip_fd = os.path.join(parent_dir, folder) |
520 | | - break |
521 | | - |
522 | | - exact_matched = False |
523 | | - |
524 | | - if unzip_fd == "": |
525 | | - return res |
526 | | - |
527 | | - for folder in os.listdir(unzip_fd): |
528 | | - if folder == model_name: |
529 | | - res = os.path.join(unzip_fd, folder) |
530 | | - exact_matched = True |
531 | | - break |
532 | | - |
533 | | - if not exact_matched: |
534 | | - # Use the first folder found |
535 | | - for folder in os.listdir(unzip_fd): |
536 | | - res = os.path.join(unzip_fd, folder) |
537 | | - break |
538 | | - |
539 | | - return res |
| 514 | + def find_previous_downloaded_pkg(parent_dir: str) -> str: |
| 515 | + """ |
| 516 | + Find a folder inside parent_dir that contains the fedml_model_config.yaml file. |
| 517 | + """ |
| 518 | + res = file_utils.find_file_inside_folder(parent_dir, ClientConstants.MODEL_REQUIRED_MODEL_CONFIG_FILE) |
| 519 | + if res is not None: |
| 520 | + # return the parent folder of res |
| 521 | + return os.path.dirname(res) |
| 522 | + else: |
| 523 | + return "" |
0 commit comments