ODD Models
raw JSON → 2.0.51 verified Fri May 01 auth: no python
Open Data Discovery Models provides the data model schemas for Open Data Discovery (ODD) platform. Version 2.0.51 supports Python 3.9+ and defines entities like datasets, jobs, and metadata. The library is actively maintained with a focus on ODD protocol compatibility.
pip install odd-models Common errors
error ImportError: cannot import name 'DataSet' from 'odd_models' ↓
cause Common mistake: importing from the top-level package instead of the models submodule.
fix
Use: from odd_models.models import DataSet
error ValidationError: 1 validation error for DataSetField type value is not a valid enumeration member; permitted: 'bool', 'int32', 'int64', 'float', 'double', 'string', 'binary', 'timestamp', 'date', 'time', 'list', 'map', 'struct', 'union', 'null' ↓
cause Providing an invalid type string for DataSetField.type.
fix
Use one of the allowed enum values: bool, int32, int64, float, double, string, binary, timestamp, date, time, list, map, struct, union, null.
error AttributeError: module 'odd_models' has no attribute 'models' ↓
cause Possible outdated installation; or the import path changed in version 2.0.
fix
Install the latest version: pip install --upgrade odd-models
Warnings
breaking In version 2.0, the package was restructured: imports changed from `odd_models` namespace to `odd_models.models`. Old imports (e.g., `from odd_models import DataSet`) will fail. ↓
fix Use `from odd_models.models import DataSet`.
gotcha All `odd_path` fields must be unique across entities. Using duplicate values causes validation errors. ↓
fix Ensure each odd_path string is globally unique.
deprecated The `DataConsumer` and `DataProducer` models are deprecated as of 2.0. Use `DataSet` with appropriate role fields instead. ↓
fix Migrate to DataSet and set `role` attribute accordingly.
Imports
- DataSet wrong
from odd_models import DataSetcorrectfrom odd_models.models import DataSet - DataTransformer
from odd_models.models import DataTransformer - DataSetField
from odd_models.models import DataSetField - MetadataExtension
from odd_models.models import MetadataExtension
Quickstart
from odd_models.models import DataSet, DataSetField, MetadataExtension
import datetime
# Create a dataset
field = DataSetField(
odd_path='my_db.public.users.id',
name='id',
type='int64',
is_primary_key=True
)
dataset = DataSet(
odd_path='my_db.public.users',
name='users',
metadata=[MetadataExtension(metadata={'source': 'postgres'})],
fields_list=[field],
updated_at=datetime.datetime.now(datetime.timezone.utc)
)
print(dataset)