Skip to main content

linkinpy

linkinpy is the Python core for running YAML-described bioimage-analysis methods in isolated uv environments. It provides:

  • a CLI: linkinpy list, linkinpy install, linkinpy run
  • spec parsing and validation
  • per-spec environment management
  • image loading, writing, and shared-memory transport helpers
  • result normalization for single-output and multi-output methods
  • Colab helper widgets
  • a small Python facade API

Run commands in this document from the LinkinPy/ folder.

Development Setup

uv sync
uv run ruff check src tests
uv run pytest

Optional developer commands:

uv run ruff format .
uv run python -m build
uv run pre-commit install

The same workflow is available through make:

make sync
make lint
make test
make format
make build

CLI Tutorial

List available methods:

uv run linkinpy list ../Library/nanopyx.yaml

Install a spec for the CLI interface:

uv run linkinpy install ../Library/nanopyx.yaml --interface cli

Each spec gets its own environment under ~/.linkinpy/<spec-name>/. If the spec contains how_to_cite, the install command prints that citation text after the install summary.

Run a method and save declared outputs to a folder:

uv run linkinpy run ../Library/nanopyx.yaml eSRRF \
  --output-dir outputs \
  image=input.tif \
  magnification=2

Use explicit output destinations when needed:

uv run linkinpy run ../Library/StarDist.yaml "Predict 2D Pretrained Model" \
  --output labels=outputs/labels.tif \
  image=input.tif \
  model_name=2D_versatile_fluo

Arguments are passed as name=value. For inputs declared as np.ndarray, the CLI accepts image paths and .npy files.

Python API Tutorial

from linkinpy import LinkinPy

lp = LinkinPy("../Library/nanopyx.yaml")
print(lp.list_callables())
lp.install(interface="cli")
print(
    lp.run(
        "eSRRF",
        {"image": "input.tif", "magnification": 2},
        output_dir="outputs",
    )
)

Lower-level APIs are also public:

  • load_spec / parse_spec
  • EnvironmentManager
  • run_spec_callable
  • run_spec_callable_in_environment
  • parse_run_result
  • read_image / write_image

Colab Tutorial

Install LinkinPy in a notebook:

!pip install linkinpy

Mount Google Drive:

from linkinpy import mount_google_drive

mount_google_drive()

Install a selected spec:

from linkinpy import install_colab_spec

install_colab_spec("/content/LinkinPy/Library")

Run a method from installed specs:

from linkinpy import run_installed_colab_method

run_installed_colab_method(
    output_dir="/content/drive/MyDrive/LinkinPy/outputs"
)

Colab displays image and labels outputs when possible and prints metadata/path outputs in the notebook output area.

Spec Contract

Specs are YAML files. Each method declares inputs, outputs, and output.

display_name: Example Package
python_version: "3.12"
how_to_cite: "Author A, Author B. Example Package. Journal, year."

install:
  python_packages:
    - name: example-package

segment:
  callable: example_package.segment
  inputs:
    - name: image
      display_name: Input Image
      type: np.ndarray
      role: image
      required: true
  outputs:
    - name: labels
      display_name: Label Image
      type: np.ndarray
      role: labels
      format: tif
      display: true
  output:
    cli: [io]
    colab: [display, io]
    napari: [display, io]
    imagej: [display, io]
    qupath: [display, io]

outputs is the return-value contract. Tuple/list returns map by output order. Dict returns map by output name.

More Documentation

Metadata

Release files for linkinpy 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for linkinpy 0.0.6
File Size Uploaded
linkinpy-0.0.6.tar.gz 30.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for linkinpy 0.0.6
File Interpreter ABI Platform
linkinpy-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 57.8 kB

Release files / linkinpy-0.0.6.tar.gz

Download URL linkinpy-0.0.6.tar.gz
Size 30.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a7922a6b9a241b03537bed8ace7def358d72f51f1696e70c8f76d2c7fbb61c6a
BLAKE2b-256 checksum
How to use checksums
a99c8306390746c65d51f25a2f8d61e55f79f42646e93c850904be464336506a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / linkinpy-0.0.6-py3-none-any.whl

Download URL linkinpy-0.0.6-py3-none-any.whl
Size 27.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6750caeda6990df30576c065051e409395a8f173d1533c7ed9430a2902e4569f
BLAKE2b-256 checksum
How to use checksums
82ec68d59c438652a068345eacb5f850174a30f68c68e762bf58128522b1b638
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page