Is it possible to decorate functions with @script at runtime? #1235
Answered
by
alicederyn
autumnkelsey
asked this question in
Q&A
-
Hi all! The following code runs as expected--build the workflow and print out the YAML:
But this code, which I believe should do the same thing, only at runtime, fails:
The stack trace I get is:
Is there something special I have to do to invoke the script decorator at runtime? |
Beta Was this translation helpful? Give feedback.
Answered by
alicederyn
Oct 10, 2024
Replies: 1 comment 1 reply
-
Try calling the decorator outside of the with blocks? def dynamicallyDecorate(*steps: Callable):
decorated_steps = [
script(image="python:3.11", constructor="inline")(step)
for step in steps
]
with Workflow(entrypoint="steps", generate_name="idk") as w:
with Steps(name="steps"):
for step in decorated_steps:
step()
print(w.to_yaml()) This works locally for me and produces the same yaml as |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
elliotgunton
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try calling the decorator outside of the with blocks?
This works locally for me and produces the same yaml as
staticallyDecorate