Skip to content

Commit 3a91ed9

Browse files
committed
ewoks install: fresh env by default and support pip+venv, uv, poetry, pixi and conda
1 parent 82a9e2c commit 3a91ed9

54 files changed

Lines changed: 3939 additions & 785 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- `ewoks install`: create a new python environment for the workflow (named after the workflow, in
13+
the directory the package manager creates environments in) instead of installing in the current
14+
environment. New arguments: `--env-root`, `--env-name`, `--clean`, `--in-place`,
15+
`--python-version` and `--with-ewoks` (add `ewoks` itself when the requirements do not contain
16+
it, so the workflow can be executed in the environment).
17+
- `ewoks execute`: add `--env` argument to execute a workflow in another python environment, for
18+
example one created by `ewoks install`.
1219
- `ewoks install`: add `--package-manager-name` and `--package-manager-command` arguments.
1320
- `ewoks convert`: add `--package-manager-name` and `--package-manager-command` arguments.
1421
- Add `ewoks lint` CLI command to check if a workflow is conform to the Ewoks specification.
22+
- Support the `uv`, `conda`, `pixi` and `poetry` package managers to generate and install workflow
23+
requirements. Every package manager stores the files it needs to reproduce the environment
24+
(`uv.lock`, `environment.yml`, ...) as well as the list of installed python distributions, from
25+
which any other package manager generates its own files to reproduce the environment.
26+
- Documentation: tutorial "Install and execute a workflow" and how-to guide "Reproduce a workflow
27+
environment".
28+
29+
### Changed
30+
31+
- The `pip` package manager is named `pip-venv`: it creates environments with `venv` and installs
32+
in them with `pip`.
1533

1634
### Removed
1735

1836
- `ewoks install`: remove `-p/--python` argument.
37+
- Support for the `pipenv` package manager.
1938

2039
## [7.0.0rc1] - 2026-08-02
2140

doc/howtoguides.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Getting started
1515
howtoguides/inspect_workflows
1616
howtoguides/gui
1717
howtoguides/python
18+
howtoguides/requirements
1819
howtoguides/engines
1920

2021
Automation

