Chris Gunderson
02/22/2024, 10:10 PMChris Gunderson
02/22/2024, 10:10 PMimport asyncio
from prefect import get_client
from prefect.context import use_profile
async def set_schedules_as_inactive():
async with get_client() as client:
deployments = await client.read_deployments()
for deployment in deployments:
if deployment.name.startswith('loaders') or deployment.name.startswith('transaction'):
await client.update_deployment(deployment, is_schedule_active=False)
if __name__ == "__main__":
with use_profile('dev'):
asyncio.run(set_schedules_as_inactive())
Chris Gunderson
02/22/2024, 10:12 PM# deployment configurations
deployments:
- name: loaders-sra-loader-alerts
description: null
entrypoint: src/run_sod_loaders.py:SRALoaderAlerts
work_pool: *ny4_work_pool
parameters: {}
schedule:
cron: 00 7 * * 1-5
timezone: "America/Chicago"
active: false
GitHub Action Workflow
name: Deploy a Prefect flow
on:
push:
branches:
- dev
jobs:
deploy_flow:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Prefect Auth
uses: PrefectHQ/actions-prefect-auth@v1
with:
prefect-api-key: ${{ secrets.DEV_PREFECT_API_KEY }}
prefect-workspace: ${{ secrets.DEV_PREFECT_WORKSPACE }}
- name: Run Prefect Deploy
uses: PrefectHQ/actions-prefect-deploy@v3
with:
all-deployments: "true"
requirements-file-paths: ./requirements.txt
prefect-file: ./dev-prefect.yaml
Kevin Grismore
02/22/2024, 10:31 PMis_schedule_active
, I don't have a reference on hand for how we write that in the prefect.yamlKevin Grismore
02/22/2024, 11:11 PMactive: false
is fineKevin Grismore
02/22/2024, 11:15 PMprefect.yaml
?Chris Gunderson
02/23/2024, 3:10 PMChris Gunderson
02/23/2024, 3:23 PMChris Gunderson
02/23/2024, 3:55 PMactive: "{{ prefect.blocks.string.active-status }}"
Kevin Grismore
02/23/2024, 3:55 PM