Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(v3.6.0) - Poetry migration #448

Merged
merged 25 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
839646e
Merge_pr.yml workflow: Enable jekyll in github-pages
AlejandroCN7 Sep 20, 2024
269ada7
Common: Delete unusued imports
AlejandroCN7 Sep 20, 2024
cdc0c21
Coverage: Added sinergym register (sinergym/__init__) to omit list
AlejandroCN7 Sep 24, 2024
7141e42
Poetry: Add pyproject.toml and poetry.lock, deleted all deprecated fi…
AlejandroCN7 Sep 24, 2024
e474d40
Dockerfiles: Update with Poetry, separated images for production (exp…
AlejandroCN7 Sep 24, 2024
ed74881
Update Sinergym version from 3.5.11a to 3.6.0
AlejandroCN7 Sep 24, 2024
c0c7120
Devcontainer: Update default extensions in workspace with development…
AlejandroCN7 Sep 24, 2024
4e43b9d
Include pytype in project again and fix
AlejandroCN7 Sep 24, 2024
4d8d74e
Poetry: Delete requirements in pyproject.toml include
AlejandroCN7 Sep 25, 2024
a92c1db
Delete extra packages in Dockerfile (basic installation)
AlejandroCN7 Sep 25, 2024
e92a4b8
Workflows update: Include Poetry installation, setup python uses cach…
AlejandroCN7 Sep 25, 2024
db10a43
Documentation: installation section improved and simpler
AlejandroCN7 Sep 25, 2024
cae95d3
Add DockerHub badge
AlejandroCN7 Sep 25, 2024
1a981d2
Delete cache option in python setup
AlejandroCN7 Sep 25, 2024
8484fb0
Isort fix
AlejandroCN7 Sep 25, 2024
d00292f
Added test to Dockerfile
AlejandroCN7 Sep 25, 2024
5d3108d
Fix documentation sinergym module not found
AlejandroCN7 Sep 25, 2024
9f1c526
Documentation spelling fix
AlejandroCN7 Sep 25, 2024
070c67b
Specific runner in github action
AlejandroCN7 Sep 25, 2024
d447132
pytype fix in callbacks.py
AlejandroCN7 Sep 25, 2024
8578d1f
Fixed pyproject.toml: Deleted extras (doesn't work) and organized all…
AlejandroCN7 Sep 26, 2024
70f3f02
Fix Dockerfiles with new pyproject.toml installation definition
AlejandroCN7 Sep 26, 2024
361bd31
Worflow fix
AlejandroCN7 Sep 26, 2024
e67fc19
Documentation installation section fix
AlejandroCN7 Sep 26, 2024
bac242c
[ci skip] Poetry env enabled in create release workflow
AlejandroCN7 Sep 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
omit = sinergym/utils/gcloud.py,
sinergym/utils/constants.py,
sinergym/utils/env_checker.py,
sinergym/utils/callbacks.py,
sinergym/utils/callbacks.py,
sinergym/__init__.py
106 changes: 67 additions & 39 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,68 @@
# Base on nrel/energyplus from Nicholas Long but using
# Ubuntu, Python 3.10 and BCVTB
# Container for Sinergym development
# ---------------------------------------------------------------------------- #
# BASE IMAGE #
# ---------------------------------------------------------------------------- #

ARG UBUNTU_VERSION=24.04
FROM ubuntu:${UBUNTU_VERSION}

# Arguments for EnergyPlus version (default values of version 8.6.0 if is not specified)
# ---------------------------------------------------------------------------- #
# CONTAINER ARGUMENTS AND ENV CONFIG #
# ---------------------------------------------------------------------------- #

# -------------------------------- ENERGYPLUS -------------------------------- #

# VERSION ARGUMENTS
ARG ENERGYPLUS_VERSION=24.1.0
ARG ENERGYPLUS_INSTALL_VERSION=24-1-0
ARG ENERGYPLUS_SHA=9d7789a3ac

# Argument for Sinergym extras libraries
ARG SINERGYM_EXTRAS=[extras]
#ENV CONFIGURATION
ENV ENERGYPLUS_TAG=v$ENERGYPLUS_VERSION
ENV EPLUS_PATH=/usr/local/EnergyPlus-$ENERGYPLUS_INSTALL_VERSION
# Downloading from Github
# e.g. https://github.com/NREL/EnergyPlus/releases/download/v23.1.0/EnergyPlus-23.1.0-87ed9199d4-Linux-Ubuntu22.04-x86_64.sh
ENV ENERGYPLUS_DOWNLOAD_BASE_URL https://github.com/NREL/EnergyPlus/releases/download/$ENERGYPLUS_TAG
ENV ENERGYPLUS_DOWNLOAD_FILENAME EnergyPlus-$ENERGYPLUS_VERSION-$ENERGYPLUS_SHA-Linux-Ubuntu22.04-x86_64.sh
ENV ENERGYPLUS_DOWNLOAD_URL $ENERGYPLUS_DOWNLOAD_BASE_URL/$ENERGYPLUS_DOWNLOAD_FILENAME
# Python add pyenergyplus path in order to detect API package
ENV PYTHONPATH="/usr/local/EnergyPlus-${ENERGYPLUS_INSTALL_VERSION}"

# ---------------------------------- PYTHON ---------------------------------- #

# Argument for choosing Python version
# VERSION ARGUMENT
ARG PYTHON_VERSION=3.12

# ENV CONFIGURATION
ENV PIP_BREAK_SYSTEM_PACKAGES=1

# WANDB_API_KEY
# ---------------------------------- POETRY ---------------------------------- #

# ENV CONFIGURATION
ENV POETRY_NO_INTERACTION=1
ENV POETRY_VIRTUALENVS_IN_PROJECT=0
ENV POETRY_VIRTUALENVS_CREATE=0
ENV POETRY_CACHE_DIR=/tmp/poetry_cache

# ------------------------- WANDB API KEY (IF EXISTS) ------------------------ #

ARG WANDB_API_KEY
ENV WANDB_API_KEY=${WANDB_API_KEY}

# LC_ALL for python locale error (https://bobbyhadz.com/blog/locale-error-unsupported-locale-setting-in-python)
ENV LC_ALL=C

ENV ENERGYPLUS_VERSION=$ENERGYPLUS_VERSION
ENV ENERGYPLUS_TAG=v$ENERGYPLUS_VERSION
ENV ENERGYPLUS_SHA=$ENERGYPLUS_SHA

# This should be x.y.z, but EnergyPlus convention is x-y-z
ENV ENERGYPLUS_INSTALL_VERSION=$ENERGYPLUS_INSTALL_VERSION
ENV EPLUS_PATH=/usr/local/EnergyPlus-$ENERGYPLUS_INSTALL_VERSION
# ---------------------------------------------------------------------------- #
# INSTALLATION AND CONFIGURATION #
# ---------------------------------------------------------------------------- #

# --------------------- APT UPDATE AND MANDATORY PACKAGES -------------------- #

# Downloading from Github
# e.g. https://github.com/NREL/EnergyPlus/releases/download/v23.1.0/EnergyPlus-23.1.0-87ed9199d4-Linux-Ubuntu22.04-x86_64.sh
ENV ENERGYPLUS_DOWNLOAD_BASE_URL https://github.com/NREL/EnergyPlus/releases/download/$ENERGYPLUS_TAG
ENV ENERGYPLUS_DOWNLOAD_FILENAME EnergyPlus-$ENERGYPLUS_VERSION-$ENERGYPLUS_SHA-Linux-Ubuntu22.04-x86_64.sh
ENV ENERGYPLUS_DOWNLOAD_URL $ENERGYPLUS_DOWNLOAD_BASE_URL/$ENERGYPLUS_DOWNLOAD_FILENAME

# Mandatory apt packages
RUN apt update && apt upgrade -y
RUN apt install -y ca-certificates build-essential curl libx11-6 libexpat1 git wget python3

#Energyplus installation
# -------------------------- ENERGYPLUS INSTALLATION ------------------------- #

RUN curl -SLO $ENERGYPLUS_DOWNLOAD_URL \
&& chmod +x $ENERGYPLUS_DOWNLOAD_FILENAME \
&& echo "y\r" | ./$ENERGYPLUS_DOWNLOAD_FILENAME \
Expand All @@ -51,7 +72,8 @@ RUN curl -SLO $ENERGYPLUS_DOWNLOAD_URL \
# Remove the broken symlinks
&& cd /usr/local/bin find -L . -type l -delete

# Install pip, and make python point to python3
# ------------------------ PYTHON AND PIP CONFIGURTION ----------------------- #

RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& python3 get-pip.py \
&& rm get-pip.py \
Expand All @@ -61,26 +83,32 @@ RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& echo "Y\r" | apt install python3-enchant -y \
&& echo "Y\r" | apt install pandoc -y

# clean files
# ---------------------------- POETRY CONFIGURTION --------------------------- #

# Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
# Add Poetry to PATH
ENV PATH="/root/.local/bin:$PATH"

# -------------------------------- CLEAN FILES ------------------------------- #

RUN apt autoremove -y && apt autoclean -y \
&& rm -rf /var/lib/apt/lists/*


# Python add pyenergyplus path in order to detect API package
ENV PYTHONPATH="/usr/local/EnergyPlus-${ENERGYPLUS_INSTALL_VERSION}"
# ---------------------------------------------------------------------------- #
# WORKDIR AND COPY FILES #
# ---------------------------------------------------------------------------- #

WORKDIR /workspaces/sinergym
COPY requirements.txt /workspaces/sinergym/requirements.txt
COPY MANIFEST.in /workspaces/sinergym/MANIFEST.in
COPY setup.py /workspaces/sinergym/setup.py
COPY scripts /workspaces/sinergym/scripts
COPY sinergym /workspaces/sinergym/sinergym
COPY tests /workspaces/sinergym/tests
COPY examples /workspaces/sinergym/examples
COPY docs/source /workspaces/sinergym/docs/source
COPY .git/ /workspaces/sinergym/.git
RUN pip install -e .${SINERGYM_EXTRAS}

#RUN pip install idna && pip install six
# Only copy basic files for poetry installation
COPY pyproject.toml poetry.lock README.md LICENSE INSTALL.md CODE_OF_CONDUCT.md ./

# ---------------------------------------------------------------------------- #
# SINERGYM PACKAGE INSTALLATION (POETRY) #
# ---------------------------------------------------------------------------- #

RUN poetry install --no-interaction --with dev

# Execute the command
CMD ["/bin/bash"]

25 changes: 16 additions & 9 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@
},
"extensions": [
"adamvoss.vscode-languagetool",
"Cameron.vscode-pytest",
"cameron.vscode-pytest",
"ecmel.vscode-html-css",
"GitHub.vscode-pull-request-github",
"GrapeCity.gc-excelviewer",
"himanoa.Python-autopep8",
"James-Yu.latex-workshop",
"github.copilot",
"github.copilot-chat",
"github.vscode-pull-request-github",
"grapecity.gc-excelviewer",
"himanoa.python-autopep8",
"james-yu.latex-workshop",
"me-dutour-mathieu.vscode-github-actions",
"mechatroner.rainbow-csv",
"mhutchie.git-graph",
"MS-CEINTL.vscode-language-pack-es",
"ms-ceintl.vscode-language-pack-es",
"ms-python.autopep8",
"ms-python.debugpy",
"ms-python.isort",
"ms-python.python",
"ms-python.vscode-pylance",
Expand All @@ -58,19 +62,22 @@
"ms-toolsai.jupyter-renderers",
"ms-toolsai.vscode-jupyter-cell-tags",
"ms-toolsai.vscode-jupyter-slideshow",
"ms-vscode.live-server",
"ms-vscode.makefile-tools",
"nickmillerdev.pytest-fixtures",
"njpwerner.autodocstring",
"poeticandroid.vscode-poetry",
"redhat.vscode-yaml",
"ryanluker.vscode-coverage-gutters",
"shuworks.vscode-table-formatter",
"stackbreak.comment-divider",
"streetsidesoftware.code-spell-checker",
"tamasfe.even-better-toml",
"tht13.rst-vscode",
"trond-snekvik.simple-rst",
"ue.alphabetical-sorter",
"yzhang.markdown-all-in-one",
"ms-vscode.makefile-tools",
"ms-python.autopep8",
"shuworks.vscode-table-formatter"
"zeshuaro.vscode-python-poetry"
]
}
}
Expand Down
96 changes: 64 additions & 32 deletions .github/workflows/create_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,85 +4,117 @@ on: pull_request
# pwd: /home/runner/work/sinergym/sinergym

jobs:
format-check:
runs-on: ubuntu-latest
autopep8-check:
runs-on: ubuntu-24.04
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ vars.PYTHON_VERSION }}

- name: autopep8 check
id: autopep8
uses: peter-evans/autopep8@v2
with:
args: --exit-code --recursive --diff --aggressive --aggressive .

- name: Fail if autopep8 made changes
if: steps.autopep8.outputs.exit-code == 2
run: exit 1

isort-check:
runs-on: ubuntu-24.04
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ vars.PYTHON_VERSION }}

- name: isort check
id: isort-step
# default configuration use --check-only and --diff instead of --in-place options.
uses: isort/isort-action@master
continue-on-error: true
- name: warning format
if: steps.autopep8.outputs.exit-code == 2 || steps.isort-step.outcome != 'success'
run: echo "::warning ::There are some formats error (autopep8 2 level agressive + isort) in pull request. A bot will fix this issue when pull request is merged."
# - name: Comment PR warning
# if: steps.autopep8.outputs.exit-code == 2 || steps.isort-step.outcome != 'success'
# uses: thollander/actions-comment-pull-request@v1
# with:
# message: ':warning: There are some formats error (autopep8 2 level agressive + isort) in pull request. A bot will fix this issue when pull request is merged. See workflow log to see future changes.'
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# type-check:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Setup Python
# uses: actions/setup-python@v5
# with:
# python-version: ${{ vars.PYTHON_VERSION }}
# - name: Install pytype
# run: pip install pytype requests urllib3
# - name: Check pytype
# run: pytype -d import-error sinergym/
continue-on-error: false

type-check:
runs-on: ubuntu-24.04
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ vars.PYTHON_VERSION }}

- name: Install pytype
run: pip install pytype requests urllib3

- name: Check pytype
run: pytype -d import-error sinergym/

documentation-check:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ vars.PYTHON_VERSION }}

- name: Verify documentation update
uses: dorny/paths-filter@v3
id: verify-documentation-update
with:
filters: |
doc:
- 'docs/source/**'

- 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]
poetry install --no-interaction --with doc

- name: Check build docs
if: steps.verify-documentation-update.outputs.doc == 'true'
run: sphinx-build -M html docs/source docs/build
run: poetry run sphinx-build -M html docs/source docs/build

- name: Check sphinx spelling
if: steps.verify-documentation-update.outputs.doc == 'true'
run: sphinx-build -M spelling docs/source docs/build
run: poetry run sphinx-build -M spelling docs/source docs/build

tests:
name: build container and execute pytest
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Build the latest Docker image
run: docker build . --file Dockerfile --build-arg SINERGYM_EXTRAS=[test] --tag pullrequest/sinergym:latest
run: docker build . --file Dockerfile --build-arg SINERGYM_EXTRAS=test --tag pullrequest/sinergym:latest

- name: Execute tests from container
run: docker run -t pullrequest/sinergym:latest /bin/bash -c 'pytest -vv --cov sinergym tests/'
Loading