Skip to main content

Open Data Discovery Models

Project description

PyPI version

OpenDataDiscovery Models package

Has some useful tools for working with OpenDataDiscovery. Such as:

  1. Generated Python models from OpenDataDiscovery specification.
  2. API Client for working with OpenDataDiscovery.
  3. API for manual discovering data entities.

Installation

pip install odd-models

Models using example

odd-models.models package provides automatically generated Python model by OpenDataDiscovery specification. It can be used for creating data entities for uploading them into the Platform.

Code example (full code):

from oddrn_generator import PostgresqlGenerator
from odd_models.models import DataEntity, DataSet, DataSetField, DataSetFieldType, DataEntityType, Type, MetadataExtension
generator = PostgresqlGenerator(host_settings="localhost", databases="my_database", schemas="public")
DataEntity(
    oddrn=generator.get_oddrn_by_path("tables", "my_table"),
    name="my_table",
    type=DataEntityType.TABLE,
    metadata=[MetadataExtension(schema_url="https://example.com/schema.json", metadata={"env": "DEV"})],
    dataset=DataSet(
        field_list=[
            DataSetField(
                oddrn=generator.get_oddrn_by_path("tables_columns", "name"),
                name="name",
                type=DataSetFieldType(
                    type=Type.TYPE_STRING,
                    logical_type='str',
                    is_nullable=False
                ),
            )
        ]
    )
)

HTTP Client for OpenDataDiscovery


odd-models.client package provides API client for OpenDataDiscovery API. Client provides an API for working with OpenDataDiscovery Platform. It has various methods for working with data sources, data entities, management etc.

Code example(full code):

from odd_models.api_client.v2.odd_api_client import Client
from examples.postgres_models import data_entity_list

client = Client(host="http://localhost:8080")
client.auth(name="dev_aws_token", description="Token for dev AWS account data sources")
client.ingest_data_entity_list(data_entity_list)

Manual Discovery API


When there is no programmatic way to discover data sources and data entities, odd-models.discovery package provides API for manual discovery of data sources and data entities.

Code example(full code):

from odd_models.discovery import DataSource
from odd_models.discovery.data_assets import AWSLambda, S3Artifact
from odd_models.discovery.data_assets.data_asset_list import DataAssetsList

with DataSource("//cloud/aws/dev") as data_source:
    validation_lambda = AWSLambda.from_params(
        region="eu-central-1", account="0123456789", function_name="validation"
    )
    input_artifact = S3Artifact.from_url("s3://bucket/folder/test_data.csv")

    results = S3Artifact.from_url("s3://bucket/folder/test_result.csv")
    metrics = S3Artifact.from_url("s3://bucket/folder/test_metrics.json")

    input_artifact >> validation_lambda >> DataAssetsList([results, metrics])

    data_source.add_data_asset(validation_lambda)

Development

Installation

# Install dependencies
poetry install

# Activate virtual environment
poetry shell

Generating models

# Generate models. Will generate models pydantic into odd_models/models
make generate_models

# Generate api client. Will generate api client into odd_models/api_client
make generate_client

Tests

pytest .

Docker build

docker build -t odd-models .

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

odd_models-2.0.26.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

odd_models-2.0.26-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file odd_models-2.0.26.tar.gz.

File metadata

  • Download URL: odd_models-2.0.26.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.9.16 Linux/5.15.0-1035-azure

File hashes

Hashes for odd_models-2.0.26.tar.gz
Algorithm Hash digest
SHA256 958595e40ec03b34ec87ec80f419c2cb90f42df6f2c768b74cd76a0d993f3a0c
MD5 c218b6eec4b171bd8fa1ca611b9e98f3
BLAKE2b-256 c7c5dbc0666da1b5acf3366dc93a05231fcdb43f2483e16a2a09732fe67f629d

See more details on using hashes here.

File details

Details for the file odd_models-2.0.26-py3-none-any.whl.

File metadata

  • Download URL: odd_models-2.0.26-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.9.16 Linux/5.15.0-1035-azure

File hashes

Hashes for odd_models-2.0.26-py3-none-any.whl
Algorithm Hash digest
SHA256 7cb8c1b2b5df8c5aa008d811da867e51ffe26dce182e6e3f9c1702eb215d74db
MD5 3ad33ba3931303506254071d8e839df5
BLAKE2b-256 26baed0ce474eb6c9c5d155401242c8ef5c952947248205afcb21e0e5e37e96a

See more details on using hashes here.

Supported by

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