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

Configurable servers #485

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
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
10 changes: 3 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,21 @@ WORKDIR /code

# Create conda environment
COPY environment.yml .
RUN mamba env create -n raven -f environment.yml && mamba install -n raven gunicorn && mamba clean --all --yes
RUN mamba env create -n raven -f environment.yml && mamba install -n raven gunicorn && mamba clean --all --yes

# Add the raven conda environment to the path
ENV PATH=/opt/conda/envs/raven/bin:$PATH

# Set bind address and port from env variable of parent system
ENV RAVEN_BIND_ADDRESS=${RAVEN_BIND_ADDRESS:-0.0.0.0}
ENV RAVEN_BIND_PORT=${RAVEN_BIND_PORT:-9099}

# Copy raven source code
COPY . /code

# Install raven
RUN pip install . --no-deps

# Start WPS service on port 9099
EXPOSE $RAVEN_BIND_PORT
EXPOSE 9099

CMD ["gunicorn", "--bind=$RAVEN_BIND_ADDRESS:$RAVEN_BIND_PORT", "raven.wsgi:application"]
CMD ["gunicorn", "--bind=0.0.0.0:9099", "raven.wsgi:application"]
#CMD ["exec raven-wps start -b '0.0.0.0' -c etc/demo.cfg"]

# docker build -t pavics/raven .
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3'
Zeitsperre marked this conversation as resolved.
Show resolved Hide resolved
services:
# To periodically refresh deps or have weird error: `docker-compose build --no-cache wps`
# `docker-compose run wps`
Expand Down Expand Up @@ -28,4 +27,4 @@ services:
- ./:/opt/wps
environment:
- RAVENPY_TESTDATA_PATH=/testdata
command: bash -c "source activate wps && pytest -x"
command: bash -c "python -m pip install pytest && pytest -x"
77 changes: 42 additions & 35 deletions docs/source/dev_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@ Developer Guide

.. WARNING:: To create new processes, look at examples in Emu_.


Re-create a fresh environment
-----------------------------

.. code-block:: console

make stop # in case you previously did 'make start'
conda deactivate # exit the current 'raven' conda env so we can destroy it
conda env remove -n raven # destroy the current conda env to recreate one from scratch
conda env create -f environment.yml
conda activate raven
make develop # install raven-wps and additional dev tools
.. code-block:: shell

make stop # in case you previously did 'make start'
conda deactivate # exit the current 'raven' conda env so we can destroy it
conda env remove -n raven # destroy the current conda env to recreate one from scratch
conda env create -f environment.yml
conda activate raven
make develop # install raven-wps and additional dev tools

Building the docs
-----------------
Expand All @@ -47,12 +45,16 @@ Run tests using pytest_.

First activate the ``raven`` Conda environment and install ``pytest``.

.. code-block:: console
.. code-block:: console

$ source activate raven
$ pip install -r requirements_dev.txt # if not already installed
OR
$ make develop
source activate raven
pip install -r requirements_dev.txt # if not already installed
Zeitsperre marked this conversation as resolved.
Show resolved Hide resolved

Or, alternatively:

.. code-block:: console

make develop

Run quick tests (skip slow and online):

Expand Down Expand Up @@ -87,7 +89,7 @@ Do the same as above using the ``Makefile``.
Running notebooks tests
-----------------------

