英文:
Manage github Action Workflow with Prefect Cloud 2
问题
我有几个GitHub操作工作流需要运行。为了管理它们,我想要使用Prefect Cloud。我在Prefect中创建了一个部署和一个GitHub块。当我安排一个部署运行时,它保持在"late"状态。
我的存储库结构:
my_git_repo
└─github/workflows
└─prefect_deployment.yml
└─flow_run.yml
flow_test.py
我的Python流程代码:
from prefect import flow, get_run_logger
@flow(name="Demo")
def basic_flow():
logger=get_run_logger()
logger.warning("Hello World")
if __name__ == "__main__":
basic_flow()
这个流程运行是另一个工作流,flow_run.yml:
name: Run Flow
on: [workflow_dispatch]
jobs:
run-flow:
runs-on: ubuntu-latest
env:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set-Up-GitHub-Actions-Environment
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Install-Python-Packages
run: |
pip install prefect==2.8.3
- name: flow-run
run: |
python3 flow_test.py
我用来创建部署的YAML工作流代码:
name: Deploy to Prefect Cloud 2
env:
PREFECT_API_KEY: ${{ secrets.PREFECT_API_KEY }}
PREFECT_API_URL: ${{ secrets.PREFECT_API_URL }}
on: [workflow_dispatch]
jobs:
load-flow-to-prefect-cloud:
name: Build and apply deployment
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install Python Packages
run: |
pip install prefect==2.8.3
- name: Build deployment
run: |
prefect deployment build -n main_deployment flow_test.py:basic_flow \
-sb github/test-block-github\
- name : Apply deployment
run: |
prefect deployment apply basic_flow-deployment.yaml
当我尝试运行我的流程时,它保持在"late"状态。
我漏掉了什么?
英文:
I have several GitHub action workflows to run. To manage them I want to use Prefect Cloud. I created a deployment and a GitHub block in Prefect. When I schedule a deployment to run, it stays in "late" state.
My repository structure:
my_git_repo
└─github/workflows
└─prefect_deployment.yml
└─flow_run.yml
flow_test.py
My Python flow code:
from prefect import flow, get_run_logger
@flow(name="Demo")
def basic_flow():
logger=get_run_logger()
logger.warning("Hello World")
if __name__ == "__main__":
basic_flow()
My Prefect Block, linking to my repo:
This flow run is another workflow, flow_run.yml:
name: Run Flow
on: [workflow_dispatch]
jobs:
run-flow:
runs-on: ubuntu-latest
env:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set-Up-GitHub-Actions-Environment
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Install-Python-Packages
run: |
pip install prefect==2.8.3
- name: flow-run
run: |
python3 flow_test.py
My YAML workflow code to create the deployment:
name: Deploy to Prefect Cloud 2
env:
PREFECT_API_KEY: ${{ secrets.PREFECT_API_KEY }}
PREFECT_API_URL: ${{ secrets.PREFECT_API_URL }}
on: [workflow_dispatch]
jobs:
load-flow-to-prefect-cloud:
name: Build and apply deployment
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install Python Packages
run: |
pip install prefect==2.8.3
- name: Build deployment
run: |
prefect deployment build -n main_deployment flow_test.py:basic_flow \
-sb github/test-block-github\
- name : Apply deployment
run: |
prefect deployment apply basic_flow-deployment.yaml
The deployment created in Prefect Cloud:
When I try to run my flow it stays in the "late" Sate.
What am I missing ?
答案1
得分: 2
你的代理在哪里运行以检索和执行流程运行?
这看起来像一个用于注册更改的工作流;没有指定基础设施块,它默认为'process',但不清楚你希望它在哪里运行 - prefect deployment build -n main_deployment flow_test.py:basic_flow \ -sb github/test-block-github
英文:
Where is your agent running to retrieve and execute flow runs?
This looks like a workflow to register changes; with no infrastructure block specified, this is defaulting to 'process', but it's unclear where you expect this to run -
prefect deployment build -n main_deployment flow_test.py:basic_flow \ -sb github/test-block-github\
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论