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.4.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.4-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dagster_gemini-0.0.4.tar.gz
Algorithm Hash digest
SHA256 e7517bfd3085079ec0d207d43c31add58c8630e398411b75f002ee635170d590
MD5 c82c5e6f9e720692af643574c31e1386
BLAKE2b-256 23a10fcbbeb72c3d7b99da864ef845627104646373b3d43fe6bd8893fffb88af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagster_gemini-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 797fb67e9ccc44709ba9892763b7098a7835e8dffa602bfd6ccebe719bc7f2d5
MD5 df2698583b9da5c23e4b6622061f3d65
BLAKE2b-256 183d7e9d4b0dcbfe61ef1a1b830475fa271385ef8b7eb0288c24f27f8d69cf70

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