Skip to content

Commit

Permalink
Merge pull request #92 from CSHS-CWRA/new-config-idea
Browse files Browse the repository at this point in the history
Configuration subsystem refactoring
  • Loading branch information
cjauvin authored Apr 30, 2021
2 parents 9354e1b + ec89633 commit 0f91952
Show file tree
Hide file tree
Showing 123 changed files with 4,892 additions and 89,529 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"project_slug": "ravenpy",
"project_short_description": "A Python wrapper to setup and run the hydrologic modelling framework Raven.",
"pypi_username": "CSHS-CWRA",
"version": "0.4.2",
"version": "0.5.0",
"use_pytest": "y",
"use_pypi_deployment_with_travis": "y",
"add_pyup_badge": "y",
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
- id: debug-statements
language_version: python3
- repo: https://github.com/ambv/black
rev: 21.4b0
rev: 21.4b1
hooks:
- id: black
language_version: python3
Expand Down
18 changes: 14 additions & 4 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@
History
=======

0.5.0
-----

* Refactoring of the RV config subsystem
* The config is fully encapsulated into its own class: `ravenpy.config.rvs.Config`
* The emulator RV templates are inline in their emulator classes
* The emulators have their own submodule: `ravenpy.models.emulators`
* The "importers" have been renamed to "extractors" and they have their own submodule: `ravenpy.extractors`

0.4.2
-----
* Update to RavenC revision 318 to fix OPENDAP access for StationForcing commands
* Fix grid_weights set to None by default
* Pass nc_index to ObservationData command
* Expose more cleanly RavenC errors and warnings

* Update to RavenC revision 318 to fix OPENDAP access for StationForcing commands.
* Fix grid_weights set to None by default.
* Pass nc_index to ObservationData command.
* Expose more cleanly RavenC errors and warnings.

0.4.1
-----
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ coverage: ## check code coverage quickly with the default Python

docs: ## generate Sphinx HTML documentation, including API docs
# Warning: as the sphinx-apidoc is NOT being run on the RTD server the workaround we have
# is to commit the (currently 5) rst files it generates.
sphinx-apidoc -o docs/ ravenpy
# is to commit the (currently 8) rst files it generates.
sphinx-apidoc -d 10 -o docs/ ravenpy
$(MAKE) -C docs clean
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html
Expand Down
10 changes: 10 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
autosummary_generate = True
nbsphinx_execute = "auto"

# To ensure that underlined fields (e.g. `_field`) are shown in the docs.
autodoc_default_options = {
"members": True,
"undoc-members": True,
"private-members": False,
"special-members": False,
}

