hi again team. I'm really amazed from how responsi...
# prefect-getting-started
s
hi again team. I'm really amazed from how responsive you all were to my last inquiry so I figure I would ask once more, haha. When building a deployment from a CLI command, is there a way to specify the default parameters directly from there or I always have to edit the resulting
yaml
file? Asking mostly because I don't see it listed in the Deployment build options in the docs. Thanks for your help!
1
j
Yes. You can uses
--param=som_param_value
or
--params
and aJSON string. I show how in this video.
👍 2
s
thank you @Jeff Hale! that's exactly what I was looking for
hey @Jeff Hale I tried what you show in the video for
params
and it is not pushing the parameters to the deployment. I have to go to the UI and edit the deployment there. I tried three ways: 1. Adding
--params='{"city_id": 56, "timezone": "US/Eastern", "agency_name": "COTA", "analysis_end": null, "analysis_start": null}'
to my
prefect deployment build
command 2. Similarly adding
--params '{"city_id": 56, "timezone": "US/Eastern", "agency_name": "COTA", "analysis_end": null, "analysis_start": null}'
to my
prefect deployment build
command (almost the same as before but with no "=") 3. Deploying from a Python file:
Copy code
# deployment.py
# This file hasn't been tested yet
from via_ds_amm_gtfs_real_time_tools.valhalla_map_matching.prefect_valhalla import \
     gtfs_rt_conflation
from prefect.deployments import Deployment
from prefect.orion.schemas.schedules import CronSchedule
from prefect.blocks.core import Block

deployment = Deployment.build_from_flow(
    flow=test_flow,
    name="test",
    parameters={"city_id": 56, "timezone": "US/Eastern", "agency_name": "COTA", "analysis_end": None, "analysis_start": None},
    infra_overrides={},
    work_queue_name="test",
    tags=['T0', 'T1'],
    schedule=(CronSchedule(cron="0 5 * * *", timezone="America/New_York")),
    storage = Block.load("s3/bucket")
)

if __name__ == "__main__":
    deployment.apply()
any ideas what could be going wrong? Maybe something in the way I specify the parameters?
j
Hmm. Hi Santiago. I tested a deployment with the same parameter names using your first method. I was able to change the value of a parameter by running the same deployment build command and just changing a parameter. I’m on a mac with Prefect 2.6.6. • What’s the output of
prefect version
? • What’s your full deployment build command for method #1?
s
hi @Jeff Hale, thanks a lot for the quick answer. • The Prefect version is 2.6.5. I can try an upgrade to the latest (2.6.7?) • The full command is:
Copy code
prefect deployment build ./prefect_test.py:test_flow \
 -n test_flow \
 -sb s3/bucket \
 -q test \
 -o ./path_to.yaml \
 -t T1 -t T2 \
 --cron "0 3 * * *" \
 --timezone "America/New_York" \
 --params='{"city_id": 56, "timezone": "US/Eastern", "agency_name": "COTA", "analysis_end": null, "analysis_start": null}' \
 --apply
j
2.6.5 should be fine. If you run
prefect version
from the CLI - what’s the output?
s
I updated to 2.6.7 and still the same problem. The output to
prefect version
is:
j
Strange. Everything else works fine except the params updating, right?
s
yes, that is right. The
params
is the only things that doesn't go through. Everything else, including tags and cron schedule are correctly pushed.
j
hmm. Can you share your flow function
def test_flow( …)
line of code?
s
sure:
j
I think the issue is that _gtfs_rt_conflation_ just takes a single param event and you are passing five param values. If you pass a single param value, then it should go through ok.
s
I see, I'll try that. Thanks a lot @Jeff Hale, you really dived into this one!
👍 1