Skip to content

Commit ba78708

Browse files
yhwenchesterxgchen
andauthored
Added more handling for the source file import handling. (#2876)
Co-authored-by: Chester Chen <[email protected]>
1 parent f52be3b commit ba78708

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

nvflare/job_config/fed_job_config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,15 @@ def _copy_source_file(self, custom_dir, module, source_file, dest_file):
230230

231231
import_source_file = os.path.join(source_dir, import_source.replace(".", os.sep) + ".py")
232232
if os.path.exists(import_source_file):
233+
# Handle the import from within the same module
233234
self._get_custom_file(custom_dir, import_module, import_source_file)
235+
else:
236+
# Handle the import from outside the module
237+
size = len(module.split(".")) - 1
238+
source_root = os.sep.join(source_dir.split(os.sep)[0:-size])
239+
import_source_file = os.path.join(source_root, import_source.replace(".", os.sep) + ".py")
240+
if os.path.exists(import_source_file):
241+
self._get_custom_file(custom_dir, import_module, import_source_file)
234242

235243
def _get_client_app(self, config_dir, custom_dir, fed_app):
236244
client_app = {"format_version": 2, "executors": []}

0 commit comments

Comments
 (0)