Gio
07/15/2025, 6:33 PMMarvin
07/15/2025, 6:33 PMMarvin
07/15/2025, 6:34 PMpython
from prefect import get_client
async def get_artifact_data():
# Create an async client
async with get_client() as client:
# Retrieve artifacts - you can filter by various criteria
artifacts = await client.read_artifacts(
limit=10, # Optional: limit the number of results
# You can filter by:
# - key
# - flow_run_id
# - task_run_id
# - type
)
# Get a specific artifact by ID
specific_artifact = await client.read_artifact("your-artifact-id")
# Get the latest version of artifacts with a specific key
latest_artifacts = await client.read_artifact_collections(
key="your-artifact-key"
)
# Run the async function
import asyncio
asyncio.run(get_artifact_data())
You can also create new artifacts using the client:
python
async def create_artifact():
async with get_client() as client:
# Create a new artifact
new_artifact = await client.create_artifact(
key="my-data",
data={"some": "data"}, # Your data here
type="json" # Specify the type of data
)
The client supports several operations for artifacts:
- `create_artifact()`: Create a new artifact
- `read_artifacts()`: Query multiple artifacts with filters
- `read_artifact()`: Get a specific artifact by ID
- `read_artifact_collections()`: Get the latest versions of artifacts
- `update_artifact()`: Update an existing artifact's metadata
Each artifact can store various types of data, including:
- JSON data
- Markdown content
- URLs
- File paths
- Custom data types
The artifacts system is particularly useful for:
- Storing and tracking model metrics
- Saving data quality reports
- Maintaining links to generated visualizations
- Tracking any other data assets produced by your flows
Remember that artifacts are immutable once created - each new version creates a new artifact, allowing you to maintain a history of your data assets.
Would you like me to provide more specific examples for any particular use case or artifact operation?Nate
07/15/2025, 6:35 PMNate
07/15/2025, 6:36 PMuv run <https://gist.githubusercontent.com/zzstoatzz/c8a4ad709876c44cefd40e65ac983485/raw/5dcdd854799b5f42558514b9a6870fda221aa735/asset_manager.py> list
Nate
07/15/2025, 6:36 PMNate
07/15/2025, 6:36 PMGio
07/15/2025, 6:41 PMNate
07/15/2025, 6:59 PM