From 0d93bb429c8d1ee66a13bd2a484bcfaf4c24173f Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Thu, 26 May 2022 14:00:08 +0000 Subject: [PATCH 01/22] docs: add updates from github release to history --- HISTORY.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 4b3300f0..d303de55 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -11,15 +11,16 @@ History * Support for automatically running multiple samples/trials of same experiment via ``num_samples`` config parameter. * Configs named `.beobench.yml` will be automatically parsed when Beobench is run in directory containing such a config. This allows users to set e.g. wandb API keys without referring to the config in every Beobench command call. * Configs from experiments now specify the Beobench version used. When trying to rerun an experiment this version will be checked, and an error thrown if there is a mismatch between installed and requested version. - * Add improved high-level API for getting started. This uses the CLI arguments ``--method``, ``--gym`` and ``--env``. Example usage: ``beobench run --method ppo --gym sinergym --env Eplus-5Zone-hot-continuous-v1``. + * Add improved high-level API for getting started. This uses the CLI arguments ``--method``, ``--gym`` and ``--env``. Example usage: ``beobench run --method ppo --gym sinergym --env Eplus-5Zone-hot-continuous-v1`` (#55). * Improvements - * Add ``CITATION.cff`` file to citing software easier. + * Add ``CITATION.cff`` file to make citing software easier. * By default, docker builds of experiment images are now skipped if an image with tag corresponding to installed Beobench version already exists. - * Remove outdated guides and add yaml configuration description from docs. + * Remove outdated guides and add yaml configuration description from docs (#38, #76, #78). * Add support for logging multidimensional actions to wandb. * Add support for logging summary metrics on every env reset to wandb. + * Energym config now uses ``name`` argument like other integrations (#34). * Fixes From bef8eac6f73f8660b585761e6e8a28e87f6cfb41 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Mon, 30 May 2022 18:06:57 +0000 Subject: [PATCH 02/22] feat: add loguru logging --- beobench/experiment/config_parser.py | 3 ++- beobench/experiment/containers.py | 26 +++++++++++++------------- beobench/experiment/scheduler.py | 11 +++++++---- beobench/utils.py | 25 ++++++++++++++++++++++--- 4 files changed, 44 insertions(+), 21 deletions(-) diff --git a/beobench/experiment/config_parser.py b/beobench/experiment/config_parser.py index 92672c11..23d4eecc 100644 --- a/beobench/experiment/config_parser.py +++ b/beobench/experiment/config_parser.py @@ -8,6 +8,7 @@ import sys import random import os +from loguru import logger import beobench import beobench.utils @@ -138,7 +139,7 @@ def get_user() -> dict: """ if os.path.isfile(USER_CONFIG_PATH): - print(f"Beobench: recognised user config at '{USER_CONFIG_PATH}'.") + logger.info(f"Recognised user config at '{USER_CONFIG_PATH}'.") user_config = parse(USER_CONFIG_PATH) else: user_config = {} diff --git a/beobench/experiment/containers.py b/beobench/experiment/containers.py index 88d86640..d0723c61 100644 --- a/beobench/experiment/containers.py +++ b/beobench/experiment/containers.py @@ -4,6 +4,7 @@ import subprocess import os import docker +from loguru import logger import beobench from beobench.constants import AVAILABLE_INTEGRATIONS @@ -74,7 +75,7 @@ def build_experiment_container( ) package_build_context = True - print(f"Beobench: recognised integration named {gym_name}.") + logger.info(f"Recognised integration named {gym_name}.") else: # get alphanumeric name from context context_name = "".join(e for e in build_context if e.isalnum()) @@ -88,15 +89,14 @@ def build_experiment_container( # skip build if image already exists. if not force_build and check_image_exists(stage2_image_tag): - print(f"Beobench: existing image found ({stage2_image_tag}). Skipping build.") + logger.info(f"Existing image found ({stage2_image_tag}). Skipping build.") return stage2_image_tag - print( - f"Beobench: image not found ({stage2_image_tag}) or forced", - "rebuild. Building image.", + logger.warning( + f"Image not found ({stage2_image_tag}) or forced rebuild. Building image.", ) - print(f"Building experiment base image `{stage0_image_tag}`...") + logger.info(f"Building experiment base image `{stage0_image_tag}`...") with contextlib.ExitStack() as stack: # if using build context from beobench package, get (potentially temp.) build @@ -114,7 +114,7 @@ def build_experiment_container( build_context, ] env = os.environ.copy() - print("Running command: " + " ".join(stage0_build_args)) + logger.info("Running command: " + " ".join(stage0_build_args)) subprocess.check_call( stage0_build_args, env=env, # this enables accessing dockerfile in subdir @@ -146,7 +146,7 @@ def build_experiment_container( with subprocess.Popen( ["cat", stage1_dockerfile], stdout=subprocess.PIPE ) as proc: - print("Running command: " + " ".join(stage1_build_args)) + logger.info("Running command: " + " ".join(stage1_build_args)) subprocess.check_call( stage1_build_args, stdin=proc.stdout, @@ -191,14 +191,14 @@ def build_experiment_container( with subprocess.Popen( ["cat", stage2_dockerfile], stdout=subprocess.PIPE ) as proc: - print("Running command: " + " ".join(stage2_build_args)) + logger.info("Running command: " + " ".join(stage2_build_args)) subprocess.check_call( stage2_build_args, stdin=proc.stdout, env=env, # this enables accessing dockerfile in subdir ) - print("Experiment gym image build finished.") + logger.info("Experiment gym image build finished.") return stage2_image_tag @@ -213,10 +213,10 @@ def create_docker_network(network_name: str) -> None: network_name (str): name of docker network. """ - print("Creating docker network ...") + logger.info("Creating docker network ...") try: args = ["docker", "network", "create", network_name] subprocess.check_call(args) - print("Docker network created.") + logger.info("Docker network created.") except subprocess.CalledProcessError: - print("No new network created. Network may already exist.") + logger.info("No new network created. Network may already exist.") diff --git a/beobench/experiment/scheduler.py b/beobench/experiment/scheduler.py index c198b0d9..efdc1403 100644 --- a/beobench/experiment/scheduler.py +++ b/beobench/experiment/scheduler.py @@ -10,6 +10,7 @@ import copy import contextlib from typing import Union +from loguru import logger # To enable compatiblity with Python<=3.6 (e.g. for sinergym dockerfile) try: @@ -25,6 +26,8 @@ import beobench.utils from beobench.constants import CONTAINER_DATA_DIR, CONTAINER_RO_DIR, AVAILABLE_AGENTS +beobench.utils.setup_logging() + def run( config: Union[str, dict, pathlib.Path, list] = None, @@ -94,7 +97,7 @@ def run( num_samples (int, optional): number of experiment samples to run. This defaults to a single sample, i.e. just running the experiment once. """ - print("Beobench: starting experiment run ...") + logger.info("Starting experiment run ...") # parsing relevant kwargs and adding them to config kwarg_config = _create_config_from_kwargs( local_dir=local_dir, @@ -134,9 +137,9 @@ def run( for i in range(1, num_samples + 1): # TODO: enable checking whether something is run in container # and do not print the statement below if inside experiment container. - print( + logger.info( ( - f"Beobench: running experiment in container with environment " + f"Running experiment in container with environment " f"{config['env']['name']}" f" and agent from {config['agent']['origin']}. Sample {i} of" f" {num_samples}." @@ -301,7 +304,7 @@ def _build_and_run_in_container(config: dict) -> None: arg_str = " ".join(args) if wandb_api_key: arg_str = arg_str.replace(wandb_api_key, "") - print(f"Executing docker command: {arg_str}") + logger.info(f"Executing docker command: {arg_str}") subprocess.check_call(args) diff --git a/beobench/utils.py b/beobench/utils.py index 0c3f036c..971cb41b 100644 --- a/beobench/utils.py +++ b/beobench/utils.py @@ -1,6 +1,8 @@ """Module with a number of utility functions.""" import docker +from loguru import logger +import sys def check_if_in_notebook() -> bool: @@ -87,17 +89,19 @@ def merge_dicts( def shutdown() -> None: """Shut down all beobench and BOPTEST containers.""" - print("Stopping any remaining beobench and BOPTEST docker containers...") + setup_logging() + + logger.info("Stopping any remaining beobench and BOPTEST docker containers...") client = docker.from_env() container_num = 0 for container in client.containers.list(): if "auto_beobench" in container.name or "auto_boptest" in container.name: - print(f"Stopping container {container.name}") + logger.info(f"Stopping container {container.name}") container.stop(timeout=0) container_num += 1 - print(f"Stopped {container_num} container(s).") + logger.info(f"Stopped {container_num} container(s).") def restart() -> None: @@ -110,3 +114,18 @@ def restart() -> None: """ shutdown() + + +def setup_logging() -> None: + """Setup Beobench loguru logging setup.""" + logger.remove() + logger.add( + sys.stdout, + colorize=True, + format=( + "Beobench " + "⚡️" + "[{time:YYYY-MM-DD, HH:mm:ss.SSSS}] " + "{message}" + ), + ) From 425836432a8938e011b13fdd63d121aaff637430 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Mon, 30 May 2022 18:08:19 +0000 Subject: [PATCH 03/22] aux: add loguru to requirements --- requirements/dev_requirements.txt | 14 ++++---------- requirements/doc_requirements.txt | 5 ++++- setup.py | 1 + 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/requirements/dev_requirements.txt b/requirements/dev_requirements.txt index 13abc6a9..c2fa301b 100644 --- a/requirements/dev_requirements.txt +++ b/requirements/dev_requirements.txt @@ -19,15 +19,9 @@ build # PyPA build tool # Jupyter notebooks jupyterlab -# ML & RL tools -# gym -# torch -# ray[rllib] -# wandb - -# Convex solver tools (OPTIONAL) -# cvxpy - # for rst development (used by vscode) doc8 -rstcheck \ No newline at end of file +rstcheck + +# logging +loguru \ No newline at end of file diff --git a/requirements/doc_requirements.txt b/requirements/doc_requirements.txt index c443cb46..75d4176c 100644 --- a/requirements/doc_requirements.txt +++ b/requirements/doc_requirements.txt @@ -17,4 +17,7 @@ docutils==0.16 Jinja2<3.1 # For allowing type hints -sphinx-autodoc-typehints \ No newline at end of file +sphinx-autodoc-typehints + +# logging +loguru \ No newline at end of file diff --git a/setup.py b/setup.py index aca89ad4..6631efa6 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ "click", "pyyaml", "importlib-resources", # backport of importlib.resources, required for Python<=3.8 + "loguru", ] # The extended requirements are only used inside experiment/gym containers From b5ad18bb05f912d0363fe6e3735f61aeb7a34471 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Mon, 30 May 2022 18:20:03 +0000 Subject: [PATCH 04/22] refactor: move logging utils to logging module --- beobench/experiment/config_parser.py | 2 +- beobench/experiment/scheduler.py | 5 +++-- beobench/logging.py | 19 +++++++++++++++++++ beobench/utils.py | 22 ++++------------------ 4 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 beobench/logging.py diff --git a/beobench/experiment/config_parser.py b/beobench/experiment/config_parser.py index 23d4eecc..4abf844b 100644 --- a/beobench/experiment/config_parser.py +++ b/beobench/experiment/config_parser.py @@ -8,7 +8,7 @@ import sys import random import os -from loguru import logger +from beobench.logging import logger import beobench import beobench.utils diff --git a/beobench/experiment/scheduler.py b/beobench/experiment/scheduler.py index efdc1403..be3403b0 100644 --- a/beobench/experiment/scheduler.py +++ b/beobench/experiment/scheduler.py @@ -10,7 +10,6 @@ import copy import contextlib from typing import Union -from loguru import logger # To enable compatiblity with Python<=3.6 (e.g. for sinergym dockerfile) try: @@ -24,9 +23,11 @@ import beobench.experiment.containers import beobench.experiment.config_parser import beobench.utils +import beobench.logging +from beobench.logging import logger from beobench.constants import CONTAINER_DATA_DIR, CONTAINER_RO_DIR, AVAILABLE_AGENTS -beobench.utils.setup_logging() +beobench.logging.setup() def run( diff --git a/beobench/logging.py b/beobench/logging.py new file mode 100644 index 00000000..8e4ebded --- /dev/null +++ b/beobench/logging.py @@ -0,0 +1,19 @@ +"""Logging utilities for Beobench.""" + +from loguru import logger +import sys + + +def setup() -> None: + """Setup Beobench loguru logging setup.""" + logger.remove() + logger.add( + sys.stdout, + colorize=True, + format=( + "Beobench " + "⚡️" + "[{time:YYYY-MM-DD, HH:mm:ss.SSSS}] " + "{message}" + ), + ) diff --git a/beobench/utils.py b/beobench/utils.py index 971cb41b..033378f6 100644 --- a/beobench/utils.py +++ b/beobench/utils.py @@ -1,8 +1,9 @@ """Module with a number of utility functions.""" import docker -from loguru import logger -import sys + +import beobench.logging +from beobench.logging import logger def check_if_in_notebook() -> bool: @@ -89,7 +90,7 @@ def merge_dicts( def shutdown() -> None: """Shut down all beobench and BOPTEST containers.""" - setup_logging() + beobench.logging.setup() logger.info("Stopping any remaining beobench and BOPTEST docker containers...") @@ -114,18 +115,3 @@ def restart() -> None: """ shutdown() - - -def setup_logging() -> None: - """Setup Beobench loguru logging setup.""" - logger.remove() - logger.add( - sys.stdout, - colorize=True, - format=( - "Beobench " - "⚡️" - "[{time:YYYY-MM-DD, HH:mm:ss.SSSS}] " - "{message}" - ), - ) From 682fdb5363befd1ba63fa2990d65e4daf8f64cda Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Mon, 30 May 2022 18:20:18 +0000 Subject: [PATCH 05/22] docs: add logging feature to history --- HISTORY.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index d303de55..190376bb 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,13 @@ History ======= +0.5.1 (2022-06-00) +------------------ + +* Features: + + * Pretty logging based on loguru package. + 0.5.0 (2022-05-26) ------------------ From 094edce302df8ebe10cb2f53dfce8ebe09cda4c5 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Mon, 30 May 2022 18:56:46 +0000 Subject: [PATCH 06/22] feat: capture output of main run cmd in logger --- beobench/experiment/scheduler.py | 3 ++- beobench/logging.py | 19 +++++++++++++++++-- beobench/utils.py | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/beobench/experiment/scheduler.py b/beobench/experiment/scheduler.py index be3403b0..14b8eb00 100644 --- a/beobench/experiment/scheduler.py +++ b/beobench/experiment/scheduler.py @@ -307,7 +307,8 @@ def _build_and_run_in_container(config: dict) -> None: arg_str = arg_str.replace(wandb_api_key, "") logger.info(f"Executing docker command: {arg_str}") - subprocess.check_call(args) + # subprocess.check_call(args) + beobench.utils.run_command(args, process_name="exp. container") def _create_config_from_kwargs(**kwargs) -> dict: diff --git a/beobench/logging.py b/beobench/logging.py index 8e4ebded..02039a44 100644 --- a/beobench/logging.py +++ b/beobench/logging.py @@ -4,8 +4,12 @@ import sys -def setup() -> None: +def setup(include_time=False) -> None: """Setup Beobench loguru logging setup.""" + if include_time: + time_str = "[{time:YYYY-MM-DD, HH:mm:ss.SSSS}] " + else: + time_str = "" logger.remove() logger.add( sys.stdout, @@ -13,7 +17,18 @@ def setup() -> None: format=( "Beobench " "⚡️" - "[{time:YYYY-MM-DD, HH:mm:ss.SSSS}] " + f"{time_str}" "{message}" ), ) + + +def log_subprocess(pipe, process_name="subprocess"): + """Log subprocess pipe. + + Adapted from from https://stackoverflow.com/a/21978778. + """ + for line in iter(pipe.readline, b""): # b'\n'-separated lines + context = f"\033[34m{process_name}:\033[0m" # .decode("ascii") + line = line.decode("ascii").rstrip() + logger.info(f"{context} {line}") diff --git a/beobench/utils.py b/beobench/utils.py index 033378f6..789a721b 100644 --- a/beobench/utils.py +++ b/beobench/utils.py @@ -1,6 +1,7 @@ """Module with a number of utility functions.""" import docker +import subprocess import beobench.logging from beobench.logging import logger @@ -115,3 +116,19 @@ def restart() -> None: """ shutdown() + + +def run_command(cmd_line_args, process_name): + """Run command and log its output.""" + + process = subprocess.Popen( + cmd_line_args, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + ) + with process.stdout: + beobench.logging.log_subprocess( + process.stdout, + process_name=process_name, + ) + _ = process.wait() # 0 means success From 52f08e5653d3329916f706a30ec4100d3b4171b9 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Mon, 30 May 2022 19:03:35 +0000 Subject: [PATCH 07/22] aux: update beobench format in logger --- beobench/logging.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/beobench/logging.py b/beobench/logging.py index 02039a44..a773099e 100644 --- a/beobench/logging.py +++ b/beobench/logging.py @@ -15,7 +15,7 @@ def setup(include_time=False) -> None: sys.stdout, colorize=True, format=( - "Beobench " + "Beobench " "⚡️" f"{time_str}" "{message}" @@ -27,6 +27,8 @@ def log_subprocess(pipe, process_name="subprocess"): """Log subprocess pipe. Adapted from from https://stackoverflow.com/a/21978778. + + Color setting of context is described in https://stackoverflow.com/a/33206814. """ for line in iter(pipe.readline, b""): # b'\n'-separated lines context = f"\033[34m{process_name}:\033[0m" # .decode("ascii") From 0a1a398b2378e1aaf87712b707ae0ddcba9cd675 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Mon, 30 May 2022 19:06:35 +0000 Subject: [PATCH 08/22] aux: remove boldness from info logging level --- beobench/logging.py | 1 + 1 file changed, 1 insertion(+) diff --git a/beobench/logging.py b/beobench/logging.py index a773099e..67817deb 100644 --- a/beobench/logging.py +++ b/beobench/logging.py @@ -11,6 +11,7 @@ def setup(include_time=False) -> None: else: time_str = "" logger.remove() + logger.level("INFO", color="") logger.add( sys.stdout, colorize=True, From cacf7c59b8e3c1fe33b5c2603f453153843ead8c Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Thu, 23 Jun 2022 13:59:41 +0000 Subject: [PATCH 09/22] exp: add demo yaml --- beobench/data/configs/demo.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 beobench/data/configs/demo.yaml diff --git a/beobench/data/configs/demo.yaml b/beobench/data/configs/demo.yaml new file mode 100644 index 00000000..d3c34da4 --- /dev/null +++ b/beobench/data/configs/demo.yaml @@ -0,0 +1,11 @@ +agent: + origin: random_action + config: + num_steps: 100 +env: + gym: sinergym + config: + name: Eplus-5Zone-hot-continuous-v1 + normalize: True +general: + local_dir: ./beobench_results \ No newline at end of file From f7645cc833bd877cd65da636a3941aeea1259800 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Fri, 24 Jun 2022 14:16:51 +0000 Subject: [PATCH 10/22] Fix: update encoding in subprocess logging --- beobench/logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beobench/logging.py b/beobench/logging.py index 67817deb..9599ea98 100644 --- a/beobench/logging.py +++ b/beobench/logging.py @@ -33,5 +33,5 @@ def log_subprocess(pipe, process_name="subprocess"): """ for line in iter(pipe.readline, b""): # b'\n'-separated lines context = f"\033[34m{process_name}:\033[0m" # .decode("ascii") - line = line.decode("ascii").rstrip() + line = line.decode("utf-8").rstrip() logger.info(f"{context} {line}") From efbf89555d400cc4a1c9a154e412bc73e216838a Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Fri, 24 Jun 2022 14:19:18 +0000 Subject: [PATCH 11/22] fix: make timestep stop config correct in demo yaml --- beobench/data/configs/demo.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beobench/data/configs/demo.yaml b/beobench/data/configs/demo.yaml index d3c34da4..bb72228d 100644 --- a/beobench/data/configs/demo.yaml +++ b/beobench/data/configs/demo.yaml @@ -1,7 +1,8 @@ agent: origin: random_action config: - num_steps: 100 + stop: + timesteps_total: 3 env: gym: sinergym config: From 82305a3d6655d5f22f960e15ee2403c4a046854f Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Fri, 24 Jun 2022 14:21:13 +0000 Subject: [PATCH 12/22] aux: update submodule --- beobench/beobench_contrib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beobench/beobench_contrib b/beobench/beobench_contrib index 172d5622..4fe60bf2 160000 --- a/beobench/beobench_contrib +++ b/beobench/beobench_contrib @@ -1 +1 @@ -Subproject commit 172d5622e17db61cfc3d7c9a9fe5002120b57de6 +Subproject commit 4fe60bf20f0ba9fe0f3a867c6cc19d5599508d23 From 6f92147026fff94d38542fea1d4c875c82596194 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Fri, 24 Jun 2022 14:26:35 +0000 Subject: [PATCH 13/22] aux: update logging in scheduler --- beobench/experiment/scheduler.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/beobench/experiment/scheduler.py b/beobench/experiment/scheduler.py index 14b8eb00..500369a5 100644 --- a/beobench/experiment/scheduler.py +++ b/beobench/experiment/scheduler.py @@ -156,6 +156,8 @@ def run( # Execute experiment # (this is usually reached from inside an experiment container) + logger.info("Running agent script.") + container_ro_dir_abs = CONTAINER_RO_DIR.absolute() args = [ "python", @@ -308,7 +310,7 @@ def _build_and_run_in_container(config: dict) -> None: logger.info(f"Executing docker command: {arg_str}") # subprocess.check_call(args) - beobench.utils.run_command(args, process_name="exp. container") + beobench.utils.run_command(args, process_name="container") def _create_config_from_kwargs(**kwargs) -> dict: From 0ae516606705c05b7ce5c38f0e23902695d1f588 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Fri, 24 Jun 2022 14:27:10 +0000 Subject: [PATCH 14/22] aux: update submodule --- beobench/beobench_contrib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beobench/beobench_contrib b/beobench/beobench_contrib index 4fe60bf2..857092d1 160000 --- a/beobench/beobench_contrib +++ b/beobench/beobench_contrib @@ -1 +1 @@ -Subproject commit 4fe60bf20f0ba9fe0f3a867c6cc19d5599508d23 +Subproject commit 857092d14eb6950f016fac2f746e97a0a5e578e1 From e26593542282c6f32c1b8b26446bb5229ed82b44 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Sat, 25 Jun 2022 16:51:52 +0000 Subject: [PATCH 15/22] aux: enable wrapper in config without it's own config --- beobench/experiment/provider.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/beobench/experiment/provider.py b/beobench/experiment/provider.py index c69f786e..a938b06c 100644 --- a/beobench/experiment/provider.py +++ b/beobench/experiment/provider.py @@ -39,7 +39,11 @@ def create_env(env_config: dict = None) -> object: for wrapper_dict in config["wrappers"]: wrapper = _get_wrapper(wrapper_dict) - env = wrapper(env, **wrapper_dict["config"]) + if "config" in wrapper_dict.keys(): + wrapper_config = wrapper_dict["config"] + else: + wrapper_config = {} + env = wrapper(env, **wrapper_config) return env From 560618dff4b17fcc6d212a5631c97c3e4fed2681 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Sat, 25 Jun 2022 16:52:29 +0000 Subject: [PATCH 16/22] exp: update demo --- beobench/data/configs/demo.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/beobench/data/configs/demo.yaml b/beobench/data/configs/demo.yaml index bb72228d..17933831 100644 --- a/beobench/data/configs/demo.yaml +++ b/beobench/data/configs/demo.yaml @@ -8,5 +8,8 @@ env: config: name: Eplus-5Zone-hot-continuous-v1 normalize: True +wrappers: + - origin: general + class: WandbLogger general: local_dir: ./beobench_results \ No newline at end of file From 198d5bf3bf0f95a031c632198cfabb1f85090621 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Sun, 26 Jun 2022 11:26:41 +0000 Subject: [PATCH 17/22] exp: update demo config --- beobench/data/configs/demo.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/beobench/data/configs/demo.yaml b/beobench/data/configs/demo.yaml index 17933831..3d396cb1 100644 --- a/beobench/data/configs/demo.yaml +++ b/beobench/data/configs/demo.yaml @@ -2,14 +2,11 @@ agent: origin: random_action config: stop: - timesteps_total: 3 + timesteps_total: 10 env: gym: sinergym config: name: Eplus-5Zone-hot-continuous-v1 - normalize: True wrappers: - origin: general - class: WandbLogger -general: - local_dir: ./beobench_results \ No newline at end of file + class: WandbLogger \ No newline at end of file From 8b4e0a1fc8f648519831de950c360fb5a6380266 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Sun, 26 Jun 2022 11:52:22 +0000 Subject: [PATCH 18/22] exp: add wandb details to demo --- beobench/data/configs/demo.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/beobench/data/configs/demo.yaml b/beobench/data/configs/demo.yaml index 3d396cb1..f6676a92 100644 --- a/beobench/data/configs/demo.yaml +++ b/beobench/data/configs/demo.yaml @@ -9,4 +9,8 @@ env: name: Eplus-5Zone-hot-continuous-v1 wrappers: - origin: general - class: WandbLogger \ No newline at end of file + class: WandbLogger +general: + wandb_entity: beobench + wandb_project: demo + # wandb_api_key: HIDDEN \ No newline at end of file From 2c83d00e3e714827c32e37193e978db676665297 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Tue, 28 Jun 2022 16:32:41 +0000 Subject: [PATCH 19/22] aux: update history to include all major changes --- HISTORY.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 190376bb..6774585e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,12 +2,21 @@ History ======= -0.5.1 (2022-06-00) +0.5.1 (2022-06-28) ------------------ * Features: - * Pretty logging based on loguru package. + * Add pretty logging based on loguru package. Now all Beobench output is clearly marked as such. + +* Improvements + + * Enable adding wrapper without setting config. + * Add ``demo.yaml`` simple example config. + +* Fixes + + * Update Sinergym integration to latest Sinergym version. 0.5.0 (2022-05-26) ------------------ From 786d416b051b33487f9e9120cae9f9df137a73e2 Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Tue, 28 Jun 2022 16:38:37 +0000 Subject: [PATCH 20/22] =?UTF-8?q?Bump=20version:=200.5.0=20=E2=86=92=200.5?= =?UTF-8?q?.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CITATION.cff | 2 +- beobench/__init__.py | 2 +- beobench/data/configs/default.yaml | 2 +- setup.cfg | 2 +- setup.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 6b0cdf09..4ee17472 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -9,7 +9,7 @@ message: >- If you use this software, please cite it using the metadata from this file. type: software -version: 0.5.0 +version: 0.5.1 url: https://github.com/rdnfn/beobench authors: - given-names: Arduin diff --git a/beobench/__init__.py b/beobench/__init__.py index 07ea095f..8008eba6 100644 --- a/beobench/__init__.py +++ b/beobench/__init__.py @@ -2,7 +2,7 @@ __author__ = """Beobench authors""" __email__ = "-" -__version__ = "0.5.0" +__version__ = "0.5.1" from beobench.utils import restart from beobench.experiment.scheduler import run diff --git a/beobench/data/configs/default.yaml b/beobench/data/configs/default.yaml index 30aab120..5d0677e9 100644 --- a/beobench/data/configs/default.yaml +++ b/beobench/data/configs/default.yaml @@ -109,4 +109,4 @@ general: # experiment once. num_samples: 1 # Beobench version - version: 0.5.0 + version: 0.5.1 diff --git a/setup.cfg b/setup.cfg index e3abeb36..85aec9ae 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.5.0 +current_version = 0.5.1 commit = True tag = True diff --git a/setup.py b/setup.py index 6631efa6..f6b49640 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ with open("HISTORY.rst", encoding="UTF-8") as history_file: history = history_file.read() -version = "0.5.0" # pylint: disable=invalid-name +version = "0.5.1" # pylint: disable=invalid-name requirements = [ "docker", From ff3024665a1f9882ab5f20a457704ecd9f9c49ca Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Tue, 28 Jun 2022 17:04:51 +0000 Subject: [PATCH 21/22] aux: update pylintrc to new pylint version --- pylintrc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pylintrc b/pylintrc index 2de9082d..d3a1c93a 100644 --- a/pylintrc +++ b/pylintrc @@ -155,12 +155,6 @@ disable=abstract-method, # mypackage.mymodule.MyReporterClass. output-format=text -# Put messages in a separate file for each module / package specified on the -# command line instead of printing them on stdout. Reports (if any) will be -# written in a file name "pylint_global.[txt|html]". This option is deprecated -# and it will be removed in Pylint 2.0. -files-output=no - # Tells whether to display a full report or only the messages reports=no @@ -283,7 +277,7 @@ single-line-if-stmt=yes # separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. # `trailing-comma` allows a space between comma and closing bracket: (a, ). # `empty-line` allows space-only lines. -no-space-check= +# no-space-check= # Maximum number of lines in a module max-module-lines=99999 From 7efe3e6270489a2b1c3ffcff834f90b8c56271cb Mon Sep 17 00:00:00 2001 From: rdnfn <75615911+rdnfn@users.noreply.github.com> Date: Tue, 28 Jun 2022 17:05:12 +0000 Subject: [PATCH 22/22] aux: update pylint config --- beobench/utils.py | 2 +- beobench/wrappers/energym.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/beobench/utils.py b/beobench/utils.py index 789a721b..72623a7e 100644 --- a/beobench/utils.py +++ b/beobench/utils.py @@ -121,7 +121,7 @@ def restart() -> None: def run_command(cmd_line_args, process_name): """Run command and log its output.""" - process = subprocess.Popen( + process = subprocess.Popen( # pylint: disable=consider-using-with cmd_line_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, diff --git a/beobench/wrappers/energym.py b/beobench/wrappers/energym.py index 5cf6ca41..e718319c 100644 --- a/beobench/wrappers/energym.py +++ b/beobench/wrappers/energym.py @@ -26,7 +26,7 @@ def __init__(self, env: gym.Env, info_obs_weights: dict): def step(self, action): obs, _, done, info = self.env.step(action) - reward = sum( + reward = sum( # pylint: disable=consider-using-generator [info["obs"][key] * value for key, value in self.info_obs_weights.items()] ) return obs, reward, done, info