Skip to main content

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

dagster_gemini-0.0.3.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dagster_gemini-0.0.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file dagster_gemini-0.0.3.tar.gz.

File metadata

  • Download URL: dagster_gemini-0.0.3.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for dagster_gemini-0.0.3.tar.gz
Algorithm Hash digest
SHA256 13fa52a2239da879e426fa5eb5ea2b0c5642b79b17ab80a4d0f885e64cb6111f
MD5 79f0b025a15933ec9f76c21294dcf028
BLAKE2b-256 06bf51aaaba42588afbf60b0c8d308b16dedbfdb71f83732586ad8fe1c995221

See more details on using hashes here.

File details

Details for the file dagster_gemini-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for dagster_gemini-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 78df630b9430ff093e21040b403c058a439410c091c59d0d53912d591a0f8920
MD5 67711fa20b2e523c3116d402a6e0f17a
BLAKE2b-256 111db1095a366c9d8ca4d3ddadea05faa74880ca7bf61fede1d32cda6f57efee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page