{"id":4665,"library":"open-data-contract-standard","title":"Open Data Contract Standard (Python)","description":"The `open-data-contract-standard` Python library provides a Pydantic model for reading and writing YAML files conforming to the Open Data Contract Standard (ODCS). It's extracted from the Data Contract CLI and its version number mirrors the major and minor versions of the ODCS it supports. The library is actively maintained, currently at version 3.1.2, supporting ODCS v3.1.0 and above.","status":"active","version":"3.1.2","language":"en","source_language":"en","source_url":"https://github.com/datacontract/open-data-contract-standard-python","tags":["data-contracts","pydantic","yaml","data-governance","schema-validation","odcs","data-quality"],"install":[{"cmd":"pip install open-data-contract-standard","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core library functionality is built upon Pydantic models for data validation and serialization.","package":"pydantic"}],"imports":[{"note":"The main Pydantic model for the data contract.","symbol":"OpenDataContractStandard","correct":"from open_data_contract_standard.model import OpenDataContractStandard"}],"quickstart":{"code":"from open_data_contract_standard.model import OpenDataContractStandard\n\n# Example 1: Load a data contract specification from a string\ndata_contract_str = \"\"\"\nversion: 1.0.0\nkind: DataContract\nid: 53581432-6c55-4ba2-a65f-72344a91553b\nstatus: active\nname: my_table\napiVersion: v3.1.0\n\"\"\"\ndata_contract_from_string = OpenDataContractStandard.from_string(data_contract_str)\nprint(\"--- Data Contract from string ---\")\nprint(data_contract_from_string.to_yaml())\n\n# Example 2: To load from a file, you would use from_file\n# Ensure 'data_contract.yaml' exists in the same directory\n# with valid ODCS content for this to run without error.\n# import os\n# file_path = 'data_contract.yaml'\n# with open(file_path, 'w') as f:\n#    f.write(data_contract_str)\n# data_contract_from_file = OpenDataContractStandard.from_file(file_path)\n# print(\"\\n--- Data Contract from file ---\")\n# print(data_contract_from_file.to_yaml())\n# os.remove(file_path) # Clean up file\n","lang":"python","description":"This quickstart demonstrates how to load an Open Data Contract Standard (ODCS) specification from a string using the `OpenDataContractStandard` Pydantic model and then print it back as a YAML string. It includes comments for how to load from a file, which requires an existing YAML file."},"warnings":[{"fix":"Always check the PyPI page or GitHub README for the exact version mapping between the pip module and the ODCS specification version it implements.","message":"The pip module version mirrors the major and minor versions of the Open Data Contract Standard (ODCS) it supports, but specifically does NOT mirror the patch version. For instance, ODCS v3.1.0 might correspond to pip module versions >=3.1.0 but not necessarily 3.1.0 exactly.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review the ODCS v3.0.0 changelog for a comprehensive list of breaking changes. Update your data contract YAML files to conform to the ODCS v3.x specification.","message":"Migration from ODCS v2.x to v3.x involved significant breaking changes in the standard's schema, which the `open-data-contract-standard` Python library (v3.x and above) enforces. Key changes include renaming `uuid` to `id`, `columns` to `properties`, and changing the `team` (formerly `stakeholders`) structure from an array to an object.","severity":"breaking","affected_versions":"3.x.x (when processing v2.x ODCS contracts)"},{"fix":"Ensure your data contracts strictly adhere to the ODCS v3.1.0 (or later) JSON Schema, removing any properties not explicitly defined in the standard. Review the ODCS v3.1.0 release notes for details on stricter validation.","message":"ODCS v3.1.0 introduced stricter JSON Schema validation, disallowing additional or undefined properties in certain sections of the contract. While v3.1.0 was declared backward compatible with v3.0.x, contracts that previously contained extra, undefined fields (and were thus valid under a looser schema) will now fail validation.","severity":"breaking","affected_versions":"3.1.0 and later"},{"fix":"Avoid using `slaDefaultElement` and the top-level `dataProduct`. Consult the latest ODCS documentation for recommended alternatives or replacements.","message":"In ODCS v3.1.0, `slaDefaultElement` and the top-level `dataProduct` fields were deprecated. While still functional, they will generate warnings and are slated for removal in future major versions (e.g., ODCS v4).","severity":"deprecated","affected_versions":"3.1.0 and later"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}