Hi team,GM, I have a repo in gitlab, I want deploy...
# ask-community
j
Hi team,GM, I have a repo in gitlab, I want deploy the workflow to my Prefect cloud account. It works well when I use the function 'serve'. However, it does not work when I use function 'deploy'. My serve code is:
if __name__ == "__main__":
everflow_clicks_conversions_api_to_gcp.serve(
name="everflow_deployment",
cron="0 10 * * *",
tags=["testing", "tutorial"],
description="Given a GitHub repository, logs repository statistics for that repo.",
version="tutorial/deployments",
)
my deploy code is:
if __name__ == "__main__":
flow.from_source(
source=GitLabRepository(
repository="<https://gitlab.com/excelimpact/data_eng/data_etl/prefect/repository.git>",
reference="main",
credentials=GitLabCredentials(token="gitlab-access-token")
),
entrypoint="workflow/everflow_workflow_test1.py:everflow_clicks_conversions_api_to_gcp",
).deploy(
name="Everflow-deployment-test1",
work_pool_name="my-managed-pool",
cron="0 10 * * *"
)
Copy code
the error is: SError: Failed to pull from remote:
474 Cloning into '/tmp/tmpft4g6p4_prefect'...
475remote: The project you were looking for could not be found or you don't have permission to view it.
476fatal: repository '<https://gitlab.com/excelimpact/data_eng/data_etl/prefect/repository.git/>' not found
n
hi @Jiaqiang Li
The project you were looking for could not be found or you don't have permission to view it
it looks like you're missing a gitlab token / credential that you might have locally when you
serve
your flow?
j
Hi @Nate Thank you very much. I have the gitlab token. I use both of the serve and deploy in the same place gitlab, however, serve works, but deploy does not work.
n
how have you used the token with .deploy?
j
I have a python Everflow_deployment_test1.py, the code is:
Copy code
from prefect import flow
from prefect_gitlab.repositories import GitLabRepository
from prefect_gitlab.credentials import GitLabCredentials
from prefect.blocks.system import Secret


if __name__ == "__main__":
    flow.from_source(
        source=GitLabRepository(
        repository="<https://gitlab.com/excelimpact/data_eng/data_etl/prefect/repository.git>",
        reference="main",
        credentials=GitLabCredentials(token="glpat-******-*********")
    ),
    entrypoint="workflow/everflow_workflow_test1.py:everflow_clicks_conversions_api_to_gcp",
    ).deploy(
        name="Everflow-deployment-test1", 
        work_pool_name="my-managed-pool", 
        cron="0 10 * * *"
    )
and then I use
- python Everflow_deployment_test1.py
my gitlab-ci.yml
Copy code
stages:
  - deploy

deploy:
  stage: deploy
  image: python:3.10
  before_script:
    - export PREFECT_API_KEY=$PREFECT_API_KEY
    #- echo $PREFECT_API_KEY
    - pip install -r requirements.txt
    #- |
    #  curl -s -H "Authorization: Bearer $PREFECT_API_KEY" "<https://api.prefect.cloud/api/me/>"
    - prefect cloud login --key $PREFECT_API_KEY --workspace excelimpact/default
    - prefect profile inspect
  script:
    - python Everflow_deployment_test1.py
    # - python everflow_workflow_test1.py
  only:
    - main  # Adjust branch as needed
  tags:
    - k8s-runner-excel-staging
Hi @Nate Good morning. I just wonder if you have any update about my issue. Thanks!