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, and darwin/arm64) 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

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
  • 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 linux/amd64, the daemon currently runs native amd64 containers and rejects known foreign architectures. Live execution requires the same KVM 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.1.0.tar.gz (25.9 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.1.0-py3-none-manylinux_2_17_x86_64.whl (10.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

neurodesk-0.1.0-py3-none-manylinux_2_17_aarch64.whl (9.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

neurodesk-0.1.0-py3-none-macosx_11_0_arm64.whl (10.1 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: neurodesk-0.1.0.tar.gz
  • Upload date:
  • Size: 25.9 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.1.0.tar.gz
Algorithm Hash digest
SHA256 75b23a256696d190c583172f5b7e63b2736624a2469ef186f328e26523d2f3a8
MD5 f201c7d6e355330e10149ae160407489
BLAKE2b-256 3da5a975acb313402d6bc507f88611da87b651d764731106e03e20e33517992b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neurodesk-0.1.0-py3-none-manylinux_2_17_x86_64.whl
  • Upload date:
  • Size: 10.2 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.1.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c149c67c43ac55ff06dd068320f35a3e91301fc59f13b20d5b2c918ca2dbbaff
MD5 dd73e0e097b779d99758248ca160b5eb
BLAKE2b-256 cde533e28558ab45ec528f0dd562d9c0857aa7c7288bf14b5b8827f32e9dcae3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neurodesk-0.1.0-py3-none-manylinux_2_17_aarch64.whl
  • Upload date:
  • Size: 9.8 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.1.0-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 609ddd260e71f386c78d1dd155012f510594e89a6116ab44220cb5d14f1ff66a
MD5 55e172ba33cf51be01d7d78f52e59c3f
BLAKE2b-256 8fe3a86465855634d6d40a6c6c2e0dad2a2eb908fea38c79664dcd64716ab142

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neurodesk-0.1.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 10.1 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.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c99d057294b8b6d606fc549ddc0694c203d00e355e97aec44a473db71137c177
MD5 f64ba395d082412035400a5a00fcb184
BLAKE2b-256 2098113572225e6d47a4ce2488e40ee1c7377a357e96ae857ef65db508538adc

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