Skip to main content

MetricFlow adapter for Datus semantic layer

Project description

datus-semantic-metricflow

MetricFlow adapter for Datus semantic layer.

Installation

pip install datus-semantic-metricflow

Dependencies (datus-metricflow, pydantic) will be installed automatically.

Requirements

  • Python >= 3.12

Quick Start

import asyncio
from datus_semantic_metricflow import MetricFlowAdapter, MetricFlowConfig

config = MetricFlowConfig(
    datasource="my_project",
    config_path="/path/to/metricflow/config",  # optional
)

adapter = MetricFlowAdapter(config)

async def main():
    # List metrics
    metrics = await adapter.list_metrics(limit=10)
    for metric in metrics:
        print(f"{metric.name}: {metric.description}")

    # Get dimensions for a metric
    dimensions = await adapter.get_dimensions("revenue")
    for dim in dimensions:
        print(f"{dim.name}: {dim.description}")

    # Query metrics
    result = await adapter.query_metrics(
        metrics=["revenue", "orders"],
        dimensions=["date", "region"],
        limit=100,
    )
    print(f"Columns: {result.columns}")
    print(f"Data: {result.data[:5]}")

asyncio.run(main())

Configuration

Field Type Default Description
datasource str Required Datasource for this semantic layer instance
config_path str None Path to MetricFlow configuration file
timeout int 300 Query timeout in seconds
db_config dict None Datus datasource config; Snowflake supports password or private_key / private_key_file with private_key_file_pwd plus optional role

API

  • list_metrics(path=None, limit=100, offset=0) - List available metrics
  • get_dimensions(metric_name, path=None) - Get dimensions for a metric
  • query_metrics(metrics, dimensions=[], ...) - Execute metric queries
  • validate_semantic() - Validate configuration files

Development

pip install -e ".[dev]"
pytest

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

datus_semantic_metricflow-0.2.6.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

datus_semantic_metricflow-0.2.6-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file datus_semantic_metricflow-0.2.6.tar.gz.

File metadata

File hashes

Hashes for datus_semantic_metricflow-0.2.6.tar.gz
Algorithm Hash digest
SHA256 0229a5bfd2529e5bdba341cbe84bf6b9c4f8f16394a2e7f3e75ecfc38c76ba23
MD5 29abeb9cad764498fb3ab70e70e05af5
BLAKE2b-256 1952ee73e14ad439ddb247533ae3890749046f5bd50b3bec4f974082e2e3b2c5

See more details on using hashes here.

File details

Details for the file datus_semantic_metricflow-0.2.6-py3-none-any.whl.

File metadata

File hashes

Hashes for datus_semantic_metricflow-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5d3763e047ddc7af7da84ad308257f5dceca34570fe438fe635351cb5a8c4be6
MD5 63eb37cfb4853df99d5d0bbf7b147b21
BLAKE2b-256 bca8e46aafa970578279fe3e722a93bc3f6a2c30baba4c422bd1969e8fe36c11

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