This repository holds the pixi environment for developing
aiflow and
aiflow_nodes together. Both are
cloned into the root of this repository as independent git repositories (not
submodules), so you can branch, commit and push in each of them as usual. They
are listed in .gitignore.
aiflow_env/
├── README.md
├── pixi.toml
├── pixi.lock
├── aiflow/ # git clone, installed editable into the environment
└── aiflow_nodes/ # git clone, installed editable into the environment
The environment supports linux-64 and osx-arm64 (Apple Silicon). Intel
Macs (osx-64) are not supported, since conda-forge has no recent TensorFlow
build for them. On macOS, GPAW is not installed, because the only osx-arm64
build needs a newer numpy than pyiron_atomistics allows. All other packages
are the same, and only the GPAW calculator nodes in aiflow_nodes are
unavailable.
curl -fsSL https://pixi.sh/install.sh | shRestart your shell (or source ~/.bashrc) so pixi is on your PATH, then
check it works:
pixi --versionSee the pixi installation docs for other options.
git clone git@github.com:pyiron/aiflow_env.git
cd aiflow_envAll following commands run from this directory. git pull here later picks up
changes to pixi.toml and pixi.lock; rerun pixi install afterwards.
git clone git@github.com:pyiron/aiflow_nodes.gitYou can also work with your own fork instead.
git clone git@github.com:<your-user>/aiflow_nodes.git aiflow_nodesgit clone git@github.com:pyiron/aiflow.gitOr, from your own fork:
git clone git@github.com:<your-user>/aiflow.git aiflowEither way the clones must be named aiflow and aiflow_nodes (the explicit
target directory above takes care of renamed forks), since pixi.toml refers
to them by these paths.
pixi.toml installs aiflow from ./aiflow (editable, with the all extra)
and aiflow_nodes from ./aiflow_nodes (editable), so the clones must exist
before the next step. aiflow's development tools (its dev dependency group:
pytest, ruff, pylint, deptry, mkdocs, …) are listed in pixi.toml itself,
because pixi cannot install a dependency group of a path dependency. aiflow_nodes' conda-forge dependencies are declared once,
in its own pyproject.toml ([tool.pixi.package.run-dependencies]), and
pixi.toml pulls them in through its [dev] table.
pixi installThis resolves the environment from pixi.lock and installs it into .pixi/.
The first run downloads several GB (LAMMPS, GPAW, TensorFlow, ...) and takes a
while.
The aiflow.gui widget is written in TypeScript (aiflow/frontend) and is
compiled with npm. Node.js is part of the pixi environment, so build it with:
pixi run gui-buildThis runs npm install and npm run build in aiflow/frontend and writes
widget.js, widget.css and ngl.js to aiflow/src/aiflow/gui/static.
Without this step the GUI shows an empty widget.
When working on the frontend, pixi run gui-dev rebuilds on every change
(restart the Jupyter kernel to pick it up) and pixi run gui-test runs the
jest tests.
pixi shellThis starts a subshell with the environment active; leave it with exit.
Activation also sets GLIBC_TUNABLES=glibc.rtld.execstack=2, needed for the
conda-forge TensorFlow build on glibc >= 2.41 (has no effect on macOS).
To run a single command without a subshell use pixi run <command>, e.g.
pixi run lab to start JupyterLab.
Check the installation:
python -c "import aiflow_nodes, aiflow; print('ok')"pre-commit is part of the pixi environment. With the environment active,
install the hooks in each repository:
cd aiflow && pre-commit install && cd ..
cd aiflow_nodes && pre-commit install && cd ..- aiflow installs a
pre-commithook (ruff lint and format) and apre-pushhook that runs the fast unit tests withpython -m pytest. The push hook uses the active Python, so push from insidepixi shell. - aiflow_nodes installs a
pre-commithook (ruff lint and format).
To run all hooks over the whole repository once, e.g. after installing:
pre-commit run --all-filesSkip the hooks for a single commit or push with --no-verify.
All commands run from the root of this repository.
git pull
pixi installThis picks up changes to pixi.toml and pixi.lock. pixi shell and
pixi run also bring the environment in sync with the lock file
automatically, so pixi install mainly saves you the wait later.
Pull in each clone as usual:
git -C aiflow pull
git -C aiflow_nodes pullBoth are installed editable, so Python code changes take effect immediately. These cases need an extra step:
- aiflow's dependencies changed (its
pyproject.toml): runpixi install, which re-resolves the environment and updatespixi.lock. - aiflow_nodes' dependencies changed (its
pyproject.toml): runpixi installas well. A new conda dependency goes into its[tool.pixi.package.run-dependencies], not intopixi.toml. aiflow/frontendchanged: rebuild the GUI withpixi run gui-buildand restart the Jupyter kernel.
To move the packages in pixi.lock to the newest versions allowed by
pixi.toml:
pixi updateRun the tests, then commit the new pixi.lock (and pixi.toml, if you
changed version pins) to this repository.
The hook versions are pinned in each repository's .pre-commit-config.yaml,
so a git pull there updates them and pre-commit installs the new versions
on its next run. Nothing needs to be reinstalled.
Set python interpreter to .pixi/envs/default/bin/python