Skip to main content

ToolVIPER

Tools and utilities for optimized radio astronomy processing using the VIPER framework.

Python 3.11 3.12 3.13 Linux Tests macOS Tests ipynb Tests Version Status

ToolVIPER provides a suite of high-level tools designed to simplify Dask cluster management, logging, profiling, and data distribution for radio astronomy applications. It is part of the VIPER (Very Large Interferometry Post-processing and Exploratory Research) ecosystem.

Features

  • Dask Cluster Management: Easily create and manage local or SLURM-based Dask clusters with optimized configurations.
  • Unified Logging: Structured, colorized, and worker-aware logging system.
  • Resource Profiling: Built-in decorators to monitor CPU and memory usage of functions.
  • Interactive Utilities: Enhanced data display for Jupyter notebooks, including interactive JSON and HTML views for complex dictionaries.
  • Data Management: Simple interface for downloading and managing external datasets from Cloudflare.
  • Parameter Validation: Decorator-based system for validating function arguments using JSON schemas.
  • Graph Distribution: Tools to distribute functions across datasets along specific axes using Dask.

Installation

ToolVIPER requires Python 3.11, 3.12, or 3.13.

Basic Installation

pip install toolviper

With Optional Dependencies

ToolVIPER offers several optional dependency sets:

  • test: For running tests (pytest, black, etc.)
  • interactive: For Jupyter/IPython support (jupyterlab, matplotlib, ipympl, etc.)
  • docs: For building documentation (sphinx, nbsphinx, etc.)
  • all: Installs all optional dependencies.

Example:

pip install "toolviper[interactive]"

Quick Start

1. Dask Client Management

Example Notebook

ToolVIPER simplifies setting up a Dask environment.

from toolviper.dask.client import local_client

# Start a local Dask client with 4 workers
client = local_client(cores=4, memory_limit="8GB")
print(client.dashboard_link)

For SLURM clusters:

from toolviper.dask.client import slurm_cluster_client

client = slurm_cluster_client(
    workers_per_node=1,
    cores_per_node=4,
    memory_per_node="16GB",
    number_of_nodes=2,
    queue="normal",
    interface="ib0",
    python_env_dir="/path/to/env",
    dask_local_dir="/tmp/dask",
    dask_log_dir="dask_logs"
)

2. Logging

Example Notebook

ToolVIPER provides a pre-configured logger that can be used throughout your application.

from toolviper.utils import logger

logger.info("Initializing process...")
logger.warning("Low memory detected", verbose=True)

3. Profiling

Monitor your functions' resource consumption using decorators.

from toolviper.utils.profile import cpu_usage

@cpu_usage(filename="my_profile.csv")
def heavy_computation():
    # Your code here
    pass

heavy_computation()

4. Interactive Data Exploration

In a Jupyter notebook, you can use DataDict for better visualization of nested dictionaries.

from toolviper.utils.display import DataDict

my_data = {"level1": {"level2": {"key": "value"}}}
dd = DataDict(my_data)
dd.display()  # Renders an interactive JSON tree in Notebooks

5. Data Management

Access and download external datasets easily.

import toolviper

# List available files
toolviper.utils.data.list_files()

# Get a python list available files
toolviper.utils.data.get_files()

# Download a specific dataset
toolviper.utils.data.download("example_dataset.zip", folder="./data")

6. Parameter Validation

A detailed write-up can be found here: Parameter Validation.

Ensure your functions receive correct arguments using the `@validate` decorator.

from toolviper.utils.parameter import validate

@validate()
def my_function(param1: int, param2: str):
    # This function will automatically validate arguments 
    # against a corresponding .param.json schema.
    pass

Development and Testing

To contribute or run tests locally:

  1. Clone the repository:

    git clone https://github.com/casangi/toolviper.git
    cd toolviper
    
  2. Install in editable mode with test dependencies:

    pip install -e ".[test]"
    
  3. Run tests:

    pytest tests
    

License

ToolVIPER is licensed under the terms of the LICENSE file included in the root directory.

Download files

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

Source Distribution

toolviper-0.1.5.tar.gz (58.2 kB view details)

Uploaded Source

Built Distribution

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

toolviper-0.1.5-py3-none-any.whl (49.2 kB view details)

Uploaded Python 3

File details

Details for the file toolviper-0.1.5.tar.gz.

File metadata

  • Download URL: toolviper-0.1.5.tar.gz
  • Upload date:
  • Size: 58.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for toolviper-0.1.5.tar.gz
Algorithm Hash digest
SHA256 0dc4d9d36903d95ff0a211e66fa857b3693770d6c4edc133ba65048be1ef3613
MD5 289e26f8a26fe6251cb2c31aab4dc67c
BLAKE2b-256 fa1026fabe2a392ba7120412f783e11f1dbb12cca3d87d5c8c1ae928e00fa80f

See more details on using hashes here.

File details

Details for the file toolviper-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: toolviper-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 49.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for toolviper-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 95d5cfaf6c86f7b65f54c3b754088356ac369f2ca198bc7789eec3b74ec0dc51
MD5 55fae6ef64b97f5d8f0164f61462e678
BLAKE2b-256 9d25de7497002ab40fe455d0530e4114c6d79644c8cd0d4defd2916d1a10e6eb

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.7

2 files

0.1.6

2 files

This release

0.1.5 This release

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.5

2 files

0.0.4

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page