Skip to main content

Python client for the ccx3 Neurodesk-oriented image and VM API

Project description

neurodesk

neurodesk is a Python client and shell helper for the ccx3 daemon. It is focused on Neurodesk container discovery, CVMFS-backed image import, VM lifecycle management, and running container commands from Python, notebooks, or normal shell scripts.

What It Provides

  • A typed HTTP client for ccvm
  • High-level container("name") helpers for Neurodesk containers
  • CVMFS listing and file-read helpers
  • Automatic daemon startup for local workflows
  • Shell activation and command wrappers for nd load / nd exec
  • Fulltest helpers for running Neurodesk test suites inside containers

Installation

The package is published as neurodesk:

pip install neurodesk

Both import neurodesk and import pyneurodesk are supported.

Development Setup

The package uses uv and requires Python 3.9 or newer.

cd pyneurodesk
uv sync
uv run pytest

The default package install keeps the client and shell dependencies small. The pyneurodesk-fulltest helper needs NIfTI and YAML support, so install the optional extra when you want to run fulltest recipes:

uv sync --extra fulltest

Publishing

Platform wheels should include the bundled ccvm binary so installs do not need a Go toolchain at runtime. Use the repository release helper from the repo root to cross-compile the currently supported wheels (linux/amd64, linux/arm64, darwin/arm64, and stable windows/amd64) with CGO_ENABLED=0:

UV_PUBLISH_TOKEN=pypi-... tools/publish_neurodesk.sh

By default the helper builds and publishes wheels only. To also publish a source-only sdist, run:

UV_PUBLISH_TOKEN=pypi-... tools/publish_neurodesk.sh --include-sdist

The sdist intentionally does not contain ccvm; installing from it fails during wheel build unless ccvm is discoverable through PYNEURODESK_CCVM, CCX3_CCVM, CCVM_BINARY, or PATH.

If you want to exercise real VM execution, build the Go daemon first from the repository root:

go build -o /tmp/ccx3-dev/ccvm ./cmd/ccvm

Then point pyneurodesk at it if it is not bundled in the default location:

export PYNEURODESK_CCVM=/tmp/ccx3-dev/ccvm

Python Usage

Run a Neurodesk command from Python:

import neurodesk as nd

niimath = nd.container("niimath")
print(niimath.run("niimath", "-help"))

Share a host directory with a container:

from pathlib import Path
import neurodesk as nd

work = nd.share_dir(Path.cwd(), writable=True)
niimath = nd.container("niimath")
print(niimath.run("sh", "-lc", f"ls {work.guest_path}"))

Connect to an existing daemon:

import neurodesk as nd

client = nd.connect(base_url="http://127.0.0.1:3456")
print(client.instance_status())

Shell Usage

Generate an activation script and load a container:

source <(uv run neurodesk activate --shell bash)
nd load niimath
niimath -help

On PowerShell, neurodesk activate auto-detects the native shell. The short form uses PowerShell's built-in iex alias:

nd activate | iex
nd load niimath
niimath -help

Run a one-off command through the active VM:

nd exec niimath -- niimath -help

Bind a shell session to a named cc VM when you want separate parallel sessions:

source <(uv run neurodesk activate --shell bash --vm analysis)
nd load niimath
nd exec niimath -- niimath -help

You can also target one command explicitly:

nd load niimath --vm analysis
nd exec --vm analysis niimath -- niimath -help

The shell integration creates wrapper scripts in a session directory under the user cache directory and reuses the shared daemon/VM where possible.

CVMFS Helpers

Search for available versions:

import neurodesk as nd

print(nd.search("niimath"))

Import a specific CVMFS path with the lower-level client:

import neurodesk as nd
from pyneurodesk.models import CVMFSSource, ImportImageRequest

client = nd.connect()
source = CVMFSSource(
    mirror="http://cvmfs.neurodesk.org",
    repo="neurodesk.ardc.edu.au",
    path="/containers/niimath_1.0.20250804_20251016",
)
client.import_image("niimath-cvmfs", ImportImageRequest.from_cvmfs_container(
    mirror=source.mirror,
    repo=source.repo,
    path=source.path,
))

