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.3.0.tar.gz (70.6 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.3.0-py3-none-any.whl (44.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: osa_py-0.3.0.tar.gz
  • Upload date:
  • Size: 70.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","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.3.0.tar.gz
Algorithm Hash digest
SHA256 77addc0a7458ff86812397625a2ee96aa841b812aa47e3f318cbde652bd327a2
MD5 7595d217a224b0b573f080d63d26e671
BLAKE2b-256 7fff5df07c9f74edc189b6695ad97cf17a18f94004b1feec467900f0d7eb3736

See more details on using hashes here.

File details

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

File metadata

  • Download URL: osa_py-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 44.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8725a57b89dedc5eb029df9a899ba0a3c5eded09450ae2c29a4799c65c56bbe7
MD5 5e2da3edb592b15c3c5933937b64a88c
BLAKE2b-256 9580ac6b757be135424b61c759b48a1d251e948f1a3674107eb247d059c0e49d

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