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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linkinpy-0.0.4.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

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

linkinpy-0.0.4-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file linkinpy-0.0.4.tar.gz.

File metadata

  • Download URL: linkinpy-0.0.4.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for linkinpy-0.0.4.tar.gz
Algorithm Hash digest
SHA256 19ab1a9f0a7cad6e560f2104b6c37a965869979e1d660de6fe5a22ef2eb43323
MD5 2aabeafa2366b786cd42cdd8c122cd2f
BLAKE2b-256 a591b4be732eff94f276b02bd739f8f8b415f559d4ba83ce85968f2ad9cee7fd

See more details on using hashes here.

File details

Details for the file linkinpy-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: linkinpy-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 27.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for linkinpy-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d1dee01df068a3fd4462eae934e26a938c979b80fc86c605dca52119daac24a9
MD5 5b91a7a291818e115df4b892b46abc56
BLAKE2b-256 191e017c91897f0c5020616fc5ceaf55f28922484129f478b1db82bb2c1fcede

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 files

0.0.2

2 files

0.0.1

2 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