Tests

Unit tests do not require KVM or a live daemon:

uv run pytest

The shell smoke example does require the Go daemon and host virtualization:

./examples/test_niimath_shell.sh

Environment Variables

  • PYNEURODESK_BASE_URL: connect to an existing ccvm daemon
  • PYNEURODESK_CCVM: path to the ccvm binary used for automatic startup
  • PYNEURODESK_CACHE_DIR: cache root for daemon state and shell sessions
  • PYNEURODESK_HTTP_TIMEOUT: default HTTP timeout in seconds
  • PYNEURODESK_BOOT_TIMEOUT: VM boot timeout in seconds, default 5
  • CCX3_VM_BOOT_TIMEOUT: daemon-side VM boot timeout in seconds, default 5
  • PYNEURODESK_RELEASES_DIR: local Neurodesk release metadata directory
  • PYNEURODESK_RELEASES_API: GitHub contents API endpoint for release metadata

Notes

pyneurodesk delegates actual container execution to ccvm. On stable amd64 hosts (linux/amd64 and windows/amd64), the daemon currently runs native amd64 containers and rejects known foreign architectures. Live execution requires the host virtualization setup described in the top-level repository README.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

neurodesk-0.4.0-py3-none-win_amd64.whl (11.2 MB view details)

Uploaded Python 3Windows x86-64

neurodesk-0.4.0-py3-none-manylinux_2_17_x86_64.whl (11.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

neurodesk-0.4.0-py3-none-manylinux_2_17_aarch64.whl (10.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

neurodesk-0.4.0-py3-none-macosx_11_0_arm64.whl (10.9 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file neurodesk-0.4.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: neurodesk-0.4.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 11.2 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for neurodesk-0.4.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 d3929dc51a6044c27e90840679dc7ff8622ff0ba08a01731b5fbebbb9d210e40
MD5 23d1af9ea3516ed9c8c018ead67149f8
BLAKE2b-256 398834ecef817a42cbd1a0a10095220011c7d1eea51d8c32b2676ff072abcc9c

See more details on using hashes here.

File details

Details for the file neurodesk-0.4.0-py3-none-manylinux_2_17_x86_64.whl.

File metadata

  • Download URL: neurodesk-0.4.0-py3-none-manylinux_2_17_x86_64.whl
  • Upload date:
  • Size: 11.3 MB
  • Tags: Python 3, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for neurodesk-0.4.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 785446ebff8242e7bad8efc585f6cb52e25eee226e7828cf885f4e482fb4bf73
MD5 205c6f7bf59af62d3b94ef9d8dc4de5b
BLAKE2b-256 e493782dc2379fd58e8031fbce93cb6b3a03f6134bee38246afca38971a59f69

See more details on using hashes here.

File details

Details for the file neurodesk-0.4.0-py3-none-manylinux_2_17_aarch64.whl.

File metadata

  • Download URL: neurodesk-0.4.0-py3-none-manylinux_2_17_aarch64.whl
  • Upload date:
  • Size: 10.5 MB
  • Tags: Python 3, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for neurodesk-0.4.0-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 62523bbdf50785b6e9a116641817f047edd8b9975a8930d923461ba4ba61b9fd
MD5 cb56760ef64104659b83a1840ed393c1
BLAKE2b-256 37064986b4af41c9ec22d1717b5dc86933d33aa1e33476b1b407e9dffbf16827

See more details on using hashes here.

File details

Details for the file neurodesk-0.4.0-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: neurodesk-0.4.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 10.9 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for neurodesk-0.4.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b12e381ebcc2056ac42afba571dc759ba94389a7ebac8694078ad281ec1e5a48
MD5 bce2fceb091befd8771ee586506d29ca
BLAKE2b-256 9457c9ae274f8391ca020145624efcea5849800e72262674b7dda3fa488e6608

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