https://prefect.io logo
y

Yufei Li

08/16/2023, 7:51 PM
Hello, is it possible to pass the current timestamp into the prefect.yaml file for deployment? In the deployment sessions, we want to add a new deployment for a workflow, and overwrite the parameters with the current timestamp. I'm trying to use
"${sys.now()}"
but it didn't pass into Prefect. In the future. we'd create a schedule for this workflow, and each time it's triggered, the
end_date
parameter should be the timestamp as the current triggered time.
Copy code
- name: new_workflow
  # version: null
  # tags: []
  # description: null
  schedule: null
  entrypoint: flows/tests/example.py:example
  parameters: {
    "start_date": "2023-03-01T08:00:00.000Z"
    "end_date": "${sys.now()}"
  }
  work_pool: *work_pool
c

Christopher Boyd

08/16/2023, 8:47 PM
You can set an environment variable using the shell date command and pass that in if that’s feasible ?
Eg run shell script to store a date variable , and use that in the parameters
y

Yufei Li

08/23/2023, 3:49 PM
Hi @Christopher Boyd is there any way I can pass the prefect variable into that parameter section? My prefect variable is defined as
prefect.variables.current_date
, but when I reference this in the parameter section as below, if failed to load.
Copy code
- name: new_workflow
  # version: null
  # tags: []
  # description: null
  schedule: null
  entrypoint: flows/tests/example.py:example
  parameters: {
    "start_date": "2023-03-01T08:00:00.000Z"
    "end_date": "{{ prefect.variables.current_date }}"
  }
  work_pool: *work_pool
c

Christopher Boyd

08/23/2023, 4:31 PM
It looks like you are doing it correctly based on the documentation here - https://docs.prefect.io/2.11.4/guides/variables/?h=var#in-project-steps That said, I haven’t tested this myself, so I don’t really have a definite answer of what might be the issue here at the moment