Skip to content

Commit

Permalink
depend on HAPI_DATA_DIR environment variable to store the parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
MAfarrag committed Jan 5, 2025
1 parent a621c03 commit f5e907a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/conda-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ jobs:
conda config --show-sources
conda config --show
pytest -sv -m "not plot" -m "not fig_share"
env:
HAPI_DATA_DIR: ${{ github.workspace }}/src/Hapi/parameters
2 changes: 2 additions & 0 deletions .github/workflows/pypi-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
- name: Run Tests
run: |
python -m pytest -vvv -m "not fig_share" --cov=src/Hapi --cov-report=xml
env:
HAPI_DATA_DIR: ${{ github.workspace }}/src/Hapi/parameters

- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
19 changes: 14 additions & 5 deletions src/Hapi/inputs.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""Rainfall-runoff Inputs."""
from typing import Union
from pathlib import Path

import datetime as dt
import os
from pathlib import Path
from typing import Union

import pandas as pd
from geopandas import GeoDataFrame
from pyramids.dataset import Dataset
from pyramids.datacube import Datacube
from pyramids.dataset import Dataset

import Hapi

Expand Down Expand Up @@ -197,8 +199,15 @@ def extract_parameters(
"lp","k0","k1","k2","uzl","perc", "maxbas",'K_muskingum',
'x_muskingum']
"""
parameters_path = os.path.dirname(Hapi.__file__)
parameters_path = f"{parameters_path}/parameters/{scenario}"
data_dir = os.getenv("HAPI_DATA_DIR")
if data_dir is None:
raise ValueError("HAPI_DATA_DIR environment variable is not set")
else:
data_dir = Path(data_dir)
if not data_dir.exists():
raise FileNotFoundError(f"{data_dir} does not exist")

parameters_path = data_dir / scenario

if not as_raster:
dataset = Dataset.read_file(f"{parameters_path}/{PARAMETERS_LIST[0]}.tif")
Expand Down

0 comments on commit f5e907a

Please sign in to comment.