https://prefect.io logo
a

Ariya Sontrapornpol

09/17/2023, 8:09 AM
Hi, I have a quick short question. Is it possible to use Prefect Variables under "deployments" section in prefect.yaml like "{{ prefect.variables.my_var }}". I use blocks under pull section with this syntax, it works fine but doesn't seem to be the case under deployments.
1
s

Serina

09/18/2023, 7:24 PM
Hi @Ariya Sontrapornpol, it is, please see our documentation here on templating options
a

Ariya Sontrapornpol

09/20/2023, 11:50 AM
Tried but somehow it didn't work for me on 2.12.1. This is my prefect.yaml
Copy code
# Welcome to your prefect.yaml file! You can use this file for storing and managing
# configuration for deploying your flows. We recommend committing this file to source
# control along with your flow code.

# Generic metadata about this project
name: mlops-deployments
prefect-version: 2.12.1

# build section allows you to manage and build docker images
build: null

# push section allows you to manage if and how this project is uploaded to remote locations
push: null

# pull section allows you to provide instructions for cloning this project in remote locations
pull:
- prefect.deployments.steps.git_clone:
    id: clone-step
    repository: <https://github.com/jomariya23156/prefect-deployments.git>
    branch: master
    # access_token: "{{ prefect.blocks.secret.dev-only-token }}"
- prefect.deployments.steps.pip_install_requirements:
    directory: "{{ clone-step.directory }}"
    requirements_file: requirements.txt
    stream_output: False

# the deployments section allows you to provide configuration for deploying flows
deployments:
- name: hi_mom_over_again
  version: null
  tags: []
  description: "Say Hi Mom!"
  schedule: {}
  entrypoint: all_flows.py:hi_mom_flow
  parameters: {}
  work_pool:
    name: "{{ prefect.variables.monitor_pool_name }}"
    work_queue_name: null
    job_variables: {}
- name: drift_detection_evidently
  version: null
  tags: []
  description: >
      Compute Evidently Reports and Test suites to detect data drift
      
      **Note**: the parameter `model_metadata_file_path` is replaced with the Prefect variable
      named `current_model_metadata_file` at run time for automation purposes. 
      Change this behavior at the header of the `detect_drift_flow` function in `detect_drift/detect_drift_flow.py`
  schedule:
    # run every 7 days aka weekly aka once a week
    rrule: 'FREQ=DAILY;INTERVAL=7'
  entrypoint: all_flows.py:detect_drift_flow
  parameters: 
    # set default flow parameters
    model_metadata_file_path: "{{ prefect.variables.current_model_metadata_file }}"
    last_days: 7
    last_n: 500
    evidently_project_name: "production_model_monitor"
    evidently_project_desc: "Dashboard for monitoring production models"
  work_pool:
    name: "{{ prefect.variables.monitor_pool_name }}"
    work_queue_name: null
    job_variables: {}
Variables are there. But when called
prefect deploy
it didn't interpret the value. The same thing on deployment's parameters tab from the UI.
s

Serina

09/20/2023, 9:05 PM
This seems like it could be a bug! Since you’ve got an MRE and screenshots, would you mind creating an issue for this?
a

Ariya Sontrapornpol

09/21/2023, 3:50 AM
OK sure. Thank you.
s

Serina

09/21/2023, 8:40 PM
Hi @Ariya Sontrapornpol, could you give variables a try now with today’s release to let me know how that goes?
a

Ariya Sontrapornpol

09/23/2023, 8:02 AM
It's working now in the new version! Thank you.
🥳 1
3 Views