linkinpy 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ *.DS_Store
2
+ *uv.lock
3
+ */__pycache__/*
4
+ *.pyc
5
+ *.tif
6
+ */target/
7
+ */build/
8
+ */.gradle/
9
+ */dist/
10
+ */.pytest_cache/
11
+ */.ruff_cache/
12
+ .vscode/settings.json
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [v0.0.1] - Date
11
+
12
+ ### Fixed
13
+
14
+
15
+ ### Added
16
+
17
+
18
+ ### Changed
19
+
@@ -0,0 +1,83 @@
1
+ # Contributing to linkinpy
2
+
3
+ Thanks for contributing. This guide keeps the local workflow simple and consistent.
4
+
5
+ ## Development Setup
6
+
7
+ Clone the repository, then enter the Python package folder:
8
+
9
+ ```bash
10
+ git clone https://github.com/YOUR_USERNAME/LinkinPy.git
11
+ cd LinkinPy
12
+ cd LinkinPy/
13
+ ```
14
+
15
+ Create the development environment:
16
+
17
+ ```bash
18
+ uv sync
19
+ uv run pre-commit install
20
+ ```
21
+
22
+ ## Daily Workflow
23
+
24
+ Create a branch for your work:
25
+
26
+ ```bash
27
+ git checkout -b feature/short-description
28
+ ```
29
+
30
+ Run the main local checks before opening a pull request:
31
+
32
+ ```bash
33
+ uv run pytest
34
+ uv run ruff check .
35
+ uv run ruff format .
36
+ uv run python -m build
37
+ ```
38
+
39
+ Or use the shorter `make` targets:
40
+
41
+ ```bash
42
+ make test
43
+ make lint
44
+ make format
45
+ make build
46
+ ```
47
+
48
+ ## Command Reference
49
+
50
+ - `uv sync`: create or update the local environment from `pyproject.toml`
51
+ - `uv run pytest`: run the test suite
52
+ - `uv run ruff check .`: run lint checks
53
+ - `uv run ruff format .`: format the codebase
54
+ - `uv run python -m build`: verify the package builds correctly
55
+
56
+ The repository also includes a `.python-version` file so local development and CI agree on the interpreter target.
57
+
58
+ This guide applies to the Python package in `LinkinPy/`.
59
+ Other top-level folders in the repository should keep their own contributing and setup instructions.
60
+
61
+ ## Pull Requests
62
+
63
+ Before opening a pull request, please make sure:
64
+
65
+ - tests pass locally
66
+ - linting and formatting are clean
67
+ - the package builds successfully
68
+ - docs are updated if the workflow or public API changed
69
+ - notable changes are reflected in `CHANGELOG.md`
70
+
71
+ ## Code Style
72
+
73
+ This project keeps the toolchain intentionally small:
74
+
75
+ - Ruff for linting and formatting
76
+ - Pytest for tests
77
+ - pre-commit for git hook integration
78
+
79
+ Prefer small, focused changes with clear commit messages and matching tests when behavior changes.
80
+
81
+ ## Getting Help
82
+
83
+ Open an issue for bugs or feature requests, or contact the maintainers at bruno.msaraiva2@gmail.com if you need help.
@@ -0,0 +1,77 @@
1
+ # Getting Started
2
+
3
+ This project uses `uv` to manage the local development environment.
4
+ Run every command below from the `LinkinPy/` folder.
5
+
6
+ The `.python-version` file pins the interpreter version expected for local development and CI.
7
+
8
+ ## 1. Create the environment
9
+
10
+ ```bash
11
+ uv sync
12
+ ```
13
+
14
+ What it does:
15
+
16
+ - creates a virtual environment if needed
17
+ - installs the project in editable mode
18
+ - installs the default development and test dependency groups
19
+
20
+ ## 2. Install git hooks
21
+
22
+ ```bash
23
+ uv run pre-commit install
24
+ ```
25
+
26
+ What it does:
27
+
28
+ - enables local checks before each commit
29
+ - runs formatting and lightweight validation automatically
30
+
31
+ ## 3. Run the tests
32
+
33
+ ```bash
34
+ uv run pytest
35
+ ```
36
+
37
+ What it does:
38
+
39
+ - runs the test suite from `tests/`
40
+ - confirms the package imports correctly from the `src/` layout
41
+
42
+ ## 4. Run linting and formatting
43
+
44
+ ```bash
45
+ uv run ruff check .
46
+ uv run ruff format .
47
+ ```
48
+
49
+ What they do:
50
+
51
+ - `ruff check .` finds lint issues
52
+ - `ruff format .` applies consistent formatting
53
+
54
+ ## 5. Build the package
55
+
56
+ ```bash
57
+ uv run python -m build
58
+ ```
59
+
60
+ What it does:
61
+
62
+ - creates distribution artifacts in `dist/`
63
+ - verifies the package metadata and build configuration are valid
64
+
65
+ ## Optional Make Targets
66
+
67
+ If you like `make`, these commands wrap the same workflow:
68
+
69
+ ```bash
70
+ make sync
71
+ make test
72
+ make lint
73
+ make format
74
+ make build
75
+ ```
76
+
77
+ For repository-level navigation, go back to the [root README](../README.md).
@@ -0,0 +1,95 @@
1
+ Metadata-Version: 2.4
2
+ Name: linkinpy
3
+ Version: 0.0.1
4
+ Summary: A python package to bring uv managed workflows to all common image analysis tools
5
+ Project-URL: Homepage, https://github.com/your-username/MyPackageFolder
6
+ Project-URL: Repository, https://github.com/your-username/MyPackageFolder
7
+ Project-URL: Issues, https://github.com/your-username/MyPackageFolder/issues
8
+ Project-URL: Changelog, https://github.com/your-username/MyPackageFolder/blob/main/CHANGELOG.md
9
+ Author-email: "Bruno M. Saraiva" <bruno.msaraiva2@gmail.com>
10
+ License-Expression: MIT
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Requires-Python: >=3.9
17
+ Requires-Dist: ipyfilechooser>=0.6.0
18
+ Requires-Dist: ipywidgets>=8.0
19
+ Requires-Dist: magicgui>=0.10.0
20
+ Requires-Dist: numpy>=1.26
21
+ Requires-Dist: pyyaml>=6.0
22
+ Requires-Dist: stackview>=0.14.0
23
+ Requires-Dist: tifffile>=2024.8.10
24
+ Provides-Extra: gui
25
+ Requires-Dist: pyqt6>=6.7.0; extra == 'gui'
26
+ Provides-Extra: napari
27
+ Requires-Dist: napari>=0.5.0; extra == 'napari'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # linkinpy
31
+
32
+ A Python package to bring `uv`-managed workflows to common image analysis tools.
33
+
34
+ ## Quick Start
35
+
36
+ ```bash
37
+ uv sync
38
+ uv run pytest
39
+ ```
40
+
41
+ Run these commands from the `LinkinPy/` folder.
42
+
43
+ This package pins its local development interpreter in `.python-version` and keeps package metadata in `pyproject.toml`.
44
+
45
+ ## Common Commands
46
+
47
+ ```bash
48
+ uv sync # create/update the local environment
49
+ uv run pytest # run the test suite
50
+ uv run ruff check . # lint the codebase
51
+ uv run ruff format . # format the codebase
52
+ uv run python -m build # build the source and wheel distributions
53
+ uv run pre-commit install
54
+ ```
55
+
56
+ If you prefer shorter aliases, the same workflow is available through `make`:
57
+
58
+ ```bash
59
+ make sync
60
+ make test
61
+ make lint
62
+ make format
63
+ make build
64
+ ```
65
+
66
+ ## LinkinPy Spec Workflow
67
+
68
+ LinkinPy reads YAML spec files such as `../Library/nanopyx.yaml`. Each spec file owns exactly one isolated `uv` virtual environment at `~/.linkinpy/<spec-file-name>/`, and all runs for that spec execute inside that environment. LinkinPy checks whether `uv` is installed, bootstraps it when missing, and installs the core package into every spec-owned environment automatically.
69
+
70
+ ```bash
71
+ uv run linkinpy list ../Library/nanopyx.yaml
72
+ uv run linkinpy install ../Library/nanopyx.yaml --interface cli
73
+ uv run linkinpy run ../Library/nanopyx.yaml eSRRF image=input.tif --output result.tif
74
+ ```
75
+
76
+ The `run` command accepts callable arguments as `name=value`. Image arguments declared as `np.ndarray` can be passed as image file paths for the CLI path. The core also exposes Python APIs for spec parsing, environment management, image transport, direct callable execution, and magicgui widget construction.
77
+
78
+ ## Project Layout
79
+
80
+ ```text
81
+ src/linkinpy/
82
+ tests/
83
+ pyproject.toml
84
+ .python-version
85
+ GETTING_STARTED.md
86
+ CONTRIBUTING.md
87
+ ```
88
+
89
+ ## Documentation
90
+
91
+ - Start with [GETTING_STARTED.md](GETTING_STARTED.md) for first-time setup
92
+ - See [CONTRIBUTING.md](CONTRIBUTING.md) for the contributor workflow
93
+ - Track user-facing changes in [CHANGELOG.md](CHANGELOG.md)
94
+
95
+ For the multi-project repository overview, see the [repository root README](../README.md).
@@ -0,0 +1,66 @@
1
+ # linkinpy
2
+
3
+ A Python package to bring `uv`-managed workflows to common image analysis tools.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ uv sync
9
+ uv run pytest
10
+ ```
11
+
12
+ Run these commands from the `LinkinPy/` folder.
13
+
14
+ This package pins its local development interpreter in `.python-version` and keeps package metadata in `pyproject.toml`.
15
+
16
+ ## Common Commands
17
+
18
+ ```bash
19
+ uv sync # create/update the local environment
20
+ uv run pytest # run the test suite
21
+ uv run ruff check . # lint the codebase
22
+ uv run ruff format . # format the codebase
23
+ uv run python -m build # build the source and wheel distributions
24
+ uv run pre-commit install
25
+ ```
26
+
27
+ If you prefer shorter aliases, the same workflow is available through `make`:
28
+
29
+ ```bash
30
+ make sync
31
+ make test
32
+ make lint
33
+ make format
34
+ make build
35
+ ```
36
+
37
+ ## LinkinPy Spec Workflow
38
+
39
+ LinkinPy reads YAML spec files such as `../Library/nanopyx.yaml`. Each spec file owns exactly one isolated `uv` virtual environment at `~/.linkinpy/<spec-file-name>/`, and all runs for that spec execute inside that environment. LinkinPy checks whether `uv` is installed, bootstraps it when missing, and installs the core package into every spec-owned environment automatically.
40
+
41
+ ```bash
42
+ uv run linkinpy list ../Library/nanopyx.yaml
43
+ uv run linkinpy install ../Library/nanopyx.yaml --interface cli
44
+ uv run linkinpy run ../Library/nanopyx.yaml eSRRF image=input.tif --output result.tif
45
+ ```
46
+
47
+ The `run` command accepts callable arguments as `name=value`. Image arguments declared as `np.ndarray` can be passed as image file paths for the CLI path. The core also exposes Python APIs for spec parsing, environment management, image transport, direct callable execution, and magicgui widget construction.
48
+
49
+ ## Project Layout
50
+
51
+ ```text
52
+ src/linkinpy/
53
+ tests/
54
+ pyproject.toml
55
+ .python-version
56
+ GETTING_STARTED.md
57
+ CONTRIBUTING.md
58
+ ```
59
+
60
+ ## Documentation
61
+
62
+ - Start with [GETTING_STARTED.md](GETTING_STARTED.md) for first-time setup
63
+ - See [CONTRIBUTING.md](CONTRIBUTING.md) for the contributor workflow
64
+ - Track user-facing changes in [CHANGELOG.md](CHANGELOG.md)
65
+
66
+ For the multi-project repository overview, see the [repository root README](../README.md).
@@ -0,0 +1,41 @@
1
+ .PHONY: help sync sync-dev test lint format check build docs
2
+
3
+ help:
4
+ @echo "Available commands:"
5
+ @echo " sync Create/update the local environment with uv"
6
+ @echo " sync-dev Alias for sync"
7
+ @echo " test Run the test suite"
8
+ @echo " lint Run Ruff lint checks"
9
+ @echo " format Format the codebase with Ruff"
10
+ @echo " check Run lint, tests, and build"
11
+ @echo " build Build source and wheel distributions"
12
+ @echo " docs Generate API docs with pdoc"
13
+
14
+ sync:
15
+ uv sync
16
+
17
+ sync-dev:
18
+ uv sync
19
+
20
+ test:
21
+ uv run pytest
22
+
23
+ lint:
24
+ uv run ruff check .
25
+
26
+ format:
27
+ uv run ruff format .
28
+
29
+ check:
30
+ uv run ruff check .
31
+ uv run pytest
32
+ uv run python -m build
33
+
34
+ build:
35
+ uv run python -m build
36
+
37
+ docs:
38
+ rm -rf docs
39
+ uv run pdoc src/linkinpy -o docs
40
+
41
+ .DEFAULT_GOAL := help
@@ -0,0 +1,80 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.26.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "linkinpy"
7
+ version = "0.0.1"
8
+ description = "A python package to bring uv managed workflows to all common image analysis tools"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ license-files = ["LICENSE*"]
13
+ authors = [
14
+ { name = "Bruno M. Saraiva", email = "bruno.msaraiva2@gmail.com" }
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Operating System :: OS Independent",
22
+ ]
23
+ dependencies = [
24
+ "magicgui>=0.10.0",
25
+ "numpy>=1.26",
26
+ "pyyaml>=6.0",
27
+ "tifffile>=2024.8.10",
28
+ "ipywidgets>=8.0",
29
+ "ipyfilechooser>=0.6.0",
30
+ "stackview>=0.14.0",
31
+ ]
32
+
33
+ [project.optional-dependencies]
34
+ gui = [
35
+ "pyqt6>=6.7.0",
36
+ ]
37
+ napari = [
38
+ "napari>=0.5.0",
39
+ ]
40
+
41
+ [project.urls]
42
+ Homepage = "https://github.com/your-username/MyPackageFolder"
43
+ Repository = "https://github.com/your-username/MyPackageFolder"
44
+ Issues = "https://github.com/your-username/MyPackageFolder/issues"
45
+ Changelog = "https://github.com/your-username/MyPackageFolder/blob/main/CHANGELOG.md"
46
+
47
+ [project.scripts]
48
+ linkinpy = "linkinpy.cli:main"
49
+
50
+ [dependency-groups]
51
+ dev = [
52
+ "build>=1.2.2",
53
+ "pdoc>=15.0.0",
54
+ "pre-commit>=4.2.0",
55
+ "pyqt6>=6.7.0",
56
+ "ruff>=0.11.0",
57
+ ]
58
+ test = [
59
+ "pytest>=8.3.0",
60
+ "pytest-cov>=6.0.0",
61
+ "pytest-xdist>=3.6.1",
62
+ ]
63
+
64
+ [tool.hatch.build.targets.wheel]
65
+ packages = ["src/linkinpy"]
66
+
67
+ [tool.pytest.ini_options]
68
+ addopts = "-ra"
69
+ testpaths = ["tests"]
70
+
71
+ [tool.coverage.run]
72
+ source = ["linkinpy"]
73
+ branch = true
74
+
75
+ [tool.coverage.report]
76
+ show_missing = true
77
+ skip_covered = true
78
+
79
+ [tool.uv]
80
+ default-groups = ["dev", "test"]
@@ -0,0 +1,51 @@
1
+ exclude = [
2
+ ".bzr",
3
+ ".direnv",
4
+ ".eggs",
5
+ ".git",
6
+ ".git-rewrite",
7
+ ".hg",
8
+ ".ipynb_checkpoints",
9
+ ".mypy_cache",
10
+ ".nox",
11
+ ".pants.d",
12
+ ".pyenv",
13
+ ".pytest_cache",
14
+ ".pytype",
15
+ ".ruff_cache",
16
+ ".svn",
17
+ ".tox",
18
+ ".venv",
19
+ ".vscode",
20
+ "__pypackages__",
21
+ "_build",
22
+ "buck-out",
23
+ "build",
24
+ "dist",
25
+ "node_modules",
26
+ "site-packages",
27
+ "venv",
28
+ ]
29
+ line-length = 88
30
+ indent-width = 4
31
+ target-version = "py39"
32
+
33
+ [lint]
34
+ fixable = ["ALL"]
35
+ unfixable = []
36
+ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
37
+ ignore = [
38
+ "UP007", # Keep Python 3.9-compatible Union annotations.
39
+ "UP045", # Keep Python 3.9-compatible Optional annotations.
40
+ ]
41
+
42
+ [format]
43
+ quote-style = "double"
44
+ indent-style = "space"
45
+ skip-magic-trailing-comma = false
46
+ line-ending = "auto"
47
+ docstring-code-format = true
48
+ docstring-code-line-length = "dynamic"
49
+
50
+ [lint.pydocstyle]
51
+ convention = "google"
@@ -0,0 +1,63 @@
1
+ from .colab import (
2
+ choose_colab_spec,
3
+ install_colab_spec,
4
+ installed_colab_specs,
5
+ launch_colab,
6
+ mount_google_drive,
7
+ run_installed_colab_method,
8
+ )
9
+ from .environment import EnvironmentManager, ensure_uv, find_uv
10
+ from .images import (
11
+ SharedArray,
12
+ attach_shared_array,
13
+ create_shared_array,
14
+ read_image,
15
+ write_image,
16
+ )
17
+ from .linkinpy import LinkinPy
18
+ from .runner import (
19
+ get_callable,
20
+ resolve_callable,
21
+ run_callable_in_process,
22
+ run_spec_callable,
23
+ run_spec_callable_in_environment,
24
+ )
25
+ from .spec import (
26
+ CallableSpec,
27
+ InputSpec,
28
+ LinkinPySpec,
29
+ PackageSpec,
30
+ SpecError,
31
+ load_spec,
32
+ parse_spec,
33
+ )
34
+
35
+ __all__ = [
36
+ "CallableSpec",
37
+ "EnvironmentManager",
38
+ "InputSpec",
39
+ "LinkinPy",
40
+ "LinkinPySpec",
41
+ "PackageSpec",
42
+ "SharedArray",
43
+ "SpecError",
44
+ "attach_shared_array",
45
+ "choose_colab_spec",
46
+ "create_shared_array",
47
+ "ensure_uv",
48
+ "find_uv",
49
+ "get_callable",
50
+ "install_colab_spec",
51
+ "installed_colab_specs",
52
+ "launch_colab",
53
+ "load_spec",
54
+ "mount_google_drive",
55
+ "parse_spec",
56
+ "read_image",
57
+ "resolve_callable",
58
+ "run_callable_in_process",
59
+ "run_installed_colab_method",
60
+ "run_spec_callable",
61
+ "run_spec_callable_in_environment",
62
+ "write_image",
63
+ ]
@@ -0,0 +1,30 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ from typing import Optional
6
+
7
+ from .images import create_empty_untracked_shared_array
8
+
9
+
10
+ def main(argv: Optional[list[str]] = None) -> int:
11
+ parser = argparse.ArgumentParser(description="Internal LinkinPy shared-memory helper.")
12
+ subparsers = parser.add_subparsers(dest="command", required=True)
13
+
14
+ allocate = subparsers.add_parser("allocate", help="Allocate an untracked shared-memory array.")
15
+ allocate.add_argument("--shape", required=True, help="JSON list of dimensions.")
16
+ allocate.add_argument("--dtype", required=True)
17
+ allocate.add_argument("--axes")
18
+
19
+ args = parser.parse_args(argv)
20
+ if args.command == "allocate":
21
+ shape = json.loads(args.shape)
22
+ descriptor, block = create_empty_untracked_shared_array(shape, args.dtype, axes=args.axes)
23
+ block.close()
24
+ print(json.dumps(descriptor.to_descriptor()), flush=True)
25
+ return 0
26
+ return 1
27
+
28
+
29
+ if __name__ == "__main__":
30
+ raise SystemExit(main())
@@ -0,0 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ import numpy as np
4
+
5
+
6
+ def add_one(x: float) -> float:
7
+ return x + 1
8
+
9
+
10
+ def image_plus_one(image: np.ndarray) -> np.ndarray:
11
+ return image + 1
12
+
13
+
14
+ def make_image() -> np.ndarray:
15
+ return np.arange(4, dtype=np.float32).reshape(2, 2)