Giter VIP home page Giter VIP logo

ipyniivue's Introduction

ipyniivue

A Jupyter Widget for Niivue based on anywidget.

Installation

pip install ipyniivue

Usage

In a Jupyter environment:

from ipyniivue import NiiVue

nv = NiiVue()
nv.load_volumes([{"path": "images/mni152.nii.gz"}])
nv

See the basic demo to learn more.

Development

ipyniivue uses the recommended hatchling build-system, which is convenient to use via the hatch CLI. We recommend installing hatch globally (e.g., via pipx) and running the various commands defined within pyproject.toml. hatch will take care of creating and synchronizing a virtual environment with all dependencies defined in pyproject.toml.

Commands Cheatsheet

All commands are run from the root of the project, from a terminal:

Command Action
hatch run format Format project with ruff format . and apply linting with ruff --fix .
hatch run lint Lint project with ruff check ..
hatch run test Run unit tests with pytest

Alternatively, you can develop ipyniivue by manually creating a virtual environment and managing installation and dependencies with pip.

python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

Making Changes to the JavaScript Code

This is an anywidget project, which means the code base is hybrid Python and JavaScript. The JavaScript part is developed under js/ and uses esbuild to bundle the code. Any time you make changes to the JavaScript code, you need to rebuild the files under src/ipyniivue/static. This can be done in two ways:

npm run build

which will build the JavaScript code once, or you can start a development server:

npm run dev

which will start a development server that will automatically rebuild the code as you make changes. We recommend the latter approach, as it is more convenient.

Once you have the development server running, you can start the JupyterLab or VS Code to develop the widget. When finished, you can stop the development server with Ctrl+C.

NOTE: In order to have anywidget automatically apply changes as you work, make sure to export ANYWIDGET_HMR=1 environment variable. This can be set directly in a notebook with %env ANYWIDGET_HMR=1 in a cell.

Release Process

  1. Releases are automated using GitHub Actions and the release.yml workflow.
  2. The workflow is triggered when a new tag matching the pattern v* is pushed to the repository.
  3. To create a new release, create a tag from the command line:
    git tag -a vX.X.X -m "vX.X.X"
    git push --follow-tags
  4. When triggered, the workflow will:
  • Publish the package to PyPI with the tag version.
  • Generate a changelog based on conventional commits and create a GitHub Release with the changelog.

Changelog Generation

  • We generate a changelog for GitHub releases with antfu/changelogithub
  • Each changelog entry is grouped and rendered based on conventional commits, and it is recommended to follow the Conventional Commits.
  • The tool generates the changelog based on the commits between the latest release tag and the previous release tag.

By following this release process and utilizing conventional commits, you can ensure consistent and informative releases for your project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.