[Workflow API] Enable user's to import helper functions / utilities from a separate python script in FederatedRuntime Notebooks #14
scngupta-dsp
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
The issue related to securefederatedai#1565, where the User encountered a problem while importing user-defined modules in Jupyter notebooks while running a
FederatedRuntime
experimentIn the current implementation of Workflow API, jupyter notebook is expected to define the Federated Learning experiment in it's entirety. If the user attempts to import a user defined module from a different python script it will fail due to following reasons
generated_workspace
does not contain the user defined codeModuleNotFoundError
failure during execution on participants in a distributed infrastructureDescribe the solution you'd like
Enable users to import helper functions from a separate python script. For e.g. FL experiment tutorial:
crowd_guard.ipynb
is importing some helper functions / classes from user-defined scriptvalidation.py
in a folderworkspace
validation.py (contains helper class)
CrowdGuard.ipynb (Jupyter notebook for Workflow API experiment)
To support this use case, existing export process in
notebook_tools
needs to be enhanced togenerated_workpace
This shall ensure that
generated_workspace
(shown below) includes all user-defined code and ensure that it works on the distributed infrastructureDescribe alternatives you've considered
N.A.
Additional context
This enhancement shall be based on following Requirements & Guidelines
Export Directives
#| export
directive as the first line#| export
directives are required to export the user-defined imports to exported script and further processingUser-defined scripts should not install any packages:
requirements.txt
for the FL experiment, User-defined scripts are not analyzed by the infrastructure to identify dependenciesLocation of User defined python scripts:
generate_workspace
For e.g. Notebook contains
from openfl.experimental.workflow.external.helper.validation import CrowdGuardClientValidation
While this may work on the user node - it may not be possible for infrastructure to recreate the same path on distributed nodes
For e.g.
from openfl.experimental.workflow.external.helper.validation import CrowdGuardClientValidation
could be modified tofrom helper.validation import CrowdGuardClientValidation
Proposal is to avoid this complexity in
notebook_tools
Restrictions on User-defined imports
sys.path
to enable python to find the scripts to import. For e.g.CrowdGuard.ipynb (Jupyter notebook for Workflow API experiment)
Recommended_Usage
User-defined imports should be self-contained:
utils.py (contains additional helper functions)
validation.py (contains helper functions)
notebook_tools
shall be able to identify thatfrom helper.validation import CrowdGuardClientValidation
in Notebook is a user defined importvalidation.py
and identifyingfrom utils import calculate_accuracy
is a user-defined import could be complex to implement and is recommended to be avoidedBeta Was this translation helpful? Give feedback.
All reactions