# Reuse past runs and configurations The snippets on this page start from a `manager` (see {doc}`getting_started`): ```python import os from avatars.manager import Manager manager = Manager(api_key=os.environ["AVATAR_API_KEY"]) ``` ## How to view my last jobs Jobs are listed by creation date, with their identifier, creation date and status. ```python manager.get_last_jobs(count=10) # the last 10 jobs manager.get_jobs_by_name("wbcd_tuning") # all the jobs of a run name manager.get_last_results(count=10) # a summary of the last 10 results ``` You can also see your last jobs and results in the [web application](https://www.octopize.app). ## How to reload results from a previous run Use `create_runner_from_name` with the name you gave to the run. This works for runs launched from Python and from the [web application](https://www.octopize.app). ```python runner = manager.create_runner_from_name("wbcd_tuning") df = runner.shuffled("wbcd") metrics = runner.privacy_metrics("wbcd") ``` If several runs have the same name, the most recent one is used. To choose another one, list them with `find_ids_by_name` and load one by its identifier with `create_runner_from_id`: ```python results = manager.find_ids_by_name("wbcd_tuning") for set_name_id, jobs in results: print(set_name_id, [job.kind for job in jobs]) runner = manager.create_runner_from_id(results[0][0]) ``` The identifier of a run is also in `runner.set_name` after `run()`. ### Run again from a loaded runner A loaded runner is first a way to **access existing results**. When you call `run()` on it, a new run starts, and a warning gives the identifier of the previous run so that you can still reload it: ```python runner = manager.create_runner_from_name("wbcd_tuning") runner.update_parameters("wbcd", k=20) runner.run(ignore_warnings=True) # If the data expired on the server, upload it again first: # runner.upload_file("wbcd", "fixtures/wbcd.csv") ``` ## How to export a configuration as YAML The YAML file holds the whole configuration of a run: tables, schema, parameters, metrics, report and PIA context. It does not hold the data. Use it to version a configuration or to share it. ```python runner.get_yaml("wbcd_tuning.yaml") # writes the file and returns the YAML text ``` **In the web app:** run step → **Configuration and execution script → Generated configuration → Download YAML configuration**. ## How to launch a job from a YAML file Load a YAML file exported from Python or downloaded from the web application, upload the data of each table, and run: ```python runner = manager.create_runner_from_yaml("fixtures/yaml_from_web.yaml", set_name="iris_from_yaml") runner.upload_file("iris", "fixtures/iris.csv") # the data is not in the YAML runner.jobs.config = runner.config # needed with client 1.30.0 and earlier, see the warning runner.run() ``` `create_runner_from_yaml` adds a version suffix to the name of the run (`iris_from_yaml-v1`). You can also load a YAML file in an existing runner with `runner.from_yaml("path/to/config.yaml")`. :::{warning} With client 1.30.0 and earlier, `run()` on a runner loaded from a YAML file raises `ValueError: Expected k or epsilon to be set`, because the jobs still use the configuration from before the YAML was loaded. Add `runner.jobs.config = runner.config` after `create_runner_from_yaml` or `from_yaml`, as in the snippet above. ::: :::{warning} `upload_file` names the file `