Hi everyone! I built a flow a few months ago (usin...
# ask-community
f
Hi everyone! I built a flow a few months ago (using Prefect 2.12.0) and back then doing a local deployment through the cli worked ok:
Copy code
prefect deployment run 'file-name/flow-name'
I'm now trying to do a local deployment again but receive this error message whenever I try:
Copy code
cli_params = _load_json_key_values(params, "parameter")
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fina/.local/share/virtualenvs/flow-dGAJ-ukb/lib/python3.11/site-packages/prefect/cli/deployment.py", line 1282, in _load_json_key_values
    for spec in cli_input:
TypeError: 'NoneType' object is not iterable
It seems like the cli command thinks it received a 'params' flag and that its contents are Null, when in fact it didn't. Does anyone have any ideas about what might be going on?? 🙏
d
If you run
Copy code
prefect deployment run --help
You can see how to pass params with the
--param
flag or
--params
flag
I think this is saying that it's expecting some params for your flow but you didn't pass any?
f
Thank you Dev! That's not quite the issue I have: I don't want to pass in parameters through the cli. I do that through a python script:
Copy code
if __name__ == "__main__":
    with open('flow_params_for_local_run.json',
              encoding='utf-8') as file:
        data = json.load(file)

    flow.serve(name="local-flow-deployment",
                           parameters={"param1": 'value1',
                                       "param2":
                                'value2'})
(Using dummy values for the params in this message). The simple command
Copy code
prefect deployment run 'file-name/flow-name'
used to work a few months ago, and now it doesn't. That's the issue
d
Passing parameters is
.serve
is only setting the default parameters
To be precise: when you call
flow.serve(parameters={}
, you are setting the default values for the params, e.g., you are specifying that
param1
should have default value `value`` . When you invoke a deployment with
prefect deployment run
you can still pass params to the deployment.
serving a deployment is just setting up a worker to execute the flow, but calling
deployment run
is the thing that actually runs it
Are you re-serving your flow when you call the deployment? If it's local, is that process still running?
n
pretty sure this is a
typer
problem @Fina Silva-Santisteban can you do
pip list | grep -E 'prefect|typer'
?
💡 1
basically typer changed how optionals work, so instead of an empty list we get
None
, hence the
NoneType
not iterable - which we've fixed in newer versions of prefect
💡 1
f
@Dev Dabke I first run the python file which sets up the worker in one terminal window, then in a second window, use the command it shows in the terminal to run a deployment. (See screenshot) It used to work fine that way, but now it doesn't. I hope this makes things more clear
Screenshot 2024-06-18 at 12.47.13 PM.png
@Nate This is the typer version it uses:
Copy code
typer                      0.12.3
Oh no, does this mean that I need to update the prefect version??
n
if you dont want to upgrade
prefect
, you should be able to downgrade
typer
this issue breaks
prefect deploy
and
prefect deployment run
in all scenarios where a user does not have
typer
pinned below
0.10.0
f
Oh true! Sorry about that, I panicked for a second. I'll try that and let you know how it goes!
n
no worries - let me know if you hit other trouble on this!
f
@Nate It worked! I explicitly set it to
typer  = "==0.9.4"
in my pipfile and now things work fine again! Thanks a lot 🙏
n
catjam
😹 1
great to hear! no problem
🙏 1