diff --git a/docs/services.md b/docs/services.md new file mode 100644 index 0000000..a41e61b --- /dev/null +++ b/docs/services.md @@ -0,0 +1,67 @@ +# Services + +Services can be used to add some useful functionalities when running experiments. For instance, +below is an example of tensorboard service + +```python +class TensorboardService(WebService): + id = "tensorboard" + + def __init__(self, path: Path): + super().__init__() + + self.path = path + cleanupdir(self.path) + self.path.mkdir(exist_ok=True, parents=True) + logging.info("You can monitor learning with:") + logging.info("tensorboard --logdir=%s", self.path) + self.url = None + + def add(self, config: Config, path: Path): + (self.path / tagspath(config)).symlink_to(path) + + def description(self): + return "Tensorboard service" + + def close(self): + if self.server: + self.state = ServiceState.STOPPING + self.server.shutdown() + self.state = ServiceState.STOPPED + + def _serve(self, running: threading.Event): + import tensorboard as tb + + try: + self.state = ServiceState.STARTING + self.program = tb.program.TensorBoard() + self.program.configure( + host="localhost", + logdir=str(self.path.absolute()), + path_prefix=f"/services/{self.id}", + port=0, + ) + self.server = self.program._make_server() + + self.url = self.server.get_url() + running.set() + self.state = ServiceState.RUNNING + self.server.serve_forever() + except Exception: + logging.exception("Error while starting tensorboard") + running.set() +``` + +Within an experiment, this can be used as follows: + +```python +# Creates the tensorboard service +tb = xp.add_service(TensorboardService(xp.workdir / "runs")) + +learner = Learner() +learner.submit() + +# This will allow to monitor the run through tensorboard +# (in the web interface) +tb.add(learner, learner.logpath) +``` diff --git a/docs/settings.md b/docs/settings.md new file mode 100644 index 0000000..b285a99 --- /dev/null +++ b/docs/settings.md @@ -0,0 +1,27 @@ +# Configuration + +## Settings file + +Default settings can be stored in the `$HOME/.config/experimaestro/settings.yaml file`. +All the settings are optional + +```yaml + +# Experiment server settings +server: + port: 12345 + token: 2134inmd8132323 + host: 192.168.1.1 + +# Environment variables for experimental tasks +env: + JAVA_HOME: /path/to/java + +workspaces: + # First workspace is the default + - id: neuralir + path: ~/experiments/xpmir + # Specific environment for this workspace + env: + VARNAME: VALUE +```