Assuming that the ``raven`` conda env has already been created and is up-to-date and `raven-wps`` has been installed with ``make develop``::
Assuming that the ``raven`` conda env has already been created and is up-to-date and raven-wps has been installed with ``make develop``:

.. code-block:: console

Expand All @@ -97,27 +99,28 @@ Assuming that the ``raven`` conda env has already been created and is up-to-date
# to test all notebooks
make test-notebooks

Or:
Or, alternatively:

The notebooks may also require other WPS services (``Finch``). By default these are from the production server but we can point the notebooks to local servers if needed for development purposes::
.. code-block:: console

# to test all notebooks
$ make FINCH_WPS_URL=http://localhost:5000 test-notebooks
# to test a single notebook (note the .run at the end of the notebook path)
make docs/source/notebooks/Subset_climate_data_over_watershed.ipynb.run


# to test a single notebook (note the .run at the end of the notebook path)
$ make FINCH_WPS_URL=http://localhost:5000 docs/source/notebooks/Subset_climate_data_over_watershed.ipynb.run
The notebooks may also require other WPS services (`finch`).
By default these are from the production server but we can point the notebooks to local servers if needed for development purposes:

If instead we want to run the notebooks against the production raven-wps server or any other raven-wps servers::
.. code-block:: console

# to test all notebooks
make FLYINGPIGEON_WPS_URL=http://localhost:8093 FINCH_WPS_URL=http://localhost:5000 test-notebooks
make FINCH_WPS_URL=http://localhost:5000 test-notebooks

Or:
Or, alternatively:

.. code-block:: console

We can also override all three of the server variables (``WPS_URL``, ``FINCH_WPS_URL``) to pick and choose any servers/services from anywhere we want.
# to test a single notebook (note the .run at the end of the notebook path)
make FINCH_WPS_URL=http://localhost:5000 docs/source/notebooks/Subset_climate_data_over_watershed.ipynb.run

If instead we want to run the notebooks against the production raven-wps server or any other raven-wps servers:

Expand All @@ -126,19 +129,21 @@ If instead we want to run the notebooks against the production raven-wps server
# to test all notebooks
make WPS_URL=https://pavics.ouranos.ca/twitcher/ows/proxy/raven/wps test-notebooks

Or:
Or, alternatively:

.. code-block:: console

# to test a single notebook (note the .run at the end of the notebook path)
make WPS_URL=https://pavics.ouranos.ca/twitcher/ows/proxy/raven/wps docs/source/notebooks/Subset_climate_data_over_watershed.ipynb.run

We can also override all three of the server variables (WPS_URL, FINCH_WPS_URL, FLYINGPIGEON_WPS_URL) to pick and choose any servers/services from anywhere we want.
We can also override all three of the server variables (``WPS_URL``, ``FINCH_WPS_URL``) to pick and choose any servers/services from anywhere we want.

Starting local Jupyter server to edit/develop notebooks
-------------------------------------------------------

Assuming that the ``raven`` conda env has already been created and is up-to-date and ``raven-wps`` has been installed with ``make develop``::
Assuming that the ``raven`` conda env has already been created and is up-to-date and raven-wps has been installed with ``make develop``:

.. code-block:: console

# start local raven-wps server to test against
make start # remember to make stop once done
Expand All @@ -153,13 +158,12 @@ Assuming that the ``raven`` conda env has already been created and is up-to-date
# override them one by one in each notebook as each notebook will also look
# for those variables as environment variables.


Bulk refresh all notebooks output
---------------------------------

This automated refresh only works for notebooks that passed ``make test-notebooks`` above. For those that failed, manually starting a local Jupyter server and refresh them manually.

Assuming that the ``raven`` conda env has already been created and is up-to-date and ``raven-wps`` has been installed with ``make develop``::
Assuming that the ``raven`` conda env has already been created and is up-to-date and raven-wps has been installed with ``make develop``:

.. code-block:: console

Expand All @@ -169,11 +173,15 @@ Assuming that the ``raven`` conda env has already been created and is up-to-date
# to refresh all notebooks
make refresh-notebooks

Or:
Or, alternatively:

.. code-block:: console

# Can also override the server variables (WPS_URL, FINCH_WPS_URL) here as well,
# just like 'make test-notebooks' to be able to pick and choose any servers/services from anywhere we want.
# to refresh a single notebook (note the .refresh at the end of the notebook path)
make docs/source/notebooks/Assess_probabilistic_flood_risk.ipynb.refresh

# Can also override the server variables (WPS_URL, FINCH_WPS_URL) here as well,
# just like 'make test-notebooks' to be able to pick and choose any servers/services from anywhere we want.

Prepare a release
-----------------
Expand All @@ -182,7 +190,7 @@ Update the Conda specification file to build identical environments_ on a specif

.. note:: You should run this on your target OS, in our case Linux.

.. code-block:: console
.. code-block:: shell

conda env create -f environment.yml
source activate raven
Expand All @@ -192,7 +200,6 @@ Update the Conda specification file to build identical environments_ on a specif

.. _environments: https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#building-identical-conda-environments


Bump a new version
------------------

Expand Down
15 changes: 8 additions & 7 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ channels:
dependencies:
- python >=3.9,<3.13
- flit >=3.8,<4.0
- birdy
- birdy >=0.8.6
- black >=24.10.0
- bump-my-version >=0.26.0
- flake8 >=7.0
- flake8-rst-docstrings
- flake8-rst-docstrings >=0.3.0
- ipykernel
- ipywidgets
- isort >=5.13.2
- nbconvert
- nbval
- pip >=23.3.0
- nbconvert >=7.13.0
- nbval >=0.10.0
- pip >=24.2.0
- pre-commit >=3.6.0
- pymetalink
- pymetalink >=6.5.2
- pytest >=8.0.0
- pytest-xdist >=3.2
- python-build
- python-build >=1.0
- yamllint >=1.33.0
25 changes: 12 additions & 13 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,30 @@ channels:
dependencies:
- python >=3.9,<3.13
- pywps >=4.6
- affine
- anyascii
- affine >=2.4.0
- anyascii >=0.3.2
- cartopy >=0.23.0
- click >=8.1.7
- fiona >=1.9
- geopandas >=0.12.0
- geojson
- geojson >=3.1.0
- gdal >=3.0
- jinja2 >=3.1.4
- matplotlib
- nbval
- netcdf4
- matplotlib-base >=3.6.0
- nbval >=0.10.0
- netcdf4 >=1.6.5
- numpy >=1.23.0
- owslib
- owslib >=0.29.0
- pandas >=2.2
- psutil >=6.0.0
- psycopg2
- pymetalink
- pymetalink >=6.5.2
- pyogrio >=0.7.2
- pyproj >=3.4
- rasterio
- rasterstats
- requests
- rioxarray
- rasterio >=1.4.0
- rasterstats >=0.20.0
- requests >=2.31.0
- rioxarray >=0.15.0
- shapely >=2.0
- urlpath
- xarray >=2023.11.0
- xclim >=0.48.2
Loading