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

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="https://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 Distribution

neurodesk-0.2.0.tar.gz (35.1 kB view details)

Uploaded Source

Built Distributions

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

neurodesk-0.2.0-py3-none-win_amd64.whl (10.7 MB view details)

Uploaded Python 3Windows x86-64

neurodesk-0.2.0-py3-none-manylinux_2_17_x86_64.whl (10.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

neurodesk-0.2.0-py3-none-manylinux_2_17_aarch64.whl (10.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

neurodesk-0.2.0-py3-none-macosx_11_0_arm64.whl (10.5 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file neurodesk-0.2.0.tar.gz.

File metadata

  • Download URL: neurodesk-0.2.0.tar.gz
  • Upload date:
  • Size: 35.1 kB
  • Tags: Source
  • 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.2.0.tar.gz
Algorithm Hash digest
SHA256 b2b716afdc1d13d80538e251a9366a8d0cf90c0bfd560febef8b7e7b1a8d5e06
MD5 6b3ef4cc76cd304f69ef761f17342e6d
BLAKE2b-256 4aab91930731c8a054a5d7d7f3dbc2225acee5557f12b3c6d6442e53c09be466

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neurodesk-0.2.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 10.7 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.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 63f3229850eccf2a45f188dd469c5401c4ceacfbaf82af74475e744572c7d96c
MD5 36e2c5ccd937130cb65fb2fda951d18d
BLAKE2b-256 494615a7e8950cfc0bd4d47e063f6d0a443a8e0f4575457def795ff8187ba056

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neurodesk-0.2.0-py3-none-manylinux_2_17_x86_64.whl
  • Upload date:
  • Size: 10.5 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.2.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 fea8a33e758a23cab34c09345b87663c3cbf840bd3c11f846653615ea8b31b31
MD5 bb1d3d5b8b9bf15cb712c544509a10d6
BLAKE2b-256 58a672fd8c79fc313be798cce1fe1f9751f3f3baaaa0ebc12c0ced2818d83868

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neurodesk-0.2.0-py3-none-manylinux_2_17_aarch64.whl
  • Upload date:
  • Size: 10.0 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.2.0-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 857bbdca8f1bf63f691926121c58977ea227fa166440dc7495f670e61a25a5cb
MD5 c00584da7f58e4f651b0a3de8207926e
BLAKE2b-256 6e729dcf50d60f6a5819a2e2ef6d49fd4483ace8825ab6b579f2620f2fd99444

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neurodesk-0.2.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 10.5 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.2.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4bf245a7142ac1b5d23095ed891cf5433fc69d34a5fdfe9515086ef883e8d34d
MD5 6849f09b80da429834a5aa4cacbd4351
BLAKE2b-256 450d5f172a977c62b4be1d60cab92cc7529c129cbe28fe2f24689e0681fddfc7

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