https://prefect.io logo
Title
s

Santiago Toso

11/04/2022, 10:26 AM
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

Jeff Hale

11/04/2022, 12:01 PM
Yes. You can uses
--param=som_param_value
or
--params
and aJSON string. I show how in this video.
👍 2
s

Santiago Toso

11/09/2022, 2:55 PM
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:
# 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

Jeff Hale

11/11/2022, 4:07 PM
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

Santiago Toso

11/11/2022, 4:45 PM
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:
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

Jeff Hale

11/11/2022, 4:46 PM
2.6.5 should be fine. If you run
prefect version
from the CLI - what’s the output?
s

Santiago Toso

11/11/2022, 4:57 PM
I updated to 2.6.7 and still the same problem. The output to
prefect version
is:
j

Jeff Hale

11/11/2022, 5:18 PM
Strange. Everything else works fine except the params updating, right?
s

Santiago Toso

11/14/2022, 8:15 AM
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

Jeff Hale

11/14/2022, 1:48 PM
hmm. Can you share your flow function
def test_flow( …)
line of code?
s

Santiago Toso

11/15/2022, 3:54 PM
sure:
j

Jeff Hale

11/15/2022, 3:58 PM
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

Santiago Toso

11/15/2022, 4:02 PM
I see, I'll try that. Thanks a lot @Jeff Hale, you really dived into this one!
👍 1