Dagster integration with Gemini
Project description
dagster-gemini
A dagster module that provides integration with Gemini.
Installation
The dagster_gemini 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-gemini
Example Usage
In addition to wrapping the Gemini GenerativeModel class (get_model/get_model_for_asset methods), this resource logs the usage of the Gemini API to to the asset metadata (both number of calls, and tokens). This is achieved by wrapping the GenerativeModel.generate_content 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_gemini import GeminiResource
@asset(compute_kind="gemini")
def gemini_asset(context: AssetExecutionContext, gemini: GeminiResource):
with gemini.get_model(context) as model:
response = model.generate_content(
"Generate a short sentence on tests"
)
defs = Definitions(
assets=[gemini_asset],
resources={
"gemini": GeminiResource(
api_key=EnvVar("GEMINI_API_KEY"),
generative_model_name="gemini-1.5-flash"
),
},
)
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_gemini-0.0.2.tar.gz.
File metadata
- Download URL: dagster_gemini-0.0.2.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
976830fd1e6c085ad695103a2a8a78e19e117b673c465a41a68946f8474702c8
|
|
| MD5 |
eda8d825d2d853202c5a275001343a4e
|
|
| BLAKE2b-256 |
e7e3a5f19e984ada96208ee5726d7c294d25aaa2ca151d424be0d6f516cf3123
|
File details
Details for the file dagster_gemini-0.0.2-py3-none-any.whl.
File metadata
- Download URL: dagster_gemini-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f10354710d4cd190dbc2be0244a27eaf464a88b58e3580145a8aa057e03e2e59
|
|
| MD5 |
a28b0f0bdd5b5b0b0c70437c13db7906
|
|
| BLAKE2b-256 |
aef413c5eaf7c5aeca1381660bd11e0dfc2e560155dd7266f084370402182506
|