Open lsscodes opened 1 month ago
Thanks for the bug report @lsscodes!
A crashed flow run with a non-zero exit code usually means that Prefect ran into an error when pulling your flow code. You can verify the configuration of your pull step by running this script:
from prefect.deployments.steps import git_clone
from prefect_gitlab import GitLabCredentials
git_clone(
repository="https://gitlab.com/xxxx/im30_rewards_autosubscriber_prefect.git",
credentials=GitLabCredentials.load("lss-gitlab"),
)
If that runs without error, then we'll need to dig deeper!
@desertaxle i tried the following code
from prefect.deployments.steps import git_clone
from prefect_gitlab import GitLabCredentials
credentials = GitLabCredentials.load("lss-gitlab")
print(credentials)
git_clone(
repository="https://gitlab.com/xxx2074845/im30_rewards_autosubscriber_prefect.git",
credentials=credentials,
)
and it returned
GitLabCredentials(token=SecretStr('**********'), url=None)
C:\Users\xxx\OneDrive - xxxGroup\Desktop\Work\Tools\im30_rewards_autosubscriber_prefect\junk\prefect_gitlab_clone.py:8: RuntimeWarning: coroutine 'git_clone' was never awaited
git_clone(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Still processing items: 1 items remaining...
nothing happened, I don't see the repository getting cloned locally
Hmmm, ok it looks like we'll need to make sure we wait for that coroutine:
import asyncio
from prefect.deployments.steps import git_clone
from prefect_gitlab import GitLabCredentials
async def main():
await git_clone(
repository="https://gitlab.com/xxxx/im30_rewards_autosubscriber_prefect.git",
credentials=await GitLabCredentials.load("lss-gitlab"),
)
if __name__ == "__main__":
asyncio.run(main())
I thought that function had our @sync_compatible
decorator on it, which would allow it to be run synchronously, but I must've been mistaken. Hopefully the new code gives a better indicator!
@desertaxle still nothing happened
RuntimeWarning: coroutine 'git_clone' was never awaited
git_clone(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
RuntimeWarning: coroutine 'sync_compatible.<locals>.coroutine_wrapper.<locals>.ctx_call' was never awaited
git_clone(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
That's my mistake, I forgot to await
the git_clone
code. If you add an await
before git_clone
then it should execute correctly. I've updated my code example above.
@desertaxle new error
TypeError: cannot pickle 'coroutine' object
sys:1: RuntimeWarning: coroutine 'sync_compatible.<locals>.coroutine_wrapper.<locals>.ctx_call' was never awaited
hi @lsscodes its probably because you're not awaiting the load
method, on all blocks, that method is async in an async context
In [1]: from prefect.deployments.steps import git_clone
In [2]: await git_clone(repository="https://github.com/zzstoatzz/prefect-monorepo.git")
Out[2]: {'directory': 'prefect-monorepo'}
In [3]: from prefect.blocks.core import Block
In [4]: await Block.load("json/marvin-thread-cache")
Out[4]: JSON(value={...})
@zzstoatzz @desertaxle I was able to get it working. thanks for the help
did the following change
pull:
- prefect.deployments.steps.git_clone:
repository: https://gitlab.com/xxxxx/im30_rewards_autosubscriber_prefect.git
access_token: "{{ prefect.blocks.secret.lss-gitlab-token }}"
I also want to point out that even though the the deployment was successful, there still warning you might want to look into
RuntimeWarning: coroutine 'sync_compatible.<locals>.coroutine_wrapper.<locals>.ctx_call' was never awaited
if flow is None:
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
sys:1: RuntimeWarning: coroutine 'sync_compatible.<locals>.coroutine_wrapper.<locals>.ctx_call' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Version: 3.0.1
API version: 0.8.4
Python version: 3.11.9
Git commit: c6b2ffe1
Built: Fri, Sep 6, 2024 10:05 AM
OS/Arch: win32/AMD64
Profile: ephemeral
Server type: cloud
Pydantic version: 2.8.2
Integrations:
prefect-gitlab: 0.3.0
I have the same bug in Prefect 3. Can't run a Hello World flow in Prefect:managed workpool when the code is pulled from Gitlab. Logs output is just:
Opening process...
Process for flow run 'xxxxxxx' exited with status code: 1
Reported flow run 'xxxxxx' as crashed: Flow run process exited with non-zero status code 1.
Downgrading the managed workpool image to Prefect 2 fixes the issue.
I'm glad to hear you got it working, @lsscodes! Was the fix to use the access_token
field instead of the credentials field?
@Markowashere can you share your pull step to see if it's a similar issue?
@desertaxle that is correct, access_token
did the trick
by the way, have you looked at the RuntimeWarnings?
I'm glad to hear you got it working, @lsscodes! Was the fix to use the
access_token
field instead of the credentials field?@Markowashere can you share your pull step to see if it's a similar issue?
Sure, here's the pull step:
pull:
- prefect.deployments.steps.git_clone:
repository: git@gitlab.com:private/repo.git
branch: feature_branch
access_token: '{{ prefect.blocks.secret.deployment-test-my-flow-repo-token
}}'
I've also tried to deploy using Python, same issue.
Hi all, I am having a similiar issue. Please advise
my yaml
# prefect.yaml
name: fantasy-premier-league
prefect-version:
build:
push:
pull:
- prefect.deployments.steps.git_clone:
repository: https://github.com/bonsuot/fantasy-premier-league.git
deployments:
- name: fantasy-premier-league
version:
tags: [fpl_etl, database, api]
concurrency_limit:
description: Main flow orchestrating the entire ETL pipeline
entrypoint: fpl_etl.py:main_flow
parameters: {"mode":"auto"}
work_pool:
name: fpl-pool
work_queue_name:
job_variables: {}
enforce_parameter_schema: true
schedules:
- cron: 0 0 12 * * * # Every 12 hours
timezone: UTC
day_or: true
active: true
max_active_runs:
catchup: false
logs
Opening process...
10:10:49 AM
Info
Process for flow run 'prehistoric-coua' exited with status code: 1
10:10:53 AM
Error
Reported flow run 'bccb264d-7e2c-4f36-a056-eaf8741d6166' as crashed: Flow run process exited with non-zero status code 1.
Bug summary
i was trying to run a deployment that pulled code from private GITLAB repo and run it with prefect:managed work-pool and my runs are exited with "message": "Flow run process exited with non-zero status code 1."
here is the log
Here are contents of my prefect.yaml file
Version info (
prefect version
output)Additional context
No response