Skip to content

Commit

Permalink
add multiplatform building to publish step
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed Jul 24, 2024
1 parent 0797a71 commit e050199
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,20 @@ jobs:
uses: actions/checkout@v4

- name: Log into container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
id: meta
with:
images: |
Expand All @@ -291,6 +294,7 @@ jobs:
web.cache-to=type=gha,mode=max,scope=web:${{ github.ref_name }}
worker.cache-to=type=gha,mode=max,scope=worker:${{ github.ref_name }}
grafana.cache-to=type=gha,mode=max,scope=grafana:${{ github.ref_name }}
*.platform=linux/amd64,linux/arm64
load: true

- name: Tag and push images
Expand Down
18 changes: 6 additions & 12 deletions alfalfa_worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/nrel/alfalfa-dependencies:3.0.0 AS base
FROM ghcr.io/nrel/alfalfa-dependencies:multiplatform AS base

USER root

Expand All @@ -11,7 +11,8 @@ ENV DEBIAN_FRONTEND noninteractive

# Install poetry
RUN pip3 install poetry==1.8.3
RUN poetry config virtualenvs.options.system-site-packages true
RUN poetry config virtualenvs.options.system-site-packages true \
&& poetry config virtualenvs.create false

# Copy and install poetry-based dependencies
COPY pyproject.toml /alfalfa
Expand All @@ -25,19 +26,12 @@ ENV PYTHONPATH="/alfalfa:${PYTHONPATH}"

COPY ./alfalfa_worker /alfalfa/alfalfa_worker

RUN pip3.8 install virtualenv \
&& pip3.8 install -r /alfalfa/alfalfa_worker/energyplus_requirements.txt

COPY ./deploy /alfalfa/deploy
COPY ./deploy/wait-for-it.sh /usr/local/wait-for-it.sh

# update the path to python, which is in the Poetry virtual environment.
# The path (mfknN3Ol) is generated by Poetry and should be updated if the
# install path changes.
#
# The dependency warning still exists, but it is a warning. Eventually this
# will be resolved when we move to a newer version of Ubuntu.
# See https://bugs.launchpad.net/ubuntu/+source/python-debian/+bug/1926870
# Error: RequestsDependencyWarning: urllib3 (1.26.13) or chardet (3.0.4) doesn't match a supported version!
# warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported
ENV PATH=$HOME/.cache/pypoetry/virtualenvs/alfalfa-mfknN3Ol-py3.8/bin:$PATH
WORKDIR $HOME/alfalfa_worker


Expand Down
2 changes: 2 additions & 0 deletions alfalfa_worker/energyplus_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scipy
symfit
2 changes: 1 addition & 1 deletion alfalfa_worker/jobs/openstudio/create_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def exec(self):
# If there are requirements.txt files in the model create a python virtual environment and install packaged there
requirements = self.run.glob("**/requirements.txt")
if len(requirements) > 0:
check_output(["python", "-m", "venv", "--system-site-packages", "--symlinks", str(self.dir / '.venv')])
check_output(["python3.8", "-m", "venv", "--system-site-packages", "--symlinks", str(self.dir / '.venv')])
for requirements_file in requirements:
check_output([str(self.dir / '.venv' / 'bin' / 'pip'), "install", "-r", str(requirements_file)])

Expand Down
4 changes: 2 additions & 2 deletions alfalfa_worker/lib/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import numpy as np
from pyfmi import load_fmu
from scipy.integrate import trapz
from scipy.integrate import trapezoid

from alfalfa_worker.lib.data.data_manager import Data_Manager

Expand Down Expand Up @@ -289,7 +289,7 @@ def get_kpis(self) -> dict:
data = np.array(self.y_store[signal])
dT_heating = heat_setpoint - data
dT_heating[dT_heating < 0] = 0
tot_dis = tot_dis + trapz(dT_heating, self.y_store['time']) / 3600
tot_dis = tot_dis + trapezoid(dT_heating, self.y_store['time']) / 3600
# Store result in dictionary
kpis['comfort'] = tot_dis
else:
Expand Down

0 comments on commit e050199

Please sign in to comment.