Metadata-Version: 2.1
Name: experimaestro
Version: 1.3.6
Summary: "Experimaestro is a computer science experiment manager"
Home-page: https://github.com/experimaestro/experimaestro-python
License: GPL-3
Keywords: experiment manager
Author: Benjamin Piwowarski
Author-email: benjamin@piwowarski.fr
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: arpeggio (>=2,<3)
Requires-Dist: attrs (>=23.1.0,<24.0.0)
Requires-Dist: cached-property (>=1.5.2,<2.0.0) ; python_version < "3.9"
Requires-Dist: click (>=8)
Requires-Dist: decorator (>=5,<6)
Requires-Dist: docstring-parser (>=0.15,<0.16)
Requires-Dist: fabric (>=3,<4)
Requires-Dist: fasteners (>=0.19,<0.20)
Requires-Dist: flask (>=2.3,<3.0)
Requires-Dist: flask-socketio (>=5.3,<6.0)
Requires-Dist: gevent (>=23.9,<24.0)
Requires-Dist: gevent-websocket (>=0.10,<0.11)
Requires-Dist: huggingface-hub (>0.17)
Requires-Dist: humanfriendly (>=10,<11)
Requires-Dist: marshmallow (>=3.20,<4.0)
Requires-Dist: omegaconf (>=2.3,<3.0)
Requires-Dist: psutil (>=5.9.5,<6.0.0)
Requires-Dist: pyparsing (>=3.1,<4.0)
Requires-Dist: pytools (>=2023.1.1,<2024.0.0)
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
Requires-Dist: requests (>=2.31,<3.0)
Requires-Dist: rpyc (>=5,<6)
Requires-Dist: sortedcontainers (>=2.4,<3.0)
Requires-Dist: termcolor (>=2.3)
Requires-Dist: tqdm (>=4.66.1,<5.0.0)
Requires-Dist: typing-extensions (>=4.2) ; python_version < "3.11"
Requires-Dist: watchdog (>=2,<3)
Project-URL: Documentation, https://experimaestro-python.readthedocs.io/
Project-URL: Repository, https://github.com/experimaestro/experimaestro-python
Description-Content-Type: text/markdown

[![PyPI version](https://badge.fury.io/py/experimaestro.svg)](https://badge.fury.io/py/experimaestro)

Experimaestro is a computer science experiment manager whose goals are:

- To decompose experiments into a set of parameterizable tasks
- Schedule tasks and handle dependencies between tasks
- Avoids to re-run the same task two times by computing unique task IDs dependending on the parameters
- Handle experimental parameters through tags

The full documentation can be read by going to the following URL: [https://experimaestro-python.readthedocs.io](https://experimaestro-python.readthedocs.io)

# Install

## With pip

You can then install the package using `pip install experimaestro`

## Develop

Checkout the git directory, then

```
pip install -e .
```

# Example

This very simple example shows how to submit two tasks that concatenate two strings.
Under the curtain,

- A directory is created for each task (in `workdir/jobs/helloworld.add/HASHID`)
  based on a unique ID computed from the parameters
- Two processes for `Say` are launched (there are no dependencies, so they will be run in parallel)
- A tag `y` is created for the main task

<!-- SNIPPET: MAIN ARGS[%WORKDIR% --port 0 --sleeptime=0.0001] -->

```python
# --- Task and types definitions

import logging
logging.basicConfig(level=logging.DEBUG)
from pathlib import Path
from experimaestro import Task, Param, experiment, progress
import click
import time
import os
from typing import List

# --- Just to be able to monitor the tasks

def slowdown(sleeptime: int, N: int):
    logging.info("Sleeping %ds after each step", sleeptime)
    for i in range(N):
        time.sleep(sleeptime)
        progress((i+1)/N)


# --- Define the tasks

class Say(Task):
    word: Param[str]
    sleeptime: Param[float]

    def execute(self):
        slowdown(self.sleeptime, len(self.word))
        print(self.word.upper(),)

class Concat(Task):
    strings: Param[List[Say]]
    sleeptime: Param[float]

    def execute(self):
        says = []
        slowdown(self.sleeptime, len(self.strings))
        for string in self.strings:
            with open(string.__xpm_stdout__) as fp:
                says.append(fp.read().strip())
        print(" ".join(says))


# --- Defines the experiment

@click.option("--port", type=int, default=12345, help="Port for monitoring")
@click.option("--sleeptime", type=float, default=2, help="Sleep time")
@click.argument("workdir", type=Path)
@click.command()
def cli(port, workdir, sleeptime):
    """Runs an experiment"""
    # Sets the working directory and the name of the xp
    with experiment(workdir, "helloworld", port=port) as xp:
        # Submit the tasks
        hello = Say(word="hello", sleeptime=sleeptime).submit()
        world = Say(word="world", sleeptime=sleeptime).submit()

        # Concat will depend on the two first tasks
        Concat(strings=[hello, world], sleeptime=sleeptime).tag("y", 1).submit()


if __name__ == "__main__":
    cli()
```

which can be launched with `python test.py /tmp/helloworld-workdir`

