Skip to content

Commit

Permalink
ci: create docker dev (#583)
Browse files Browse the repository at this point in the history
* ci: Updated dependencies to run just through docker

* ci: Dockerfile now includes external test data

* test: MAde example's paths platform independent

* test: Corrected paths to be relative to the data directory

* ci: Reverted arguments in dockerfile

* test: corrected last failing example path

* test: Skipped redundant test

* test: corrected mark decorator

* ci: Modified dockerfile to include the `make` linux command
  • Loading branch information
Carsopre authored Oct 10, 2024
1 parent 8034e0f commit da70c08
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 15 deletions.
37 changes: 37 additions & 0 deletions .config/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# To build this docker run:
# `docker build -t ra2ce_core_dev`
# To run the docker for pytest:
# `docker run -v {your_ra2ce_checkout_dir}:/usr/src/app/ -v {ra2ce_env_dir}:/usr/src/.env -t ra2ce_core_dev`
# `poetry install`
# `poetry run pytest -m {your_pytest_arguments}`

FROM condaforge/miniforge3:latest

RUN apt-get update && apt-get install libgl1 -y && apt-get install --reinstall make

ARG SRC_ROOT="/usr/src"

# For persisting the environment remember to mount it as well:
# -v {your_local_tmp_dir}:/usr/src/.env
ARG CONDA_ENV="${SRC_ROOT}/.env"

# Install conda environment
# This location needs to be mounted with your vrtool checout:
# -v {your_ra2ce_checkout_dir}:/usr/src/app
WORKDIR $SRC_ROOT/app
COPY environment.yml $SRC_ROOT/.config/environment.yml
COPY ra2ce_test_cases $SRC_ROOT/test_external_data

RUN conda init bash \
&& . ~/.bashrc \
&& conda env create -f $SRC_ROOT/.config/environment.yml -p $CONDA_ENV

# Activate conda environment
ENV PATH $CONDA_ENV/bin:$PATH
RUN conda activate ${CONDA_ENV} & poetry config virtualenvs.create false
RUN echo conda init && echo "conda activate ${CONDA_ENV}" >> ~/.bashrc
# This ensures it's available also for `sh` instead of `bash`.
RUN echo "conda activate ${CONDA_ENV}" > ~/.profile

# Define the endpoint
CMD [ "/bin/bash" ]
3 changes: 2 additions & 1 deletion .config/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ dependencies:
# If this does not work then exclude it from the environment and install it manually
# with: conda install -c conda-forge poetry=1.3.2
- conda-forge::poetry=1.3.2
- conda-forge::pandoc
- conda-forge::pandoc
- conda-forge::teamcity-messages
8 changes: 0 additions & 8 deletions .config/tc_environment.yml

This file was deleted.

2 changes: 1 addition & 1 deletion examples/example_damages_OSdamage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"import numpy as np\n",
"import rasterio\n",
"\n",
"root_dir = Path(\".\\\\data\\\\damages_analysis_OSdamage\")\n",
"root_dir = Path(\"data\", \"damages_analysis_OSdamage\")\n",
"assert root_dir.exists(), \"root_dir not found.\""
]
},
Expand Down
2 changes: 1 addition & 1 deletion examples/example_damages_huizinga.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"import numpy as np\n",
"import rasterio\n",
"\n",
"root_dir = Path(\".\\\\data\\\\damages_analysis_huizinga\")\n",
"root_dir = Path(\"data\", \"damages_analysis_huizinga\")\n",
"assert root_dir.exists(), \"root_dir not found.\""
]
},
Expand Down
2 changes: 1 addition & 1 deletion examples/example_multi_link_losses.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"from ra2ce.ra2ce_handler import Ra2ceHandler\n",
"\n",
"# Import config data\n",
"root_dir_multi = Path(\".\\\\data\\\\multi_link_losses\")\n",
"root_dir_multi = Path(\"data\", \"multi_link_losses\")\n",
"assert root_dir_multi.exists()\n",
"\n",
"# Load network data.\n",
Expand Down
4 changes: 2 additions & 2 deletions examples/example_origin_destination_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"outputs": [],
"source": [
"# specify the path to the folder holding the RA2CE folder and input data\n",
"root_dir = Path (\"data\", \"origin_destination_analysis_without_hazard\")"
"root_dir = Path(\"data\", \"origin_destination_analysis_without_hazard\")"
]
},
{
Expand Down Expand Up @@ -439,7 +439,7 @@
"outputs": [],
"source": [
"# specify the path to the folder holding the RA2CE folder and input data\n",
"root_dir = Path (\".\\\\data\\\\origin_destination_analysis_with_hazard\")"
"root_dir = Path(\"data\", \"origin_destination_analysis_with_hazard\")"
]
},
{
Expand Down
10 changes: 9 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,15 @@ def test_given_invalid_paths_raises_value_error(
@pytest.mark.parametrize(
"case_data_dir",
[
pytest.param("acceptance_test_data", id="Default test data"),
pytest.param(
"acceptance_test_data",
id="Default test data",
marks=[
pytest.mark.skip(
reason="Test superseeded by running all jupyter notebook examples"
)
],
),
]
+ _external_test_cases,
indirect=["case_data_dir"],
Expand Down

0 comments on commit da70c08

Please sign in to comment.