Hello everyone, so I can run the basic_flow.py fro...
# prefect-cloud
a
Hello everyone, so I can run the basic_flow.py from my terminal and it runs successfully. But when I deploy the same code and run from the UI. It fails because it is looking for my directory.
Documents/prefect/prefect_env
What do I need to do so that the path doesn't point to my local file system?
1
r
You'll want to set up storage for your flow. The docs cover it well: https://docs.prefect.io/concepts/storage/ If you have any questions, please feel free to ask!
a
Thanks Ryan!
I've updated the code to point to Gitlab storage but I'm still getting the following error: "does not have upload capabilities". Any idea what I need to add to resolve this issue?
r
Ah - right. Deployments can typically upload code to storage that we can treat like a filesystem, but we can't interact with Git repos in that way. If you want to you GitLab or GitHub storage, you'll need to push your code to a GitLab repo and then set up a storage block that points at it; the README on the prefect-gitlab page walks you through the steps for that: https://github.com/PrefectHQ/prefect-gitlab You only need to set up that block once. How you use it in your deployment will depend on whether you are creating your deployments via Python or the CLI
For example, if you create a GitLab block named
my-gitlab-storage
, you would would add it to a CLI deployment with the
-sb gitlab-repository/my-gitlab-storage
flag. To add it to a Python deployment, you'd do something like:
Copy code
from prefect.deployments import Deployment
from prefect_gitlab import GitLab

my_storage = GitLab.load("my-gitlab-storage")

my_deployment = Deployment.build_from_flow(
   ...other deployment parameters
   storage=my_storage
)
a
Yes, so the Gitlab repo and storage is already setup and complete. I have pushed the basic_flow.py code into the repo. I've been using the cli to deploy to the environment. So how do I tell the system to pull the code from the Gitlab storage block?
Copy code
prefect deployment build basic_flow.py:basic_flow --name test-deployment -sb gitlab-repository/gitlab-repo-prefect-test -q default
r
That looks right. Are you seeing the "does not have upload capabilities" error when you run that?
a
yes that is correct
r
Does it work if you add
--skip-upload
?
a
same message
prefect deployment build basic_flow.py:basic_flow --name test-deployment -sb gitlab-repository/gitlab-repo-prefect-test -q --skip-upload
When I try running the deployment from the UI, I get the following error: ""No class found for dispatch key 'gitlab-repository' in registry for type 'Block'."
r
Is the
prefect-gitlab
package installed in the environment where your agent is running?
a
I've been using the cli to push the code for deployments into the Prefect environment. It is a kubernetes cluster.
when I run the python code ie
python basic_flow.py
it runs fine locally.
r
Ok, that makes sense. I don't think the docs make it very obvious, so I'll push a PR to update them, but if you want to use a storage block that comes from a separate package like
prefect-gitlab
, then
prefect-gitlab
needs to be installed in the environment that runs your deployments (in this case, it sounds like you've got an agent running in K8s)
a
yes, I believe it is k8s