Skip to main content

A CLI to automate mundane tasks with Idefix

Project description

PyPI PyPI codecov pre-commit.ci status Code style: black Imports: isort

idefix_cli:idfx

This is a CLI helper tool for Idefix, named idfx. idfx gathers and automates boring and repetetive tasks such as setup and cleanup in a single tool.

Warning: Idefix itself is not publicly available yet.

Installation

stable

It is recommended to install this tool in isolation with pipx as

$ pipx install idefix_cli

Otherwise, the simplest way to install the latest stable version is

$ python3 -m pip install idefix_cli

bleeding-edge

From the top level of the repo, run

$ python3 -m pip install -u -e .

Note that most idfx commands explicitly require that the env variable $IDEFIX_DIR be set.

Internal documentation

The following contains usage examples. Get a complete description of available options with

$ idfx --help

Likewise, get help for each command therein as, for instance

$ idfx run --help

Commands

idfx clone

Clone an idefix problem directory by either copying the main source files (definitions.hpp, setup.cpp, idefix.ini).

$ idfx clone $IDEFIX_DIR/test/HD/KHI/ /tmp/myKHI

Files can be symbolically linked to instead of copied, with --shallow. Additional files may be included in the clone using the --extra argument. They can be specified either by name or POSIX pattern.

idfx setup

idfx setup is a thin wrapper around $IDEFIX_DIR/configure.py all arguments and flags are directly passed down to that script.

idfx setup creates a valid Makefile at the specified location and with the speficied parameters (CPU/GPU ? HD/MHD ? ... set idfx setup --help).

idfx run

idfx run runs the Idefix problem found at the specified location. It is mostly useful run tests problems sequentially for very short periods.

Note that this command will fail if neither idefix or Makefile are found in the specified directory. In case only the Makefile is present, this command will compile the program first.

idfx run is not a complete wrapper around the idefix executable. This means that if you need to pass additional arguments to idefix other than -i, you should run it directly.

minimal example: run a test sequentially

$ idfx run $IDEFIX_DIR/test/HD/KHI

The default behaviour is to use idefix.ini contained in the specified directory. If you want to run a different one, use -i/--inifile

$ idfx run . -i myconf.ini

Note that idfx run looks for the inifile relative to the cwd, and then relative to the specified directory.

running a shorter version of a problem

Use the --duration and --time-step arguments to run a modified version of a base inifile.

$ idfx run . --duration 1e-4

The patched copy will be save to a .ini_ file with a unique identifier (UUID). Those files are cleaned with other with idfx clean --all

Note that --time-step maps to Idefix's inifile TimeIntegrator.first_dt.

Use --one-step/--one to run a single time step (total simulation time equates to the first time step). The length of the time step can be adjusted in combination with --time-step, however, --one-step is incompatible with --duration.

$ idfx run . --one

is a shortcut for

$ idfx run . --duration x --time-step x

where x, is the existing value found in the inifile.

IO operations for inifiles

idfx read

Read an Idefix inifile and print the resulting dictionnary to stdout in a json parsable format. This is useful to inspect inifiles programatically in combination with tools like jq

$ idfx read $IDEFIX_DIR/test/HD/KHI/idefix.ini | jq '.Output.vtk' --compact-output
[0.01,-1,"single_file"]

By default, the ouptut of idfx read is flat. Optionnaly, you can use --indent <N> to improve human-readability.

idfx write

Conversely, idfx write converts from json formatted strings to Idefix inifile format

$ idfx write save.ini $(cat save.json)

arbitrary patching

idfx read and idfx write methods can be combined with jq to arbitrarily patch an inifile

$ idfx read test/HD/KHI/idefix.ini | jq .TimeIntegrator.CFL=1e6 | idfx write idefix_patched.ini

idfx clean

Removes generated files.

$ idfx clean .

By default only intermediate C++ (*.o, *.host and *.cuda) files are cleaned.

To also remove Makefile, idefix executables and *.ini_ files generated by idfx, run

$ idfx clean . --all

idfx clean also accepts a --dry-run/--dry flag. If this flag is passed then the list of files that would be deleted is printed.

idfx stamp

Prints key data for reproduction and development to stdout.

$ idfx stamp
v0.5
daff799bb64b0993f058f50779873d594376d5bf
lesurg
f-dahu
Sat Jan 16 16:15:28 2021

Which is roughly equivalent (and slightly more portable) to

$ cd $IDEFIX_DIR \
  && git describe --tags \
  && cd - > /dev/null \
  && date \
  && hostname \
  && echo $USER

Additionnally, one can get the underlying data in json-serializable format

$ idfx stamp --json
{
  "tag": "v0.5",
  "sha": "daff799bb64b0993f058f50779873d594376d5bf",
  "user": "glesur",
  "host": "f-dahu",
  "date": "Sat Jan 16 16:15:54 2021"
}

This is helpful to quickly store important metadata next to one's datafiles. The git tag may be of critical value for reproductability, especially when bugs in Idefix are found after simulations are run, like so

$ idfx stamp --json > metadata.json

Contribution guidelines

We use the pre-commit framework to automatically lint for code style and common pitfals.

Before you commit to your local copy of the repo, please run this from the top level

$ python3 -m pip install -u -e .[dev]
$ pre-commit install

Testing

We use the pytest framework to test idfx's internal components. The test suite can be run from the top level with a simple pytest invocation.

$ pytest

Project details


Release history Release notifications | RSS feed

This version

0.4.1

Download files

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

Source Distribution

idefix_cli-0.4.1.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

idefix_cli-0.4.1-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file idefix_cli-0.4.1.tar.gz.

File metadata

  • Download URL: idefix_cli-0.4.1.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for idefix_cli-0.4.1.tar.gz
Algorithm Hash digest
SHA256 d23d5c78f520e45f79608900d61f3c716a2b5d8dcd31cb384e68d2f47ba276b2
MD5 fe5032ce371e0c65c2527736ad8203ff
BLAKE2b-256 f19c0e687df57ec3536055289fbc6ab5732428f2e34ad67e324d8cceb2ddbbbd

See more details on using hashes here.

File details

Details for the file idefix_cli-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: idefix_cli-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for idefix_cli-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d19c94929b85fec9fd17909b9ec2779e48ab7e4243b82519f2a9faabdddf4d2
MD5 2b22f3b26c02c4a802558d7525af5ccf
BLAKE2b-256 f9b4181824150a5bb3730a148d0939057e8768b5948b812f61b567c2db246cee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page