Piotr
07/08/2025, 2:22 PMMarvin
07/08/2025, 2:22 PMMarvin
07/08/2025, 2:22 PMpython
from prefect import flow
from prefect.artifacts import create_markdown_artifact
@flow
def example_flow():
create_markdown_artifact(
key="summary",
markdown_content="## Flow Results\nProcessed 1000 records successfully",
)
Since you're using a self-hosted Prefect server, the artifacts will be stored directly in your server's database. You can view them in the Prefect UI after they're created.
The artifacts system is particularly useful for:
- Visualizing flow outputs
- Tracking progress over time
- Debugging by seeing when and where results were written
- Creating links to external storage locations (like S3 buckets)
You can find more details about artifacts in the official documentation.Piotr
07/08/2025, 2:25 PMMarvin
07/08/2025, 2:25 PMMarvin
07/08/2025, 2:26 PMpython
from prefect import flow
from prefect.artifacts import create_link_artifact
import boto3 # or your preferred storage client
@flow
def generate_pdf_report():
# Generate your PDF here
pdf_content = generate_pdf() # Your PDF generation logic
# Store the PDF in your storage system
s3 = boto3.client('s3')
s3.put_object(
Bucket='your-bucket',
Key='reports/report.pdf',
Body=pdf_content
)
# Create a link artifact to the stored PDF
create_link_artifact(
key="pdf_report",
link="<https://your-bucket.s3.amazonaws.com/reports/report.pdf>",
description="Generated PDF Report"
)
For proper handling of binary outputs, you should:
1. Use appropriate storage systems (S3, GCS, Azure Blob Storage, etc.)
2. Consider implementing proper versioning and cleanup policies
3. Use artifacts to create links to these stored files, making them easily accessible from the Prefect UI
4. Consider using Prefect's result storage functionality for managing where outputs are stored
This separation of concerns (storing binary data in appropriate storage systems while using artifacts for metadata and links) is the recommended approach for handling binary outputs in your flows.