https://prefect.io logo
#prefect-community
Title
# prefect-community
p

Philip MacMenamin

08/10/2020, 6:36 PM
Copy code
with Flow("STL Flow") as f:
    files = Parameter("files")

f.run(files='fname.txt')
k

Kyle Moon-Wright

08/10/2020, 6:40 PM
Hey @Philip MacMenamin, Happy to help here. Do you mind putting the error message in this thread below? We want to provide visibility to other inquiries above.
💯 1
p

Philip MacMenamin

08/10/2020, 6:42 PM
which thread?
k

Kyle Moon-Wright

08/10/2020, 6:44 PM
This thread. I'll paste your traceback below to free up some space on the main page:
Copy code
$ python3 -m vtk_flow.flow
/home/macmenaminpe/.local/lib/python3.8/site-packages/prefect/core/flow.py:349: UserWarning: Tasks were created but not added to the flow: {<Parameter: files>}. This can occur when `Task` classes, including `Parameters`, are instantiated inside a `with flow:` block but not added to the flow either explicitly or as the input to another task. For more information, see <https://docs.prefect.io/core/advanced_tutorials/task-guide.html#adding-tasks-to-flows>.
  warnings.warn(
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/macmenaminpe/code/nih-3d-resource-workflows/vtk_flow/flow.py", line 71, in <module>
    f.run(files='Cube_3d_printing_sample.stl')
  File "/home/macmenaminpe/.local/lib/python3.8/site-packages/prefect/core/flow.py", line 1213, in run
    state = self._run(
  File "/home/macmenaminpe/.local/lib/python3.8/site-packages/prefect/core/flow.py", line 1032, in _run
    flow_state = runner.run(
TypeError: run() got an unexpected keyword argument 'files'
p

Philip MacMenamin

08/10/2020, 6:45 PM
ok - sorry, thought the snippet plus err was more helpful as a single message.
k

Kyle Moon-Wright

08/10/2020, 6:46 PM
Yeah np, definitely helpful - just don't want to lose other inquiries from today.
Based on your snippet, I think you're trying to accomplish something like this(?):
Copy code
with Flow("STL Flow") as f:
    files = Parameter(name="files", default='fname.txt')

f.run(parameters={'files': 'some_other_file.txt'})
This would set the default of your Parameter to a certain value, which can be changed at runtime by setting the Parameter in
f.run()
p

Philip MacMenamin

08/10/2020, 6:50 PM
ok - so I'm using
prefect/examples/parameterized_flow.py
as a template.
I've seen this error before, - and it seemingly worked for me. Then the above happens with the unexpected keyword, and I don't understnad where that error comes from
k

Kyle Moon-Wright

08/10/2020, 6:52 PM
Ah gotcha, looks like the Parameter is not binding to the flow because it is not being used as input for another Task
p

Philip MacMenamin

08/10/2020, 6:52 PM
Yes, it's still giving this same error.
I see... ok.
k

Kyle Moon-Wright

08/10/2020, 7:02 PM
Yep, so using the parameterized_flow.py example, the Parameter Task
value
is being taken in as an argument for
check_if_even
,
print_odd
, and
print_even
in the flow context as runtime values. These parameter values can be changed in the
flow.run()
arguments (which is what I thought you were getting at with your initial snippet), but still need to be passed to other tasks.
p

Philip MacMenamin

08/10/2020, 8:19 PM
Yes - right. I think I get the logic. I just didn't understand that error message, I thought I'd put a typo in somewhere. Thanks Kyle!
4 Views