summaryrefslogtreecommitdiff
path: root/src/training/prepare_experiments.py
diff options
context:
space:
mode:
authoraktersnurra <gustaf.rydholm@gmail.com>2020-07-05 22:27:08 +0200
committeraktersnurra <gustaf.rydholm@gmail.com>2020-07-05 22:27:08 +0200
commit5a78fc2e33c28968a69d033cb10d638f4f63fed1 (patch)
treee11cea8366c848e5500f85968ee5369ff8d96b00 /src/training/prepare_experiments.py
parent7c4de6d88664d2ea1b084f316a11896dde3e1150 (diff)
Working on getting experiment loop.
Diffstat (limited to 'src/training/prepare_experiments.py')
-rw-r--r--src/training/prepare_experiments.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/training/prepare_experiments.py b/src/training/prepare_experiments.py
new file mode 100644
index 0000000..1ab8f00
--- /dev/null
+++ b/src/training/prepare_experiments.py
@@ -0,0 +1,35 @@
+"""Run a experiment from a config file."""
+import json
+
+import click
+from loguru import logger
+import yaml
+
+
+def run_experiment(experiment_filename: str) -> None:
+ """Run experiment from file."""
+ with open(experiment_filename) as f:
+ experiments_config = yaml.safe_load(f)
+ num_experiments = len(experiments_config["experiments"])
+ for index in range(num_experiments):
+ experiment_config = experiments_config["experiments"][index]
+ experiment_config["experiment_group"] = experiments_config["experiment_group"]
+ print(
+ f"python training/run_experiment.py --gpu=-1 '{json.dumps(experiment_config)}'"
+ )
+
+
+@click.command()
+@click.option(
+ "--experiments_filename",
+ required=True,
+ type=str,
+ help="Filename of Yaml file of experiments to run.",
+)
+def main(experiment_filename: str) -> None:
+ """Parse command-line arguments and run experiments from provided file."""
+ run_experiment(experiment_filename)
+
+
+if __name__ == "__main__":
+ main()