OSA Python SDK — validators and transforms for the Open Scientific Archive
Project description
OSA Python SDK
The developer toolkit for the Open Science Archive — define metadata schemas, write validation hooks, build ingesters, and deploy conventions.
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file osa_py-0.2.0.tar.gz.
File metadata
- Download URL: osa_py-0.2.0.tar.gz
- Upload date:
- Size: 63.8 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44d8b325f970ab9dbac2aa6b302eb0b41459c8f9402eb96ef73729d5b4d2aa24
|
|
| MD5 |
258b7a8a312f05cc8cd0c9d6a5776984
|
|
| BLAKE2b-256 |
be63823cbb196491c748ba735414f4914afa21bdbffaa56fb2b131aee05e9215
|
File details
Details for the file osa_py-0.2.0-py3-none-any.whl.
File metadata
- Download URL: osa_py-0.2.0-py3-none-any.whl
- Upload date:
- Size: 39.1 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d17d5fabe8a261adef6f7725f34b7c4f0dfc62891c52788fa1fe47ac67986c13
|
|
| MD5 |
e6eb8cccdc17abe29bd0559b55e3c1a2
|
|
| BLAKE2b-256 |
a406123b026c54624c0a05e12104a515b29a63838e6627e17f18c614dc6f89a1
|