Madushan Pathirana
07/23/2025, 3:23 AMMarvin
07/23/2025, 3:23 AMMarvin
07/23/2025, 3:25 AMbash
prefect work-pool create "default-work-pool" --type process
2. Path Handling: The absolute path /root/data/devto_articles.csv might not exist on the worker machine. Consider using relative paths or ensuring the directory exists on the worker.
3. Secret Block: Make sure your "bb-token" secret block is also set up in Prefect Cloud (not just locally). You can create it via the Prefect Cloud UI or using Python:
python
from prefect.blocks.system import Secret
Secret(value="your-bitbucket-token").save("bb-token")
Here's your modified deployment script:
python
from prefect import flow
from prefect.runner.storage import GitRepository
from prefect.blocks.system import Secret
from pathlib import Path
if __name__ == "__main__":
api_base = "<https://dev.to/api>"
pages = 3
per_page = 30
# Use relative path instead of absolute
output_file = "data/devto_articles.csv"
parameters_dict = {
'api_base': api_base,
'pages': pages,
'per_page': per_page,
'output_file': output_file
}
github_repo = GitRepository(
url="<https://bitbucket.org/xx/dbt_duck_etl.git>",
credentials={
"access_token": Secret.load("bb-token")
},
branch='dev'
)
flow.from_source(
source=github_repo,
entrypoint="src/flows/Amazon/etl.py:main"
).deploy(
name="Amazon-bb-02",
work_pool_name="default-work-pool",
parameters=parameters_dict
)
To make this work:
1. First, ensure you're logged into Prefect Cloud (which you mentioned you are)
2. Create the work pool as shown above
3. Set up your secret block in Prefect Cloud
4. Run your deployment script
5. Start a worker to execute your deployments:
bash
prefect worker start -p "default-work-pool"
A few additional recommendations:
1. Consider adding tags to your deployment for better organization:
python
.deploy(
name="Amazon-bb-02",
work_pool_name="default-work-pool",
parameters=parameters_dict,
tags=["amazon", "etl"]
)
2. You might want to add error handling around the Secret.load() call in case the secret block isn't found.
3. Consider using environment variables for sensitive values like API endpoints and credentials.
Let me know if you need help with any of these steps or encounter any issues!Madushan Pathirana
07/23/2025, 3:31 AMMarvin
07/23/2025, 3:31 AMMarvin
07/23/2025, 3:31 AMbash
prefect cloud login
2. Create a work pool (one-time setup):
bash
prefect work-pool create "default-work-pool" --type process
3. Save your deployment script (the Python code you shared) in a file, let's say deploy.py
4. Run the deployment script:
bash
python deploy.py
5. Start a worker to run your deployments:
bash
prefect worker start -p "default-work-pool"
That's it! The python deploy.py command will execute your deployment script and create the deployment in Prefect Cloud.
To verify your deployment was created, you can run:
bash
prefect deployment ls
Important notes:
- Keep your worker running to execute flows
- Make sure your secret block ("bb-token") is set up in Prefect Cloud
- You can monitor your deployments in the Prefect Cloud UI
- If you need to update the deployment later, just run the script again
Would you like me to explain any of these steps in more detail or help with something specific?