doc/howtoguides/requirements.rst

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
.. _requirements:
2+
3+
Reproduce a workflow environment
4+
================================
5+
6+
A :term:`workflow` stores the python environment it was created in as the ``requirements``
7+
field of its ``graph`` field. ``ewoks install`` recreates that environment and
8+
``ewoks execute --env`` runs the :term:`workflow` in it. See
9+
:ref:`this tutorial <install_tutorial>` for a step-by-step example.
10+
11+
What is stored
12+
--------------
13+
14+
``ewoks convert`` and ``ewoks execute -o convert_destination=...`` store
15+
16+
* ``python`` and ``system``: the python interpreter and the operating system.
17+
* ``distributions``: every installed python package with its version and, when it was not
18+
installed from the python package index, the git commit or the archive it came from. Any
19+
:term:`package manager` can recreate the environment from this list.
20+
* ``manager``: the :term:`package manager` that generated the requirements, with the content
21+
of the files it needs to recreate the environment: ``requirements.txt`` for pip-venv,
22+
``pyproject.toml`` and ``uv.lock`` for uv, ``pyproject.toml`` and ``poetry.lock`` for
23+
poetry, ``environment.yml`` for conda, ``pixi.toml`` and ``pixi.lock`` for pixi.
24+
25+
Use ``--exclude-requirements`` to store nothing.
26+
27+
.. note::
28+
29+
A :term:`workflow` that stores a list of requirements instead of the structure above is
30+
still supported: the list is parsed as a ``requirements.txt`` file.
31+
32+
Select a package manager
33+
------------------------
34+
35+
``ewoks convert`` uses the :term:`package manager` of the current python environment. It is
36+
detected from the environment variables and files that package managers leave behind, and
37+
from the tool that installed most of the packages. Use ``--package-manager-name`` to select
38+
one explicitly
39+
40+
.. code-block:: bash
41+
42+
ewoks convert demo demo.json --test --package-manager-name uv
43+
44+
``ewoks install`` uses the :term:`package manager` that generated the requirements, unless it
45+
is not installed on the machine. It installs the stored files of that :term:`package manager`.
46+
When the requirements do not contain them, or installing them fails, it generates its own
47+
files from the ``distributions`` list and installs those instead. Both installations are
48+
confirmed separately unless ``--yes`` is provided
49+
50+
.. code-block:: bash
51+
52+
# requirements generated by conda, environment created by uv
53+
ewoks install demo.json --yes --package-manager-name uv
54+
55+
``--package-manager-command`` provides the command that invokes the tool, for example when it
56+
is not on the ``PATH`` or when a faster implementation should be used
57+
58+
.. code-block:: bash
59+
60+
ewoks install demo.json --yes --package-manager-name conda \
61+
--package-manager-command micromamba
62+
63+
Choose the environment
64+
----------------------
65+
66+
.. code-block:: bash
67+
68+
# a root directory of your choice instead of the one of the package manager
69+
ewoks install demo.json --yes --env-root /tmp/envs
70+
71+
# a name of your choice instead of the workflow identifier
72+
ewoks install demo.json --yes --env-name demo-env
73+
74+
# remove the environment when it already exists
75+
ewoks install demo.json --yes --clean
76+
77+
# another python version than the one stored in the requirements
78+
ewoks install demo.json --yes --python-version 3.12
79+
80+
# add ewoks itself when the requirements do not contain it
81+
ewoks install demo.json --yes --with-ewoks
82+
83+
# install in the current python environment instead of creating one
84+
ewoks install demo.json --yes --in-place
85+
86+
The default name is the identifier of the :term:`workflow`, which is the ``id`` field of its
87+
``graph`` field. A :term:`workflow` without an identifier gets a name derived from its
88+
content.
89+
90+
Without ``--env-root`` the :term:`package manager` decides where the environment goes: conda
91+
creates it in its own environment directory (``conda config --show envs_dirs``), so
92+
``conda activate <name>`` finds it, and poetry in the directory it creates project
93+
environments in (``poetry config virtualenvs.path``). venv, uv and pixi create an environment
94+
wherever they are told to, so for those ewoks uses ``~/.ewoks/envs``.
95+
96+
An environment that already exists is installed in, which adds the requirements to what is
97+
already there. Use ``--clean`` to remove it first. Only a directory that contains a python
98+
environment is removed.
99+
100+
The environment of a :term:`workflow` is a directory. For pip-venv and conda it is a python
101+
environment, for uv and poetry it is a project with the environment in ``.venv`` and for pixi
102+
it is a workspace with the environment in ``.pixi/envs/default``. ``ewoks execute --env`` takes
103+
that directory, not the python interpreter inside it.
104+
105+
Limitations
106+
-----------
107+
108+
* ``--in-place`` is only supported by pip-venv and uv. The other package managers only install
109+
in an environment they created themselves.
110+
* ``--python-version`` is a request: uv, conda and pixi can provide any python version, while
111+
pip-venv and poetry can only use the version of the python interpreter that creates the
112+
environment. A warning is emitted when the version cannot be provided.
113+
* uv, poetry and pixi resolve the ``distributions`` into a lock file, which requires access to
114+
the package index. When that fails, a warning is emitted and the requirements are stored
115+
without files: the environment is then recreated from the ``distributions`` list.
116+
* A lock file is only read by a :term:`package manager` that understands its format version, so
117+
reproducing an environment can require a version of the tool that is at least as recent as
118+
the one that generated the requirements.
119+
* poetry 1.8 or later is required. Older versions are reported as not available.
120+
* A package installed from a local directory cannot be recreated elsewhere. This is reported as
121+
a warning when the requirements are generated.

doc/reference/cli.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,27 @@ ewoks install
1818

1919
If no ``requirements`` field exist, **ewoks install** will try to extract requirements from the :term:`tasks <Task>` in the :term:`workflows <Workflow>` before installing them.
2020

21-
Unless ``--yes`` is provided, **ewoks install** will ask for confirmation before installing the packages.
21+
**ewoks install** installs the files of the :term:`package manager` that generated the ``requirements``.
22+
When the ``requirements`` do not contain those files, or installing them fails, the Python ``distributions`` they contain are installed instead.
2223

