From 5c8d473c95789cc11a9ec749e71b4ec19b366e6f Mon Sep 17 00:00:00 2001 From: AlejandroCN7 Date: Thu, 19 Sep 2024 13:26:39 +0000 Subject: [PATCH 1/9] gitignore: Deleted docs/compilation folder --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8d3a36e04..355ab7cbd 100644 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,6 @@ start_mlflow_tracking.sh # Source docs _build directory generation using RST preview in Visual Studio Code docs/source/_build/ docs/build/ -docs/compilation/ #dist folder for pypi packages dist/ From e83a9dad83761ede65c82ec1d4dfce0ea00829ca Mon Sep 17 00:00:00 2001 From: AlejandroCN7 Date: Thu, 19 Sep 2024 13:27:23 +0000 Subject: [PATCH 2/9] requirements: delete wandb of requirements and add in extras --- requirements.txt | 1 - setup.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index fb4ec01b5..167a5b97d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,5 +9,4 @@ pandas twine xlsxwriter pipdeptree -wandb tqdm \ No newline at end of file diff --git a/setup.py b/setup.py index d08689a1c..c5b74ccf4 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,7 @@ 'matplotlib', # visualization # DRL with pytorch 'stable-baselines3', + 'wandb', # logging 'pytest', 'pytest-cov', 'pytest-xdist', # Unit test repository From 08919f799788780c8e552178844293526a6d01a6 Mon Sep 17 00:00:00 2001 From: AlejandroCN7 Date: Thu, 19 Sep 2024 13:28:10 +0000 Subject: [PATCH 3/9] Workflows: Add pyenchant in PR and push main actions --- .github/workflows/create_pr.yml | 1 + .github/workflows/merge_pr.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/create_pr.yml b/.github/workflows/create_pr.yml index e797784ca..506db0b32 100644 --- a/.github/workflows/create_pr.yml +++ b/.github/workflows/create_pr.yml @@ -66,6 +66,7 @@ jobs: - name: Install dependencies if: steps.verify-documentation-update.outputs.doc == 'true' run: | + sudo apt install python3-enchant sudo apt install pandoc pip install -e .[doc] - name: Check build docs diff --git a/.github/workflows/merge_pr.yml b/.github/workflows/merge_pr.yml index 6802d05b7..d80aa9157 100644 --- a/.github/workflows/merge_pr.yml +++ b/.github/workflows/merge_pr.yml @@ -64,6 +64,7 @@ jobs: - name: Install dependencies if: steps.verify-documentation-update.outputs.doc == 'true' run: | + sudo apt install python3-enchant sudo apt install pandoc pip install -e .[doc] - name: Build multiversion docs From c74575978c5b0a9bb7fa34767adedbdfd25f9aaf Mon Sep 17 00:00:00 2001 From: AlejandroCN7 Date: Thu, 19 Sep 2024 13:28:29 +0000 Subject: [PATCH 4/9] Sphinx conf fix --- docs/source/conf.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index e12d05095..1eb3d18fb 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -10,23 +10,14 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -import sinergym.utils.logger import os import sys -from unittest.mock import MagicMock sys.path.insert(0, os.path.abspath('../../sinergym')) - -class WandBOutputFormatMock(MagicMock): - pass - - -sinergym.utils.logger.WandBOutputFormat = WandBOutputFormatMock - # -- Project information ----------------------------------------------------- -project = 'sinergym' +project = 'Sinergym' copyright = '2024, J. Jiménez, J. Gómez, M. Molina, A. Manjavacas, A. Campoy' author = 'J. Jiménez, J. Gómez, M.l Molina, A. Manjavacas, A. Campoy' @@ -50,9 +41,13 @@ class WandBOutputFormatMock(MagicMock): 'nbsphinx_link'] autodoc_mock_imports = ['stable_baselines3', + 'wandb', 'gym', 'opyplus', 'gcloud', + 'googleapiclient', + 'oauth2client', + 'google', 'google.cloud', 'pyenergyplus'] @@ -65,7 +60,7 @@ class WandBOutputFormatMock(MagicMock): # VERSIONING configuration # Whitelist pattern for tags (set to None to ignore all tags) -smv_tag_whitelist = r'^.*0$' +smv_tag_whitelist = r'^v\d+\.\d+\.0$' # smv_tag_whitelist = None # Whitelist pattern for branches (set to None to ignore all branches) @@ -76,7 +71,7 @@ class WandBOutputFormatMock(MagicMock): smv_remote_whitelist = None # Pattern for released versions -smv_released_pattern = r'^tags/.+?0$' +smv_released_pattern = r'^tags/v\d+\.\d+\.0$' # Format for versioned output directories inside the build directory smv_outputdir_format = '{ref.name}' @@ -121,7 +116,7 @@ class WandBOutputFormatMock(MagicMock): html_sidebars = {'**': ['globaltoc.html', 'relations.html', 'sourcelink.html', - 'searchbox.html', ]} + 'searchbox.html']} # disable nbsphinx errors to suppres imports checks not working nbsphinx_allow_errors = True From 5d793209e7f843b8e6d1107802405b21ab475e65 Mon Sep 17 00:00:00 2001 From: AlejandroCN7 Date: Thu, 19 Sep 2024 13:28:41 +0000 Subject: [PATCH 5/9] Sphinx modules: Update --- ...inergym.utils.logger.WandBOutputFormat.rst | 25 +++++++++++++++++++ .../pages/modules/sinergym.utils.logger.rst | 1 + 2 files changed, 26 insertions(+) create mode 100644 docs/source/pages/modules/sinergym.utils.logger.WandBOutputFormat.rst diff --git a/docs/source/pages/modules/sinergym.utils.logger.WandBOutputFormat.rst b/docs/source/pages/modules/sinergym.utils.logger.WandBOutputFormat.rst new file mode 100644 index 000000000..44904d29c --- /dev/null +++ b/docs/source/pages/modules/sinergym.utils.logger.WandBOutputFormat.rst @@ -0,0 +1,25 @@ +sinergym.utils.logger.WandBOutputFormat +======================================= + +.. currentmodule:: sinergym.utils.logger + +.. autoclass:: WandBOutputFormat + :members: + :undoc-members: + + + .. automethod:: __init__ + + + .. rubric:: Methods + + .. autosummary:: + + ~WandBOutputFormat.__init__ + ~WandBOutputFormat.write + + + + + + \ No newline at end of file diff --git a/docs/source/pages/modules/sinergym.utils.logger.rst b/docs/source/pages/modules/sinergym.utils.logger.rst index 7807d9ba3..c1b949b92 100644 --- a/docs/source/pages/modules/sinergym.utils.logger.rst +++ b/docs/source/pages/modules/sinergym.utils.logger.rst @@ -24,6 +24,7 @@ SimpleLogger TerminalLogger TqdmLoggingHandler + WandBOutputFormat From df50d36be6adb45782e62d9603325fb1f5f92684 Mon Sep 17 00:00:00 2001 From: AlejandroCN7 Date: Thu, 19 Sep 2024 13:29:36 +0000 Subject: [PATCH 6/9] Logger: Remove deprecated pkg_resources usage and replace by try/except management for WandBOutputFormat class --- sinergym/utils/logger.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sinergym/utils/logger.py b/sinergym/utils/logger.py index 5557d3497..e0df69ad9 100644 --- a/sinergym/utils/logger.py +++ b/sinergym/utils/logger.py @@ -4,18 +4,10 @@ from typing import Any, Dict, List, Tuple, Union import numpy as np -import pkg_resources from tqdm import tqdm from sinergym.utils.constants import LOG_FORMAT -required = {'stable-baselines3', 'wandb'} -installed = {pkg.key for pkg in pkg_resources.working_set} -missing = required - installed -if not missing: - import wandb - from stable_baselines3.common.logger import KVWriter - class CustomFormatter(logging.Formatter): """Custom logger format for terminal messages""" @@ -206,7 +198,9 @@ def reset_data(self) -> None: self.custom_metrics = [] -if not missing: +try: + import wandb + from stable_baselines3.common.logger import KVWriter class WandBOutputFormat(KVWriter): # pragma: no cover """ Dumps key / value pairs onto WandB. This class is based on SB3 used in logger callback @@ -249,3 +243,9 @@ def write( # Log all metrics wandb.log(metrics_to_log) +except ImportError: + class WandBOutputFormat(): + """WandBOutputFormat class for logging in WandB from SB3 logger. + """ + def __init__(self): + print('WandB or SB3 is not installed. Please install it to use WandBOutputFormat.') From 5ac0bbaf963e18b77807ad6bf69e0653b0b4d753 Mon Sep 17 00:00:00 2001 From: AlejandroCN7 Date: Thu, 19 Sep 2024 13:30:02 +0000 Subject: [PATCH 7/9] Update Sinergym version from 3.5.11 to 3.5.11a --- sinergym/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sinergym/version.txt b/sinergym/version.txt index 4ee082552..67b689025 100644 --- a/sinergym/version.txt +++ b/sinergym/version.txt @@ -1 +1 @@ -3.5.11 \ No newline at end of file +3.5.11a \ No newline at end of file From 905befec895378995a2279a152284dd8fd58ff28 Mon Sep 17 00:00:00 2001 From: AlejandroCN7 Date: Thu, 19 Sep 2024 14:01:36 +0000 Subject: [PATCH 8/9] merge_pr.yml: added github pages action --- .github/workflows/merge_pr.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/merge_pr.yml b/.github/workflows/merge_pr.yml index d80aa9157..0b69854d3 100644 --- a/.github/workflows/merge_pr.yml +++ b/.github/workflows/merge_pr.yml @@ -71,13 +71,12 @@ jobs: if: steps.verify-documentation-update.outputs.doc == 'true' run: sphinx-multiversion docs/source docs/compilation - name: Deploy to GitHub Pages - if: steps.verify-documentation-update.outputs.doc == 'true' - run: | - git config --local user.name "GitHub Actions" - git config --local user.email "actions@github.com" - git add docs/compilation - git commit -m "Deploy documentation to GitHub Pages" - git push --force origin `git subtree split --prefix build main`:github-pages + uses: peaceiris/actions-gh-pages@v4 + with: + personal_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/compilation + publish_branch: github-pages + keep_files: false tests: needs: [apply-autopep8] From e99d3cf3404ef0382a331016e8cd265f9ac8f124 Mon Sep 17 00:00:00 2001 From: AlejandroCN7 Date: Thu, 19 Sep 2024 14:06:17 +0000 Subject: [PATCH 9/9] Added wandb in test setup --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index c5b74ccf4..6493943d7 100644 --- a/setup.py +++ b/setup.py @@ -48,6 +48,7 @@ 'pytest', 'pytest-cov', 'pytest-xdist', + 'wandb', ], 'DRL': [ 'stable-baselines3',