Madushan Pathirana
07/23/2025, 3:48 AMMarvin
07/23/2025, 3:48 AMMarvin
07/23/2025, 3:48 AMyaml
# prefect.yaml
deployments:
- name: "Amazon-bb-02"
entrypoint: "src/flows/Amazon/etl.py:main"
work_pool:
name: "default-work-pool"
source:
type: "bitbucket"
repository: "<https://bitbucket.org/xx/dbt_duck_etl.git>"
branch: "dev"
credentials:
access_token: "{{ prefect.blocks.secret.bb-token }}"
parameters:
api_base: "<https://dev.to/api>"
pages: 3
per_page: 30
output_file: "/root/data/devto_articles.csv"
2. Using the CLI command:
bash
prefect deploy \
--name "Amazon-bb-02" \
--pool "default-work-pool" \
src/flows/Amazon/etl.py:main \
--param api_base="<https://dev.to/api>" \
--param pages=3 \
--param per_page=30 \
--param output_file="/root/data/devto_articles.csv" \
--from bitbucket \
--repository "<https://bitbucket.org/xx/dbt_duck_etl.git>" \
--branch dev \
--reference "{{ prefect.blocks.secret.bb-token }}"
To use either method:
1. For the YAML file:
- Save the YAML content in a file named prefect.yaml
in your project root
- Run prefect deploy
from your project directory
2. For the CLI command:
- Simply run the command as shown above from your project directory
Some important notes:
- Make sure you're logged into Prefect Cloud (prefect cloud login
)
- The Secret block (bb-token
) must be configured in your Prefect Cloud workspace
- The work pool "default-work-pool" must exist in your workspace
- The repository URL and branch name are preserved from your original configuration
- The parameters are passed through as specified in your original script
The main differences from your original script are:
1. The deployment configuration is more declarative
2. The credentials are referenced using Prefect's templating syntax
3. The configuration can be version controlled (especially with the YAML approach)
Would you like me to explain any part of these configurations in more detail?Madushan Pathirana
07/23/2025, 3:54 AMMarvin
07/23/2025, 3:54 AMMarvin
07/23/2025, 3:54 AMbash
prefect cloud login
2. Then, assuming your prefect.yaml
is in your current directory, simply run:
bash
prefect deploy
That's it! The prefect deploy
command will automatically:
- Read your prefect.yaml
file
- Create the deployment in your Prefect Cloud workspace
- Set up the connection to your Bitbucket repository
- Configure all parameters as specified
To verify your deployment was created successfully, you can run:
bash
prefect deployment ls
If you need to make changes and redeploy, just modify the prefect.yaml
file and run prefect deploy
again.
Remember:
- Make sure your Secret block (bb-token
) is already configured in your Prefect Cloud workspace
- Ensure the work pool specified in your YAML exists in your workspace
- You should run these commands from the same directory where your prefect.yaml
file is located
Would you like me to explain any part of this process in more detail?Marvin
07/23/2025, 3:56 AMMarvin
07/23/2025, 3:56 AMuv
for package management, you'll want to use uvx
to run the Prefect commands. Here's the sequence of commands you need:
1. First, ensure you're logged into Prefect Cloud:
bash
uvx prefect cloud login
2. Then deploy using your `prefect.yaml`:
bash
uvx prefect deploy
To verify your deployment:
bash
uvx prefect deployment ls
The commands are exactly the same as before, just prefixed with uvx
to use your uv
-managed Python environment. This ensures you're using the correct Python environment and dependencies managed by uv
.
Remember:
- Run these commands from the directory containing your prefect.yaml
- Make sure your Secret block (bb-token
) is configured in Prefect Cloud
- Ensure your work pool exists in your Prefect Cloud workspace
Would you like me to explain anything else about using Prefect with uv
?Madushan Pathirana
07/23/2025, 6:55 AMMarvin
07/23/2025, 6:55 AMMarvin
07/23/2025, 6:56 AMprefect.yaml
file. Here's what you should do:
1. Create a prefect.yaml
file with the following content:
yaml
deployments:
- name: "Amazon-bb-02"
entrypoint: "src/flows/Amazon/etl.py:main"
work_pool:
name: "default-work-pool"
source:
type: "bitbucket"
repository: "<https://bitbucket.org/credilinq/dbt_duck_etl.git>"
branch: "dev"
credentials:
access_token: "{{ prefect.blocks.secret.bb-token }}"
parameters:
api_base: "<https://dev.to/api>"
pages: 3
per_page: 30
output_file: "/root/data/devto_articles.csv"
2. Then deploy using `uv`:
bash
uvx prefect deploy
This is the recommended way in Prefect 3.x because:
1. It's more maintainable
2. It can be version controlled
3. It supports all the configuration options you need
If you absolutely need to use a command-line approach, you would need to first create a deployment using Python code and then use prefect deploy
to deploy it. However, the YAML approach is much cleaner and more maintainable.
Would you like me to explain how to set up the deployment using Python code instead, or would you prefer to proceed with the YAML approach?Madushan Pathirana
07/23/2025, 7:13 AMMarvin
07/23/2025, 7:13 AMMarvin
07/23/2025, 7:13 AM<mailto:git@bitbucket.org|git@bitbucket.org>
)
2. The system either doesn't have proper SSH access configured or there's an issue with the URL format
Here are the solutions, try them in order:
1. Use HTTPS URL Instead of SSH
Modify your prefect.yaml
to use the HTTPS URL format:
yaml
deployments:
- name: "Amazon-bb-02"
entrypoint: "src/flows/Amazon/etl.py:main"
work_pool:
name: "default-work-pool"
source:
type: "bitbucket"
repository: "<https://bitbucket.org/credilinq/dbt_duck_etl.git>" # HTTPS URL
branch: "dev"
credentials:
access_token: "{{ prefect.blocks.secret.bb-token }}"
parameters:
api_base: "<https://dev.to/api>"
pages: 3
per_page: 30
output_file: "/root/data/devto_articles.csv"
2. If you must use SSH:
- Ensure your SSH key is properly set up in the environment where the worker is running
- The SSH URL should be in this format:
yaml
repository: "<mailto:git@bitbucket.org|git@bitbucket.org>:credilinq/dbt_duck_etl.git"
3. Verify your Bitbucket token:
- Check that your bb-token
secret block in Prefect Cloud contains a valid token
- You can verify the token by running:
bash
uvx prefect block type ls
uvx prefect block ls
4. Check Worker Logs
Run this command to see more detailed error information:
bash
uvx prefect worker log default-work-pool
Let me know which approach you'd prefer to try first, and I can provide more detailed steps for that specific solution. Also, please let me know if you see any specific error messages in the worker logs.Madushan Pathirana
07/23/2025, 7:20 AMMarvin
07/23/2025, 7:20 AMMarvin
07/23/2025, 7:20 AMpull
section to the YAML can help with repository cloning, and it's a good practice to explicitly define how the repository should be pulled. Let me help you with both aspects.
1. Modified YAML with pull section:
yaml
deployments:
- name: "Amazon-bb-02"
entrypoint: "src/flows/Amazon/etl.py:main"
work_pool:
name: "default-work-pool"
source:
type: "bitbucket"
repository: "<https://bitbucket.org/credilinq/dbt_duck_etl.git>"
branch: "dev"
credentials:
access_token: "{{ prefect.blocks.secret.bb-token }}"
pull:
# Specify how to authenticate when pulling the repository
credentials:
# You can use the same token or a different one specifically for pulling
access_token: "{{ prefect.blocks.secret.bb-pull-token }}"
parameters:
api_base: "<https://dev.to/api>"
pages: 3
per_page: 30
output_file: "/root/data/devto_articles.csv"
2. Regarding the token storage:
- It's actually a good practice to use separate tokens for deployment and pulling
- The deployment token needs permissions to create deployments in Prefect Cloud
- The pull token needs permissions to clone the repository
- This separation of concerns is more secure
Here's how to set up the new token:
bash
# Create a new secret block for the pull token
uvx prefect block create secret bb-pull-token
When prompted, enter your Bitbucket token that has repository read access.
You can verify your secret blocks with:
bash
uvx prefect block ls secret
This setup provides several benefits:
1. Clear separation between deployment and pull permissions
2. More explicit control over how the repository is accessed
3. Easier to rotate or update tokens independently
4. Better security practices by following the principle of least privilege
Would you like me to explain any part of this in more detail? Also, if you're using a different authentication method (like SSH keys), we can modify the pull section accordingly.