23-
By default, packages are installed in the current Python environment: if **ewoks install** is run in a virtual environment, the packages will be installed in this virtual environment.
24+
Unless ``--yes`` is provided, **ewoks install** will ask for confirmation before each installation and before removing an existing environment.
25+
26+
By default, packages are installed in a new Python environment named after the workflow identifier, which is the ``id`` field of its ``graph`` field.
27+
The environment is created where the :term:`package manager` creates named environments (``~/.ewoks/envs`` for package managers that do not have such a directory).
28+
Use ``--env-root`` for another directory to create the environment in and ``--env-name`` for another name than the workflow identifier.
29+
An environment that already exists is installed in, unless ``--clean`` is provided to remove it first.
30+
The :term:`workflow` can be executed in that environment when it contains **ewoks** itself, which is the case when the ``requirements`` contain it.
31+
Use ``--with-ewoks`` to add **ewoks** when the ``requirements`` do not contain it, without changing any of the versions they do contain:
32+
33+
.. code-block:: bash
34+
35+
ewoks install myworkflow.json --yes --with-ewoks
36+
ewoks execute --env ~/.ewoks/envs/myworkflow myworkflow.json
37+
38+
Use ``--in-place`` to install in the current Python environment instead. This is not supported by all package managers.
39+
40+
The package manager that generated the ``requirements`` is used to reproduce the environment when it is available.
41+
Provide ``--package-manager-name`` (and optionally ``--package-manager-command``) to use another one: the ``requirements`` always contain the list of installed Python distributions as a fallback.
2442

2543
ewoks convert
2644
-------------

doc/reference/glossary.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@ Glossary
2828
Execution engine
2929
An execution engine is the underlying software used to execute the :term:`workflow`. :term:`Ewoks` supports multiple execution engines: pypushflow, orange, dask and the ewoks internal excution engine.
3030

31+
Package manager
32+
A package manager creates python environments and installs packages in them. :term:`Ewoks` uses package managers to store the environment in which a :term:`workflow` was created and to recreate it: pip with venv, uv, poetry, conda and pixi.
33+
3134
blissdata
3235
`Blissdata <https://bliss.gitlab-pages.esrf.fr/blissdata>`_ is an API for accessing data from BLISS in memory.

doc/tutorials.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Tutorials
88
tutorials/hello_world
99
tutorials/create_workflow
1010
tutorials/execute
11+
tutorials/install
1112
tutorials/infrastructure
1213
tutorials/external
1314
tutorials/develop

doc/tutorials/execute.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ The :ref:`python interface <execute_python>` for executing :term:`workflows <Wor
1313
1414
The equivalent exists for the :ref:`command-line <cli>`.
1515

16+
A :term:`workflow` can also be executed in a python environment created from the
17+
:term:`workflow` itself
18+
19+
.. code-block:: bash
20+
21+
ewoks install /path/to/graph.json --yes
22+
ewoks execute --env ~/.ewoks/envs/mygraph /path/to/graph.json
23+
24+
See :ref:`this tutorial <install_tutorial>` and
25+
:ref:`this how-to guide <requirements>`.
26+
1627
The :code:`engine=None` argument selects the default :term:`execution engine <Execution engine>`. Documentation on different :term:`execution engines <Execution engine>`:
1728

1829
* `ewoksppf <https://ewoksppf.readthedocs.io/>`_ : execute cyclic :term:`workflows <Workflow>`

doc/tutorials/getting_started.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ To inspect or modify a workflow, convert it to a JSON file:
8787
8888
ewoks convert demo demo.json --test
8989
90+
The JSON file also stores the python environment the :term:`workflow` needs, so it can be
91+
recreated later:
92+
93+
.. code-block:: bash
94+
95+
ewoks install demo.json --yes
96+
ewoks execute --env ~/.ewoks/envs/demo demo.json --outputs=all
97+
98+
See the `Install and execute a workflow tutorial <./install.html>`_.
99+
90100
Learn More
91101
==========
92102

