Dagster integration with Anthropic
Project description
dagster-anthropic
A dagster module that provides integration with Anthropic.
Installation
The dagster_anthropic module is available as a PyPI package - install with your preferred python
environment manager (We recommend uv).
source .venv/bin/activate
uv pip install dagster-anthropic
Example Usage
In addition to wrapping the Anthropic client (get_client/get_client_for_asset methods), this resource logs the usage of the Anthropic API to to the asset metadata (both number of calls, and tokens). This is achieved by wrapping the Anthropic.messages.create method.
Note that the usage will only be logged to the asset metadata from an Asset context - not from an Op context. Also note that only the synchronous API usage metadata will be automatically logged - not the streaming or batching API.
from dagster import AssetExecutionContext, Definitions, EnvVar, asset, define_asset_job
from dagster_anthropic import AnthropicResource
@asset(compute_kind="anthropic")
def anthropic_asset(context: AssetExecutionContext, anthropic: AnthropicResource):
with anthropic.get_client(context) as client:
response = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=[
{"role": "user", "content": "Say this is a test"}
]
)
defs = Definitions(
assets=[anthropic_asset],
resources={
"anthropic": AnthropicResource(api_key=EnvVar("ANTHROPIC_API_KEY")),
},
)
Development
The Makefile provides the tools required to test and lint your local installation
make test
make ruff
make check
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dagster_anthropic-0.0.5.tar.gz.
File metadata
- Download URL: dagster_anthropic-0.0.5.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9991495f587d5ec5a2f0aaecf87d8f7a293681d7d01795fceeb4c4761f41e6e3
|
|
| MD5 |
12c68dae1ef41f8f25fac7136e38ca62
|
|
| BLAKE2b-256 |
dba8f729ac5b0282d30758d133bb7060bdb1b9779313ed9e2c6f0028b921b0e7
|
File details
Details for the file dagster_anthropic-0.0.5-py3-none-any.whl.
File metadata
- Download URL: dagster_anthropic-0.0.5-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0089080117f54f1aed5cf1f3b462e3b8ac56c8e7039f7de2ad46cd13180e9fca
|
|
| MD5 |
f4337f397a7228c7aff3c3775f52e22d
|
|
| BLAKE2b-256 |
61889405465bed5775d307a79b1bf635f204f9ae4b71ab076560dc6f392df6f8
|