[Workflow API] Enable support for Importing helper utilities in FederatedRuntime notebooks#6
Open
[Workflow API] Enable support for Importing helper utilities in FederatedRuntime notebooks#6
Conversation
ishant162
reviewed
Jun 13, 2025
ishant162
reviewed
Jun 13, 2025
ishant162
reviewed
Jun 13, 2025
ishant162
reviewed
Jun 13, 2025
ishant162
reviewed
Jun 13, 2025
ishant162
reviewed
Jun 13, 2025
ishant162
reviewed
Jun 13, 2025
Collaborator
ishant162
left a comment
There was a problem hiding this comment.
Overall looks OK but some error handling needs to be done to make it more robust
There was a problem hiding this comment.
Pull Request Overview
This PR enhances FederatedRuntime notebook support by enabling user-defined helper utilities to be imported and executed remotely.
- Update workspace context manager to include both the experiment directory and its
srcsubdirectory insys.path. - Extend
CodeAnalyzerto detect user-defined imports in the generated script and copy the corresponding.pyfiles or packages into the workspace. - Add helper methods for checking and resolving module paths.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| openfl/utilities/workspace.py | Enhanced __enter__/__exit__ to manage src directory on sys.path. |
| openfl/experimental/workflow/notebooktools/code_analyzer.py | Implemented __extract_user_defined_imports, __copy_user_defined_modules, _is_user_defined_module, and _get_module_paths; updated imports and type hints. |
Comments suppressed due to low confidence (1)
openfl/experimental/workflow/notebooktools/code_analyzer.py:92
- Add unit tests for
__extract_user_defined_importsand__copy_user_defined_modulesto verify correct detection of user modules, including edge cases like nested packages, missing files, and different import styles.
def __extract_user_defined_imports(self, notebook_path) -> List[str]:
ishant162
approved these changes
Jun 16, 2025
Collaborator
ishant162
left a comment
There was a problem hiding this comment.
Looks good. Please check the copilot review comments and incorporate if they make sense
Signed-off-by: refai06 <refai.ahamed06@gmail.com>
Signed-off-by: refai06 <refai.ahamed06@gmail.com>
Signed-off-by: refai06 <refai.ahamed06@gmail.com>
cf15e62 to
e40a28f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses issue securefederatedai#1565 by enabling the import of user-defined helper functions and utilities from separate Python scripts in
FederatedRuntimenotebooks.Type of Change (Mandatory)
Specify the type of change being made.
Description (Mandatory)
PR enhances the
CodeAnalyzerto support importing user-defined helper modules inFederatedRuntimenotebooks by.pyfiles or packages togenerated_workspace/src.Testing