doc/tutorials/install.rst

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
.. _install_tutorial:
2+
3+
Install and execute a workflow
4+
==============================
5+
6+
A :term:`workflow` needs the python packages of its :term:`tasks <Task>` to be installed.
7+
:term:`Ewoks` can store the python environment in which a :term:`workflow` was created inside
8+
the :term:`workflow` itself and recreate that environment later, on another machine or at
9+
another time.
10+
11+
This tutorial only needs the ``ewoks`` python package
12+
13+
.. code-block:: bash
14+
15+
pip install ewoks
16+
17+
Store the requirements
18+
----------------------
19+
20+
``ewoks convert`` saves the packages installed in the current python environment as the
21+
``requirements`` of the destination :term:`workflow`
22+
23+
.. code-block:: bash
24+
25+
ewoks convert demo demo.json --test
26+
27+
The ``requirements`` field of the ``graph`` field looks like this
28+
29+
.. code-block:: json
30+
31+
{
32+
"python": {"version": "3.12.11", "implementation": "CPython", "...": "..."},
33+
"system": {"system": "Linux", "machine": "x86_64", "...": "..."},
34+
"distributions": [
35+
{"name": "ewokscore", "version": "5.1.0", "installer": "pip"},
36+
{"name": "networkx", "version": "3.4.2", "installer": "pip"}
37+
],
38+
"manager": {
39+
"name": "pip-venv",
40+
"version": "25.0.1",
41+
"files": {"requirements.txt": "ewokscore==5.1.0\nnetworkx==3.4.2\n"}
42+
}
43+
}
44+
45+
* ``distributions`` are the installed python packages. Any :term:`package manager` can
46+
recreate the environment from this list.
47+
* ``manager`` is the :term:`package manager` that generated the requirements together with
48+
the files it needs to recreate the environment exactly, for example a lock file.
49+
50+
Create the environment
51+
----------------------
52+
53+
``ewoks install`` creates a python environment for the :term:`workflow`
54+
55+
.. code-block:: bash
56+
57+
ewoks install demo.json --yes
58+
59+
It prints the python interpreter of the environment it created, the command to execute the
60+
:term:`workflow` in it and the command to remove it again
61+
62+
.. code-block:: text
63+
64+
Installed requirements for demo.json
65+
Python : ~/.ewoks/envs/demo/bin/python
66+
Execute: ewoks execute --env ~/.ewoks/envs/demo demo.json
67+
Remove : rm -rf ~/.ewoks/envs/demo
68+
69+
Without ``--yes`` you are asked to confirm after the packages have been listed. The
70+
environment is named after the :term:`workflow` and created where the :term:`package manager`
71+
creates named environments. Use ``--env-root`` to create it in a directory of your choice,
72+
``--env-name`` to give it another name and ``--clean`` to remove it when it already exists.
73+
74+
Execute the workflow
75+
--------------------
76+
77+
``--env`` executes the :term:`workflow` with the python interpreter of that environment
78+
instead of the current one
79+
80+
.. code-block:: bash
81+
82+
ewoks execute --env ~/.ewoks/envs/demo demo.json --outputs=all
83+
84+
This works because the requirements contain ``ewoks`` itself: it was installed in the
85+
environment in which the :term:`workflow` was converted. When they do not, add
86+
``--with-ewoks`` to ``ewoks install`` to install it without changing any of the versions
87+
coming from the :term:`workflow`.
88+
89+
Remove the environment
90+
----------------------
91+
92+
The environment is a normal directory, so removing it is enough
93+
94+
.. code-block:: bash
95+
96+
rm -rf ~/.ewoks/envs/demo
97+
98+
This is the command that ``ewoks install`` prints when it creates the environment.
99+
100+
.. note::
101+
102+
``ewoks install`` uses the :term:`package manager` that generated the requirements when it
103+
is available and falls back to another one otherwise. See
104+
:ref:`this how-to guide <requirements>` to select a :term:`package manager`, to install
105+
in the current python environment or to choose a python version.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ test = [
4646
"ipykernel",
4747
"importlib_resources",
4848
"pyqt5",
49-
"pytest-venv",
49+
"uv",
50+
"poetry >=1.8",
5051
"defusedxml",
5152
]
5253
dev = [

0 commit comments

Comments
 (0)