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.1.tar.gz (4.9 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.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dagster_gemini-0.0.1.tar.gz
Algorithm Hash digest
SHA256 745c126b66e3051b49619099b1d288ca17412660521d6c41c618d501475c88c9
MD5 6b51fbbd064631988a579fd1bfd90841
BLAKE2b-256 8b12c1b44e1bd598a705aa6a17a739fafdb8c0774f99ae96f743cbf9579ba668

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagster_gemini-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e1e031dbddb1550a4aa1531eb80b571e5698f5fe6ee311f1df0c8edc051cb7eb
MD5 1df2176b99b9d5bca7350b7aed0c8a34
BLAKE2b-256 d6757cf07f3df9e73ea5fc7c6228e72b1eda216e0321221e83ed09a1c4c81066

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