Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Runner loading and refactor code #977

Merged
merged 11 commits into from
Mar 4, 2024

Conversation

elliotgunton
Copy link
Collaborator

@elliotgunton elliotgunton commented Feb 26, 2024

Pull Request Checklist

Description of PR
Primarily, this PR refactors the runner code. It also fixes the mapping and loading of kwargs to a RunnerInput object.

Currently, the runner code is hard to follow. This PR refactors the functionality in the runner.py file into a _runner module with util submodules. The PR also makes the complex input mapping logic more testable.

@elliotgunton elliotgunton added semver:patch A change requiring a patch version bump type:task A general task type:bug A general bug and removed type:task A general task labels Feb 26, 2024
@elliotgunton elliotgunton changed the title Runner refactor Fix Runner loading and refactor code Feb 26, 2024
@elliotgunton elliotgunton changed the base branch from main to fix-runner-io-defaults February 26, 2024 11:58
@elliotgunton elliotgunton marked this pull request as ready for review February 26, 2024 11:58
* Create a `_runner` submodule, where `util.py` lives
* Maintains the hera.workflows.runner entrypoint

Signed-off-by: Elliot Gunton <[email protected]>
* Isolating auto gen code changes, can ignore commit

Signed-off-by: Elliot Gunton <[email protected]>
* Function is now testable, doesn't use global kwargs
* Returns a value directly

Signed-off-by: Elliot Gunton <[email protected]>
* Fixes value loading with a slightly hacky fix for now

Signed-off-by: Elliot Gunton <[email protected]>
Signed-off-by: Elliot Gunton <[email protected]>
Signed-off-by: Elliot Gunton <[email protected]>
* Also tidy up types

Signed-off-by: Elliot Gunton <[email protected]>
@elliotgunton elliotgunton force-pushed the runner-refactor branch 2 times, most recently from 907425a to c7c610c Compare March 4, 2024 16:29
Copy link
Collaborator

@flaviuvadan flaviuvadan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a relatively minor comment on "utils". Personally I am not a fan but it's also not a blocking thing. I approve bc this is not "critical" + these are private files for an experimental feature + gives us the chance to bring it up as a team and align on the convention we'd like to use (util vs specific modules vs something else)

)


def _runner(entrypoint: str, kwargs_list: List) -> Any:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a very central runner function. I wonder if it can go into something more "significant" than a util file. I don't want to pick too much on "util", to be clear, but organizing into an abstract util does not tell contributors much atm :(

Copy link
Collaborator Author

@elliotgunton elliotgunton Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I was also not 100% behind this, but I didn't want to have runner in the path again, which would end up with patch(..._runner.runner._runner) in tests.

Naming suggestions welcome!

* Script user guide was too long, split into main features. Fix internal
links
* Make pydantic io example into a runnable workflow - made it more
obvious the scripts would need a custom image

**Pull Request Checklist**
- [x] Fixes #961 (fixes example)
- [ ] Tests added
- [x] Documentation/examples added
- [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR
title

**Description of PR**
Currently, the pydantic IO example does not work. Combined with fixes in
PRs #974 and #977, this doc change shows how to use the Runner IO
features.

---------

Signed-off-by: Elliot Gunton <[email protected]>
@elliotgunton elliotgunton merged commit 799672e into fix-runner-io-defaults Mar 4, 2024
3 of 5 checks passed
@elliotgunton elliotgunton deleted the runner-refactor branch March 4, 2024 16:55
elliotgunton added a commit that referenced this pull request Mar 4, 2024
**Pull Request Checklist**
- [x] Fixes #962 
- [x] Tests added
- [ ] Documentation/examples added
- [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR
title

**Description of PR**
Primarily, this PR refactors the runner code. It also fixes the mapping
and loading of kwargs to a RunnerInput object.

Currently, the runner code is hard to follow. This PR refactors the
functionality in the `runner.py` file into a `_runner` module with util
submodules. The PR also makes the complex input mapping logic more
testable.

---------

Signed-off-by: Elliot Gunton <[email protected]>
elliotgunton added a commit that referenced this pull request Mar 4, 2024
**Pull Request Checklist**
- [x] Fixes #962 
- [x] Tests added
- [ ] Documentation/examples added
- [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR
title

**Description of PR**
Currently, defaults are required when using Parameters in the
RunnerInput. This PR allows defaults to be omitted.

## Changes from #977 
- [x] Fixes #962 
- [x] Tests added
- [ ] Documentation/examples added
- [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR title

**Description of PR**
Primarily, this PR refactors the runner code. It also fixes the mapping and loading of kwargs to a RunnerInput object.

Currently, the runner code is hard to follow. This PR refactors the functionality in the `runner.py` file into a `_runner` module with util submodules. The PR also makes the complex input mapping logic more testable.

## Changes from #982 

* Script user guide was too long, split into main features. Fix internal links
* Make pydantic io example into a runnable workflow - made it more obvious the scripts would need a custom image

**Pull Request Checklist**
- [x] Fixes #961 (fixes example)
- [ ] Tests added
- [x] Documentation/examples added
- [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR title

**Description of PR**
Currently, the pydantic IO example does not work. Combined with fixes in PRs #974 and #977, this doc change shows how to use the Runner IO features.

---------

Signed-off-by: Elliot Gunton <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:patch A change requiring a patch version bump type:bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RunnerInput/Output feedback/issues
2 participants