Skip to main content

YAML-driven hierarchical path namespace builder for acquisition data pipelines.

Project description

Acquisition Namespace

YAML-driven hierarchical path namespace builder for acquisition data pipelines.

Define your session directory layout once in a YAML spec; the library builds, parses, and validates paths at every level of the hierarchy — with zero hard-coded separators or string constants in your application code.

Installation

pip install acquisition-namespace

Or with uv:

uv add acquisition-namespace

Quick start

from acquisition_namespace import NamespaceBuilder

builder = NamespaceBuilder.from_yaml("my_namespace.yaml")

# Build the session basename from component values
name = builder.build_path("session", {
    "subject": "mouse_01",
    "datetime": "20260524_143022_123456",
    "task": "sequence",
})
# → "mouse_01__20260524_143022_123456__sequence"

# Build the full directory path from root to the session level
path = builder.generate_path("session", {...})
# → "mouse_01/mouse_01__20260524_143022_123456__sequence"

# Parse an existing path back into its fields
parts = builder.extract_level_values("session", name)
# → {"subject": "mouse_01", "datetime": "...", "task": "sequence"}

Spec YAML format

version: "1.0"
description: "My acquisition namespace."
hierarchy:
  - subject
  - session
  - file
optional_levels: []
levels:
  subject:
    template: "{subject}"
    regex: "(?P<subject>[\\w\\-]+)"
    optional_fields: []
  session:
    template: "{subject}__{datetime}__{task}"
    regex: "(?P<subject>[\\w\\-]+)__(?P<datetime>\\d{8}_\\d{6}(?:_\\d{6})?)__(?P<task>[\\w\\-]+)"
    optional_fields: []
  file:
    template: "{session}.{suffix}.{extension}"
    regex: "(?P<session>.+)\\.(?P<suffix>\\w+)\\.(?P<extension>\\w+)"
    optional_fields: []

Higher-level templates may reference lower-level names (e.g. {session} in the file template); the builder resolves them automatically.

Development setup

git clone https://github.com/murineshiftwork/acquisition-namespace.git
cd acquisition-namespace
uv sync --group dev
uv run pre-commit install --hook-type pre-commit --hook-type commit-msg
uv run pytest

Release workflow

  1. Work on a feature/ or fix/ branch, committing with cz commit
  2. Open a PR — CI (lint + tests + secrets scan) must pass before merge
  3. Merge to main → version bump and tag are created automatically
  4. Tag triggers release: GitHub release + PyPI publish

License

See LICENSE.

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

acquisition_namespace-1.2.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

acquisition_namespace-1.2.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file acquisition_namespace-1.2.0.tar.gz.

File metadata

  • Download URL: acquisition_namespace-1.2.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","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 acquisition_namespace-1.2.0.tar.gz
Algorithm Hash digest
SHA256 483bf3693557cf503fdf6a5e981f4555eff422be063b064e8c71c3101c9fb998
MD5 43468608a36c8fd4036c50f6dd38b6fd
BLAKE2b-256 8a8ee24030c91234050e74094a43f92d5be2d034876a90d6c62b5db70af2dc3d

See more details on using hashes here.

File details

Details for the file acquisition_namespace-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: acquisition_namespace-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","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 acquisition_namespace-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b58b3e371dd5c74a41f2bf67fdb348b6d880f5f954e46c90efc35d415cac5e94
MD5 f8892abfc8b715eb80c732bb24261dc9
BLAKE2b-256 2111f0aae52a1bb917cbdd637569c624338dbb34087b4aa111968e15cc31c344

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