Skip to content

Commit

Permalink
Refactor Orchestrator class in core.py to randomize treatment order
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanxiao committed May 2, 2024
1 parent 2c7eb0a commit 795b721
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Midori is a plugin-based orchestrator that allows researchers to run software en

### Usage

Initialize the orchestrator with the following parameters and run:
Initialize the orchestrator with the following [parameters](#parameters) and run:

```python
from midori.core import Orchestrator
Expand All @@ -48,9 +48,21 @@ orchestrator = Orchestrator(
orchestrator.run()
```

### Remote Node and Experiment Subject Setup

The `subject_path` is a directory on the remote node. As mentioned in the next section, `variables` represent the variables to be manipulated in the experiment, which should be reflected in the `subject_path`. `subject_path` should be a git repository that contains branches named of the combinations of the `variables`.

For example, if `variable` is

```python
variables = {'drink': ['orange', 'apple', 'watermelon'], 'size': [300, 600, 100], 'temperature': [20, 30]}
```

The `subject_path` should be a git repository that contains branches named `orange-300-20`, `orange-300-30`, `orange-600-20`, `orange-600-30`, etc. You do not have to include all the combinations, Midori will skip the missing branches.

### Parameters

- `hostname`, `username`, `password`: Mitori needs these parameters to connect to the remote cluster via SSH.
- `hostname`, `username`, `password`: Mitori needs these parameters to connect to the remote node via SSH.
- `repetitions`: The number of repetitions for the experiment.
- `before_trial_cooling_time`: The cooling time before each trial, in seconds.
- `trial_timespan`: The time span of each trial, in seconds.
Expand Down
4 changes: 3 additions & 1 deletion midori/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import paramiko
import random
from typing import List, Dict, Type
from .plugins.helpers import PluginHelper
from .treatments_helper import get_treatments
Expand Down Expand Up @@ -68,7 +69,8 @@ def run(self) -> None:
for i in range(self.__repetitions):
print(f"Repetition {i+1}")

for treatment in self.treatments:
randomized_treatments = random.sample(self.treatments, len(self.treatments))
for treatment in randomized_treatments:
if not is_a_branch_exist(
branch=treatment, subject_path=self.__subject_path, ssh=self.__ssh
):
Expand Down

0 comments on commit 795b721

Please sign in to comment.