Skip to content

Commit

Permalink
Update infrastructure to python3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
cc-a committed May 16, 2024
1 parent d32e01b commit 2e0ebe7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
16 changes: 15 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
FROM ghcr.io/imperialcollegelondon/anvil-app-server:latest
FROM python:3.11

RUN wget -O - https://apt.corretto.aws/corretto.key | gpg --dearmor -o /usr/share/keyrings/corretto-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/corretto-keyring.gpg] https://apt.corretto.aws stable main" | tee /etc/apt/sources.list.d/corretto.list

RUN apt-get update && apt-get install -y java-11-amazon-corretto-jdk && rm -rf /var/lib/apt/lists/*

WORKDIR /apps

RUN mkdir /anvil-data

RUN useradd anvil
RUN chown -R anvil:anvil /anvil-data
USER anvil

ENTRYPOINT []

USER root
Expand Down
2 changes: 1 addition & 1 deletion client_code/Main/FiguresPanel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def calculate(self, inputs, start_year, end_year, expert_mode=False):

def build_warnings(self):
self.warnings_panel.clear()
warnings = init_vals["layout"]["Warnings"]["Not required"]
warnings = init_vals["layout"].get("Warnings", {}).get("Not required", [])

for key in warnings:
name, output, plot_type, _ = warnings[key]
Expand Down
27 changes: 15 additions & 12 deletions client_code/Plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,21 @@ def plot_stacked_area(plot, model_solution, output, title, axis_unit):
data = []
total = None
for name, y in _prepare_rows(model_output, x):
if "total" in name.lower():
total = _partial_scatter(
x, y, name, mode="lines", line=dict(width=4, color="black")
)
elif all(val <= 0 for val in y):
data.append(
_partial_scatter(x, y, name=name, mode="lines", stackgroup="two")
)
else:
data.append(
_partial_scatter(x, y, name=name, mode="lines", stackgroup="one")
)
try:
if "total" in name.lower():
total = _partial_scatter(
x, y, name, mode="lines", line=dict(width=4, color="black")
)
elif all(val <= 0 for val in y):
data.append(
_partial_scatter(x, y, name=name, mode="lines", stackgroup="two")
)
else:
data.append(
_partial_scatter(x, y, name=name, mode="lines", stackgroup="one")
)
except TypeError:
pass
if total:
data.append(total)
plot.data = data
Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_spreadsheet.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$ErrorActionPreference = "Stop"
$path = Resolve-Path $args[0]

docker run --pull always --rm -it -v ${path}:/opt/excel_to_code/input.xlsx:ro -v ${pwd}:/opt/excel_to_code/work/ ghcr.io/imperialcollegelondon/calc2050_excel_to_code:main bash ./run.sh
docker run --pull always --rm -it -v ${path}:/opt/excel_to_code/input.xlsx:ro -v ${pwd}:/opt/excel_to_code/work/ ghcr.io/imperialcollegelondon/calc2050_excel_to_code:icl bash ./run.sh
Copy-Item -Path .\model\_interface2050.cpython-39-x86_64-linux-gnu.so -Destination .\server_code\
Copy-Item -Path .\model\interface2050.py -Destination .\server_code\
2 changes: 1 addition & 1 deletion scripts/convert_spreadsheet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spreadsheet=$(realpath "$1")
docker run --pull always --rm -it -u "$(id -u)":"$(id -g)" \
-v "${spreadsheet}":/opt/excel_to_code/input.xlsx:ro \
-v "$(pwd)":/opt/excel_to_code/work/ \
ghcr.io/imperialcollegelondon/calc2050_excel_to_code:main \
ghcr.io/imperialcollegelondon/calc2050_excel_to_code:icl \
bash ./run.sh

cp model/_interface2050.cpython-39-x86_64-linux-gnu.so model/interface2050.py server_code/

0 comments on commit 2e0ebe7

Please sign in to comment.