Hi Prefect Team - I'm attempting to set the schedu...
# ask-community
c
Hi Prefect Team - I'm attempting to set the schedule for certain deployments to inactive in my dev environment. This was working previously, but after a release today the dev environment was set to active.
1
Previous python code called in a github action
Copy code
import 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())
New attempt calling a dev-prefect.yaml file.
Copy code
# 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
Copy code
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
k
I'll need to double check this but I'm used to seeing a field called
is_schedule_active
, I don't have a reference on hand for how we write that in the prefect.yaml
ah nevermind, having
active: false
is fine
is setting the schedule to inactive working for you with the
prefect.yaml
?
c
@Kevin Grismore I will check that
@Kevin Grismore It worked with the prefect.yaml file. Is there a way to use a file other than prefect.yaml? I thought I had done that correctly in the github action workflow
Hi Kevin - I corrected the issue I ran into by using blocks.
Copy code
active: "{{ prefect.blocks.string.active-status }}"
k
nice! and clever
👍 1