# To avoid having to install these and burst memory limit on ReadTheDocs.
autodoc_mock_imports = [
"affine",
Expand All @@ -57,6 +65,8 @@
"netCDF4",
"osgeo",
"geopandas",
"holoviews",
"hvplot",
"lxml",
"owslib",
"pandas",
Expand Down
2 changes: 1 addition & 1 deletion docs/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ ravenpy
=======

.. toctree::
:maxdepth: 4
:maxdepth: 10

ravenpy
258 changes: 144 additions & 114 deletions docs/notebooks/RavenPy.ipynb

Large diffs are not rendered by default.

50 changes: 22 additions & 28 deletions docs/notebooks/Running_Raven_with_CANOPEX_data.ipynb

Large diffs are not rendered by default.

98 changes: 45 additions & 53 deletions docs/notebooks/climatological_ESP_forecasting.ipynb

Large diffs are not rendered by default.

83 changes: 37 additions & 46 deletions docs/notebooks/hydro_routing_product_example.ipynb

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions docs/ravenpy.config.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ravenpy.config package
======================

Submodules
----------

ravenpy.config.commands module
------------------------------

.. automodule:: ravenpy.config.commands
:members:
:undoc-members:
:show-inheritance:

ravenpy.config.rvs module
-------------------------

.. automodule:: ravenpy.config.rvs
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: ravenpy.config
:members:
:undoc-members:
:show-inheritance:
21 changes: 21 additions & 0 deletions docs/ravenpy.extractors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ravenpy.extractors package
==========================

Submodules
----------

ravenpy.extractors.routing\_product module
------------------------------------------

.. automodule:: ravenpy.extractors.routing_product
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: ravenpy.extractors
:members:
:undoc-members:
:show-inheritance:
53 changes: 53 additions & 0 deletions docs/ravenpy.models.emulators.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ravenpy.models.emulators package
================================

Submodules
----------

ravenpy.models.emulators.blended module
---------------------------------------

.. automodule:: ravenpy.models.emulators.blended
:members:
:undoc-members:
:show-inheritance:

ravenpy.models.emulators.gr4jcn module
--------------------------------------

.. automodule:: ravenpy.models.emulators.gr4jcn
:members:
:undoc-members:
:show-inheritance:

ravenpy.models.emulators.hbvec module
-------------------------------------

.. automodule:: ravenpy.models.emulators.hbvec
:members:
:undoc-members:
:show-inheritance:

ravenpy.models.emulators.hmets module
-------------------------------------

.. automodule:: ravenpy.models.emulators.hmets
:members:
:undoc-members:
:show-inheritance:

ravenpy.models.emulators.mohyse module
--------------------------------------

.. automodule:: ravenpy.models.emulators.mohyse
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: ravenpy.models.emulators
:members:
:undoc-members:
:show-inheritance:
40 changes: 8 additions & 32 deletions docs/ravenpy.models.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
ravenpy.models package
======================

Subpackages
-----------

.. toctree::
:maxdepth: 10

ravenpy.models.emulators

Submodules
----------

Expand All @@ -12,30 +20,6 @@ ravenpy.models.base module
:undoc-members:
:show-inheritance:

ravenpy.models.commands module
------------------------------

.. automodule:: ravenpy.models.commands
:members:
:undoc-members:
:show-inheritance:

ravenpy.models.emulators module
-------------------------------

.. automodule:: ravenpy.models.emulators
:members:
:undoc-members:
:show-inheritance:

ravenpy.models.importers module
-------------------------------

.. automodule:: ravenpy.models.importers
:members:
:undoc-members:
:show-inheritance:

ravenpy.models.multimodel module
--------------------------------

Expand All @@ -44,14 +28,6 @@ ravenpy.models.multimodel module
:undoc-members:
:show-inheritance:

ravenpy.models.rv module
------------------------

.. automodule:: ravenpy.models.rv
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

Expand Down
4 changes: 3 additions & 1 deletion docs/ravenpy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ Subpackages
-----------

.. toctree::
:maxdepth: 4
:maxdepth: 10

ravenpy.cli
ravenpy.config
ravenpy.extractors
ravenpy.models
ravenpy.utilities

Expand Down
8 changes: 8 additions & 0 deletions docs/ravenpy.utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ ravenpy.utilities.mk\_test module
:undoc-members:
:show-inheritance:

ravenpy.utilities.nb\_graphs module
-----------------------------------

.. automodule:: ravenpy.utilities.nb_graphs
:members:
:undoc-members:
:show-inheritance:

ravenpy.utilities.ravenio module
--------------------------------

Expand Down
31 changes: 22 additions & 9 deletions docs/user_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
User API
========

Base models
Base Models
===========

.. autoclass:: ravenpy.models.base.Raven
Expand All @@ -20,30 +20,43 @@ Base models
Emulators
=========

.. automodule:: ravenpy.models.emulators
.. automodule:: ravenpy.models.emulators.blended
:members:
:noindex:

.. automodule:: ravenpy.models.emulators.gr4jcn
:members:
:noindex:

Configuration options
=====================
.. automodule:: ravenpy.models.emulators.hbvec
:members:
:noindex:

.. automodule:: ravenpy.models.rv
.. automodule:: ravenpy.models.emulators.hmets
:members:
:noindex:

.. automodule:: ravenpy.models.commands
.. automodule:: ravenpy.models.emulators.mohyse
:members:
:noindex:

Configuration
=============

Importers
=========
.. automodule:: ravenpy.config.commands
:members:
:noindex:

.. automodule:: ravenpy.models.importers
.. automodule:: ravenpy.config.rvs
:members:
:noindex:

Extractors
==========

.. automodule:: ravenpy.extractors.routing_product
:members:
:noindex:

Utilities
=========
Expand Down
1 change: 1 addition & 0 deletions environment-rtd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies:
- ipython
- ipykernel
- jupyter_client
- pydantic
- sphinx-click
- sphinx_rtd_theme
- sphinx-autoapi
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
- pandas
- pip
- proj
- pydantic
- pyparsing
- pyproj>=3.0.0
- rasterio
Expand Down
2 changes: 1 addition & 1 deletion ravenpy/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

__author__ = """David Huard"""
__email__ = "huard.david@ouranos.ca"
__version__ = "0.4.2"
__version__ = "0.5.0"
6 changes: 3 additions & 3 deletions ravenpy/cli/aggregate_forcings_to_hrus.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import click

from ravenpy.models.commands import GridWeightsCommand
from ravenpy.models.importers import grid_weight_importer_params
from ravenpy.config.commands import GridWeightsCommand
from ravenpy.extractors.routing_product import RoutingProductGridWeightExtractor


@click.command()
Expand All @@ -14,7 +14,7 @@
"--dim-names",
nargs=2,
type=click.Tuple([str, str]),
default=grid_weight_importer_params["DIM_NAMES"],
default=RoutingProductGridWeightExtractor.DIM_NAMES,
show_default=True,
help="Ordered dimension names of longitude (x) and latitude (y) in the NetCDF INPUT_NC_FILE.",
)
Expand Down
Loading

0 comments on commit 0f91952

Please sign in to comment.