Skip to main content

gen3-metadata-templates

CI PyPI version Python versions

Turn a Gen3 schema into friendly Excel submission templates, then validate the filled-in workbooks — with every error pinned to the exact sheet, row, and column, in plain English.

Documentation

Install

pipx install gen3-metadata-templates      # installs the `g3mt` command

# everything of one kind (e.g. all your clinical data) in one workbook
g3mt generate schema.json --category clinical -o clinical_template.xlsx

# ...or a single node
g3mt generate schema.json sample -o sample_template.xlsx
# ...fill sample_template.xlsx in Excel...
g3mt validate sample_template.xlsx --schema schema.json --annotate checked.xlsx

The schema can be a local file or an http(s):// URL — e.g. a bundle published on GitHub:

g3mt generate \
  https://raw.githubusercontent.com/AustralianBioCommons/acdc-schema-json/refs/tags/v1.2.0/dictionary/prod_dict/acdc_schema.json \
  lipidomics_file -o lipidomics_file_template.xlsx

Why this exists

Submitting metadata to a Gen3 data commons means producing records that conform to a graph-shaped data model: nodes (subject, sample, file, …) linked parent-to-child, each with typed, sometimes-controlled properties. That is hard for people who aren't fluent in linked data — and mistakes are usually only discovered late, as opaque errors.

g3mt closes that gap from both ends:

  • Generation produces a workbook a non-specialist can fill in confidently — parent links and controlled values are dropdowns, so most errors can't be made in the first place.
  • Validation catches whatever still slips through and reports it as "Sheet subject, cell C4: 'ten' isn't a whole number" rather than a stack trace.

Input and output

Input (generate) A Gen3 JSON schema bundle — a single .json file or an http(s):// URL — plus what you want to submit: a node, several nodes, or a whole category.
Output (generate) An .xlsx workbook: one sheet per node on the path to your target, with dropdowns, guidance, and reference sheets.
Input (validate) Your filled .xlsx workbook + the same schema.
Output (validate) A console report grouped by sheet (and optionally a highlighted copy of the workbook or a JSON report). Exit code 0 = clean, 1 = problems found, 2 = usage error.

Key features

  • Whole-category templates--category clinical gives a researcher every clinical sheet in one workbook, in the right fill order, without having to know the node names.
  • One sheet per node, in fill order — parents before children, so links always resolve.
  • Cross-sheet link dropdowns — a subject.submitter_id column on the sample sheet is a dropdown of the IDs you entered on the subject sheet. Reusing a parent ID across child rows is all "one-to-many" requires — no theory needed.
  • Controlled-value dropdowns — enum and boolean fields become dropdowns.
  • Self-documenting workbooks — required vs optional headers, a type/required hint row, per-column description comments, plus an Instructions sheet and a full Dictionary sheet.
  • Path selection — when a node is reachable by more than one chain of parents, you choose which one the template covers.
  • Precise, plain-English validation — errors located to the cell, rephrased for non-developers, with an optional highlighted copy of your file.
  • Use it as a CLI or a Python library — the CLI is a thin shell over an importable core.

Requirements

  • Python ≥ 3.9.5
  • gen3-validator ≥ 2.1 (installed automatically)

Development

git clone https://github.com/AustralianBioCommons/gen3-metadata-templates.git
cd gen3-metadata-templates
pip install poetry
poetry install
poetry run pytest -vv

Before pushing, run the same checks CI does:

poetry run ruff check .          # lint
poetry run ruff format --check . # formatting
poetry run pytest -vv            # tests

To preview the documentation site locally:

poetry install --with docs
poetry run mkdocs serve      # then open http://127.0.0.1:8000

Continuous integration & releases

  • CI (.github/workflows/build.yml) runs on every push and pull request to main: Ruff lint + format check, the test suite on Python 3.9–3.12, a g3mt --help smoke test, and a strict docs build.
  • Publishing (.github/workflows/publish_pypi.yml) runs when a GitHub Release is published: it verifies the release tag matches the package version, then builds and publishes to PyPI. It needs a PYPI_API_KEY repository secret.
  • TestPyPI (.github/workflows/publish_testpypi.yml) can be triggered manually from the Actions tab to publish a pre-release; it needs a TESTPYPI_API_KEY secret.

To cut a release:

poetry version <major|minor|patch>       # bump the version in pyproject.toml
git commit -am "chore: release vX.Y.Z"
git tag vX.Y.Z && git push --tags
gh release create vX.Y.Z --generate-notes # publishing the release runs the workflow

A note on 2.0

Version 2.0 is a full rewrite. The old Python API (generate_xlsx_template, make_node_template_pd, PropExtractor) has been replaced by the library and g3mt CLI documented here.

License

Apache 2.0 — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gen3_metadata_templates-2.3.0.tar.gz (44.8 kB view details)

Uploaded Source

Built Distribution

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

gen3_metadata_templates-2.3.0-py3-none-any.whl (52.6 kB view details)

Uploaded Python 3

File details

Details for the file gen3_metadata_templates-2.3.0.tar.gz.

File metadata

  • Download URL: gen3_metadata_templates-2.3.0.tar.gz
  • Upload date:
  • Size: 44.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1020-azure

File hashes

Hashes for gen3_metadata_templates-2.3.0.tar.gz
Algorithm Hash digest
SHA256 6b2574a2237ba891098e930c055372c700d15eb98910e97df57af80777401458
MD5 43e103eb51f303f1271b00b17c708840
BLAKE2b-256 b800632e2db3dff4ca31490155a8af5b6392a47cfaa50db1fe6beacec0645c61

See more details on using hashes here.

File details

Details for the file gen3_metadata_templates-2.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gen3_metadata_templates-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 291e7f98c37498469618dc93c5b3da3154ed61a14c417fe2c31079d7f5cd93a0
MD5 4b343e46cdbeed93189f625e63a5307f
BLAKE2b-256 3e28602efca073f381cc9f64292cf6400e156e10c75c6f6fc493a00995b1ac5c

See more details on using hashes here.

Release history Release notifications | RSS feed

2.4.0

2 files

This release

2.3.0 This release

2 files

2.2.0

2 files

2.1.0

2 files

2.0.0

2 files

1.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page