-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Perform dynamic import such that local relative imports functio… (
#906) …n correctly. **Pull Request Checklist** - [ ] Fixes #<!--issue number goes here--> - [x] Tests added - [ ] Documentation/examples added - [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR title **Description of PR** Given a folder structure like: ```python folder/ foo.py bar.py ``` Currently, files containing workflows cannot reference other python modules, local to the point of import. i.e. `from .foo import ...` from inside `bar.py`. This PR updates the way the dynamic import occurs such that local imports **do** function correctly. What does **not** yet appear to work correctly is if the referenced code can be imported where absolute imports to a root package would function correctly. I suspect that for that to work, the FROM argument would need to reference a source `module.path` rather than a path to a file. Signed-off-by: DanCardin <[email protected]>
- Loading branch information
Showing
4 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from hera.workflows import Container | ||
|
||
on_exit = Container(image="image") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from hera.workflows import Workflow | ||
|
||
from .file1 import on_exit | ||
|
||
with Workflow(name="relative_import", on_exit=on_exit) as workflow: | ||
workflow._add_sub(on_exit) |
This file contains 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