-
Notifications
You must be signed in to change notification settings - Fork 110
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
New container decorator #1068
New container decorator #1068
Conversation
abdfc10
to
6e0e2bc
Compare
3ce3d10
to
ff6eac6
Compare
6e0e2bc
to
240e50d
Compare
ff6eac6
to
9ef804f
Compare
240e50d
to
380c9d0
Compare
380c9d0
to
ae0409c
Compare
e87960c
to
e573df0
Compare
e573df0
to
d15badf
Compare
def advanced_hello_world(my_input: MyInput, template: Optional[Container] = None) -> MyOutput: | ||
output: MyOutput = MyOutput(container_greeting=f"Hello {my_input.user}") | ||
|
||
if template: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I like this pattern of doing if template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love it but it was the best I could find for linter/developer sanity - magically adding the arg in the decorator is a bit too opaque even for devs IMO
9eb99d7
to
9c574fb
Compare
@elliotgunton how about instead of using template, we can use the function itself? def my_container(my_args:...):
my_container.<attribute> |
9c574fb
to
db04b42
Compare
@samj1912 is there a sensible way to add ![]() Otherwise I don't think it's a nice user experience. For the Another idea is some global value that we can set before calling the user function? from hera.workflows import current_template # no idea on naming 😅
@w.container(command=["sh", "-c"])
def advanced_hello_world(my_input: MyInput) -> MyOutput:
output: MyOutput = MyOutput(container_greeting=f"Hello {my_input.user}")
current_template.args = [f"echo Hello {my_input.user} | tee {output.path(output.container_greeting)}"]
return output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
impl wise this looks good to me. We already chatted about the user experience in one of the maintainer syncs. Anything else to review @elliotgunton? Happy to approve bc it lgtm!
I would prefer to go back to the drawing board for this specific feature as I'm not sure of the UX it promotes. Happy to release the other parts that are already merged. We barely use container templates in Hera anyway compared to scripts. |
@samj1912 I'm not sure there is a better balance of UX for the "advanced container" use case from the proposal, as the proposal itself broke the paradigm of config-as-code (contained within type signatures etc), instead running the function to create the container config/spec. I can remove the code for the advanced use case if the basic one is fine? |
Sure, let's start with that |
* TODO: fix typing for advanced use case Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
* Use varname's argname to get the attribute name, then inspect the attribute's annotation, which should be a Parameter or Artifact Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
7b5ae85
to
5c8a02e
Compare
Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
5c8a02e
to
6f5cdcc
Compare
* Within a DAG/Steps function, when calling functions that are decorated as templates belonging to other [Cluster]WorkflowTemplates, we generate a step/task that sets the TemplateRef based on the WorkflowTemplate name and the template name, as well as setting cluster_scope. Arguments are set as normal **Pull Request Checklist** - [x] Fixes #1096 - [x] Tests added - [ ] Documentation/examples added - [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR title Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
75df498
to
4507151
Compare
@elliotgunton if it's simple, can we also extend this to other template types? |
@samj1912 as in stubbing the function for inputs/outputs? Yes that should be okay. I'll make a new issue for it |
@elliotgunton Yes, given a template being able to set its properties in the decorator and the i/o in the signature. |
Pull Request Checklist
Description of PR
Adds the container decorator, and the special
path
function on Outputs