Skip to main content

metadata-schemas

PyPI version

This repository contains both the definitions of Metadata Schemas and a python library for creating schema objects with pydantic and Excel.

Defining Metadata Schemas

The schemas are defined in the JSON Schema format in the folder schemas. For more information you can view documentation at https://worldbank.github.io/metadata-schemas/

Excel

Excel sheets formatted for each metadata type are located in this repo in the excel_sheets folder.

Python library

To install the library run

pip install metadataschemas

Creating a pydantic metadata object

To create a timeseries metadata object run

from metadataschemas import indicator_schema

indicator_metadata = indicator_schema.TimeseriesSchema(idno='project_idno',series_description=indicator_schema.SeriesDescription(idno='project_idno', name='project_name'))

indicator_metadata.pretty_print()

And the print statement will show you the metadata object in a pleasant format.

TimeseriesSchema(
    idno='project_idno',
    series_description=series_description(
        idno='project_idno',
        name='project_name'
    )
)

Depending on your IDE, selecting TimeseriesSchema could show you what fields the schema contains and their corresponding object definitions.

There are metadata objects for each of the following metadata types:

Metadata Type Metadata Object
document document_schema.DocumentSchema
geospatial geospatial_schema.GeospatialSchema
image image_schema.ImageDataTypeSchema
indicator indicator_schema.TimeseriesSchema
indicators_db indicators_db_schema.TimeseriesDatabaseSchema
microdata microdata_schema.MicrodataSchema
resource resource_schema.Model
script script_schema.ResearchProjectSchema
table table_schema.Model
video video_schema.Model

Python - Metadata Manager

The Manager exists to be an interface with Excel and to lightly assist creating schemas.

For Excel we can:

  1. Create blank Excel files formatted for a given metadata type
  2. Write metadata objects to Excel
  3. Read an appropriately formatted Excel file containing metadata into a pydantic metadata object

To use it run:

from metadataschemas import MetadataManager

mm = MetadataManager()

filename = mm.write_metadata_outline_to_excel('indicator')

filename = mm.save_metadata_to_excel(indicator_metadata)

# Then after you have updated the metadata in the Excel file

updated_indicator_metadata = mm.read_metadata_from_excel(filename)

The manager also offers a convenient way to get started creating metadata in pydantic by creating an empty pydantic object for a given metadata type which can then be updated as needed.

# list the supported metadata types
mm.metadata_type_names

# get the pydantic class for a given metadata type
microdata_type = mm.metadata_class_from_name("microdata")

# create an instantiated pydantic object and then fill in your data
microdata_metadata = mm.create_metadata_outline("microdata")
microdata_metadata.repositoryid = "repository id"
microdata_metadata.study_desc.title_statement.idno = "project_idno"

Updating Schemas

First create a branch from the main branch. Branch names should follow the pattern 'schema/<your user name>/<short description of change>'.

Then make the change you want to the json schema in the schemas folder.

Then in pyproject.toml update the version number, changing either the major, minor or patch number as appropriate given the conventions below.

After, update the version number of the specific schema you updated in the json_to_python_config.yaml file to match the version number in pyproject.toml.

Next update the pydantic schemas so that they match the latest json schemas by running

python pydantic_schemas/generators/generate_pydantic_schemas.py

Finally update the Excel sheets by running

python -m pydantic_schemas.generators.generate_excel_files

Versioning conventions for schemas

Major Changes

  • field type changes that break convention and cannot be coerced such as a field moving from string to an array
  • a mandatory field added or optional field changed to mandatory

Minor Changes

  • field removed
  • optional field added

Patch Changes

  • field type changes that can be coerced such as int to string

Metadata

Release files for metadataschemas 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metadataschemas 0.2.0
File Size Uploaded Provenance Actions
metadataschemas-0.2.0.tar.gz 85.5 kB With provenance Details for metadataschemas-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for metadataschemas 0.2.0
File Interpreter ABI Platform Actions
metadataschemas-0.2.0-py3-none-any.whl Python 3 none any Details for metadataschemas-0.2.0-py3-none-any.whl

Total release size: 184.3 kB

Release files / metadataschemas-0.2.0.tar.gz

Download URL metadataschemas-0.2.0.tar.gz
Size 85.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3618021fe27cfc1e9bf6194056985c15c463760f4ca0f3df6529e7926f1790ea
BLAKE2b-256 checksum
How to use checksums
2a946af3c1bc7bf91f8a4460f1caeda83bf35f00e48d9450089acb2305a95820
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / metadataschemas-0.2.0-py3-none-any.whl

Download URL metadataschemas-0.2.0-py3-none-any.whl
Size 98.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ae699e8b4b02225e9def78d20026532077899984973ef663faa7ff85ed77511
BLAKE2b-256 checksum
How to use checksums
45655fad605882ac33dbf59f77400285b99a2f74b6767004f157ab731cd999ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Security for metadataschemas 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for metadataschemas-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page