Add rpy2 to the dependencies

- add a Jupyter notebook that allows to install all project-external
  dependencies regarding R and R packages
- adjust the GitHub Action workflow to also install R and the R packages
  used within the project
- add a `init_r` module that initializes all R packages globally
  once the `urban_meal_delivery` package is imported
This commit is contained in:
Alexander Hess 2021-01-11 12:24:15 +01:00
commit b0f2fdde10
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
10 changed files with 2152 additions and 52 deletions

View file

@ -69,6 +69,8 @@ class Config:
ALEMBIC_TABLE = 'alembic_version'
ALEMBIC_TABLE_SCHEMA = 'public'
R_LIBS_PATH = os.getenv('R_LIBS')
def __repr__(self) -> str:
"""Non-literal text representation."""
return '<configuration>'
@ -117,6 +119,12 @@ def make_config(env: str = 'production') -> Config:
if config.DATABASE_URI is None and not os.getenv('TESTING'):
warnings.warn('Bad configurartion: no DATABASE_URI set in the environment')
# Some functionalities require R and some packages installed.
# To ensure isolation and reproducibility, the projects keeps the R dependencies
# in a project-local folder that must be set in the environment.
if config.R_LIBS_PATH is None and not os.getenv('TESTING'):
warnings.warn('Bad configuration: no R_LIBS set in the environment')
return config