Skip to main content

OSA Python SDK — validators and transforms for the Open Scientific Archive

Project description

OSA

OSA Python SDK

The developer toolkit for the Open Science Archive — define metadata schemas, write validation hooks, build ingesters, and deploy conventions.

License Python

Pre-release — APIs will change without notice.


Install

pip install osa

Quickstart

Define a schema, write a hook, register a convention:

from osa import Schema, Field, Record, Reject, hook, convention

class Crystal(Schema, id="crystal-structure"):
    pdb_id: str
    resolution: float = Field(unit="Å")
    method: str

@hook
def resolution_check(record: Record[Crystal]) -> None:
    if record.metadata.resolution > 3.5:
        raise Reject("Resolution too low for inclusion")

convention(
    title="Crystal Structures",
    schema=Crystal,
    hooks=[resolution_check],
    files={"extensions": [".cif"], "min_count": 1},
)

Testing

Test hooks in-process without Docker:

from osa.testing import run_hook

run_hook(resolution_check, meta={"pdb_id": "1ABC", "resolution": 2.1, "method": "X-ray"})

Deploy

osa link --server https://my-archive.org
osa login
osa deploy

CLI reference

Command Description
osa link --server <url> Link project to an archive server
osa login Authenticate via device flow
osa logout Remove stored credentials
osa deploy Build OCI images and register conventions
osa meta Print the convention manifest
osa ingestion start Trigger an ingestion run

Concepts

Schema — a Pydantic model defining typed metadata fields for a convention.

Hook — a pure function decorated with @hook that receives a Record[T] and returns structured results. Hooks run as OCI containers with a filesystem I/O contract.

Convention — a bundle of a schema, hooks, file requirements, and an optional ingester.

Ingester — an async generator that pulls records from external systems into the archive on a schedule.

Record[T] — generic container binding a schema type to its metadata, files, and SRN.

Project structure

osa/
├── __init__.py              # Public API
├── authoring/               # @hook, convention(), Reject, Ingester
├── types/                   # Schema, Record, Field, File
├── runtime/                 # OCI entrypoints (osa-run-hook, osa-run-ingester)
├── testing/                 # run_hook() test harness
└── cli/                     # osa command (login, deploy, link, ...)

License

Apache 2.0

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

osa_py-0.1.0.tar.gz (63.2 kB view details)

Uploaded Source

Built Distribution

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

osa_py-0.1.0-py3-none-any.whl (38.7 kB view details)

Uploaded Python 3

File details

Details for the file osa_py-0.1.0.tar.gz.

File metadata

  • Download URL: osa_py-0.1.0.tar.gz
  • Upload date:
  • Size: 63.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for osa_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 10cfbf5fb0bfbd92ef9b8ce6c30279de16e926aa6e3f98415051847a68ef6c2a
MD5 11e90b151bcca4fa7ee0f1da0cc7cbce
BLAKE2b-256 9f62cb5ec268ed590574a75afa510643fcad82468f679950eb95cbaed9e7d693

See more details on using hashes here.

File details

Details for the file osa_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: osa_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for osa_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a815ac837b392bd9e9df89ff7dd3c48611f97c07d7e79a2a50a2762f95802a15
MD5 6479198f6ec69d873445009f134626b9
BLAKE2b-256 6bcf8d1af8f2627be8ba99a01a8d007f0e8151e2efd3721a7b4290c522ed2156

See more details on using hashes here.

Supported by

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