Skip to main content

Python utils for OMG processing

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

omgutils

Python utils for OMG processing

This omgutils repo is a WIP. One day it might have and do the following:

  • *project and dependency management with uv

  • *unit and integration tests with pytest

  • *GitHub Actions workflows for tests (CI)

  • *tagged releases on pypi

  • *GitHub Actions workflow for publishing tags to pypi (CI)

  • Machado lab code for TIFF and OMG processing (currently subpackages of stepsutils)

  • nice-to-read Python docstrings

  • do we need to publish separate readthedocs docs?

    • clicking through to real code is often more informative
    • published docs are often incomplete and/or stale
    • how far can we get with one good README?
    • publishing docs might be a good thing to do, anyway
  • notebooks to demonstrate preprocessing, similar to omg-preprocess

  • notebooks to demonstrate motion correction, similar to omg-motion-correction

  • tests for the of the demonstrated functionality with pytest

    • can the tests just run the notebooks?
  • installation, testing, getting started instructions

  • links to small datasets / test fixtures

Here's an overview of the workflow that this repo might support.

Flow chart summarizing OMG data inputs, processing steps, outputs, and diagnostic plots

editable diagram

Required and optional data inputs are in yellow boxes. Derived data products are in blue boxes. Diagnostic plots are in purple boxes.

The main processings steps (notebooks?) are in red boxes. Currently these mirror what we have in omg-preprocess and omg-motion-correction. Each of these contains many sub-steps, and the shape of these might want to evolve.

We should make our existing processing steps consume omgutils as a dependency so that we are not duplicating key code, and so that we are dogfooding.

We have oeg-preprocess code that also uses the AlignedTiff class in the stepsutils.tiff subpackage. OEG code could obtain the AlignedTiff dependency from omgutils. This should work find as a practical matter. But it would be slightly awkward to imply that OEG depends on OMG. To me this is the least bad option, though, as opposed to duplicating the common code, or creating ad managing a separate package like "tiffutils".

Dev bootstrapping notes

Here are some dev notes for reference!

uv and project setup

install uv locally

Init the project as a library

cd omgutils
uv init --lib

Reonfigure the build system in pyproject.toml because we'll want dynamic versioning on CI.

[build-system]
requires = ["hatchling", "uv-dynamic-versioning"]
build-backend = "hatchling.build"

Leave the src/omgutils/__init__.py there, but make it empty.

initial (placeholder) code to run and test

Add some hello world code so we can test something with pytest.

src/omgutils/hello/hello.py

import numpy as np


def hello(
    repetitions: int = 0
) -> list[str]:
    """Say "hello", repetitions times."""
    hellos = np.full((repetitions,), "hello", dtype=np.object_)
    return hellos

Add the numpy dependency

uv add 'numpy==2.4.6'

This declares the dependency in pyproject.toml. It also sets up a virtual environment for the project (.venv, git-ignored) and a uv.lock with explicit dependency versions.

Add a .gitignore

# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info

# Virtual environments
.venv

get the project version from git tags

Configure dynamic versioning

We want the project version numbers to correspond to Git tags, as described here.

Edit the pyproject.toml

[project]
name = "omgutils"
dynamic = ["version"]

...

[tool.hatch.version]
source = "uv-dynamic-versioning"

Create an initial tag.

git tag v0.0.1

Check the build results.

uv build
ls dist
# omgutils-0.0.1-py3-none-any.whl  omgutils-0.0.1.tar.gz

Make the version available at runtime, in src/omgutils/__init__.py

import importlib.metadata

try:
    __version__ = importlib.metadata.version(__name__)
except importlib.metadata.PackageNotFoundError:
    __version__ = "0.0.0"  # Fallback for development mode

Try printing the version at runtime.

uv run python -c "import omgutils; print(omgutils.__version__)"
# 0.0.1

testing with uv and pytest

Set up pytest and uv tooling, as described here

uv add --dev pytest

Create a few tests to run.

tests/omgutils/hello/test_hello.py

from omgutils.hello.hello import hello


def test_default_is_zero():
    hellos = hello()
    assert len(hellos) == 0

def test_ten():
    hellos = hello(10)
    assert len(hellos) == 10

Run the tests (uv run makes both pytest and omgutils available).

uv run pytest -v

Be able to run with coverage.

uv add --dev coverage
uv run coverage run -m pytest
uv run coverage report -m

run tests on CI

Set up CI testing and publishing to PyPI via GitHub Actions has described here.

Add .github/workflows/pytest.yml to set up uv and invoke pytest, similar to manual steps above. Run tests with python versions 3.11 - 3.14.

publish tags to PyPI on CI

PyPI, GitHub and uv are all friends, with just a bit of admin on GitHub and PyPI:

Created a pypi environment for this GitHub repo. No special environment configuration yet, but the environment exists with that name.

Add .github/workflows/pypi.yml to build the package, sanity check with tests/smoke_test.py, and publish to PyPi.

Create and push a repo tag to test out the publishing flow:

git tag -a v0.0.2 -m "Test of PyPI publishing."
git push --tags

The build succeeded.

This resulted in an omgutils package published to PyPI.

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

omgutils-0.0.5.tar.gz (207.8 kB view details)

Uploaded Source

Built Distribution

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

omgutils-0.0.5-py3-none-any.whl (26.2 kB view details)

Uploaded Python 3

File details

Details for the file omgutils-0.0.5.tar.gz.

File metadata

  • Download URL: omgutils-0.0.5.tar.gz
  • Upload date:
  • Size: 207.8 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 omgutils-0.0.5.tar.gz
Algorithm Hash digest
SHA256 461089188c043235216ad12d3e144b6ecd6bf0771f461fb48eadf54d20b882d7
MD5 c651d5e2365d10c3f11bafbe3396c679
BLAKE2b-256 8c9f0da467ab4dbbeb5c534b481638650a2e58ffd5c88e0fc8d8276e56e31a40

See more details on using hashes here.

File details

Details for the file omgutils-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: omgutils-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 26.2 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 omgutils-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1dd5fe5a4ef0d7b98fa7a35bb99deaa6a57ab63df0ec7c2e76402beb06c381bd
MD5 2209e6f20d6b0eee7e93943368aabb43
BLAKE2b-256 bb0eec7280d0e2ab4cdd6e171d1221c621db77b2619478308b6d1b9c77047c63

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