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

Solved dependency issues for plugins #96

Merged
merged 3 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Added plugin imports within if and try statments
  • Loading branch information
SanchitMinocha committed Feb 25, 2024
commit bf8242f9e9ee711cd4d1033c4bc7a346859e1b77
7 changes: 5 additions & 2 deletions src/rat/rat_basin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

from rat.utils.convert_to_final_outputs import convert_sarea, convert_inflow, convert_dels, convert_evaporation, convert_outflow, convert_altimeter, copy_aec_files

from rat.plugins.resorr.runResorr import runResorr

# Step-(-1): Reading Configuration settings to run RAT
# Step-0: Creating required directory structure for RAT
# Step-1: Downloading and Pre-processing of meteorolgical data
Expand Down Expand Up @@ -768,6 +766,11 @@ def rat_basin(config, rat_logger, forecast_mode=False):

## Plugins: RESORR
if config.get('PLUGINS', {}).get('resorr'):
# Importing ResORR
try:
from rat.plugins.resorr.runResorr import runResorr
except:
rat_logger.exception("Failed to import ResORR due to missing package(s). Please check for geonetworkx package. You can install it using 'pip install geonetworkx'.")
resorr_startDate = config['BASIN']['start']
resorr_endDate = config['BASIN']['end']
# check if basin_station_latlon_file exists:
Expand Down
11 changes: 10 additions & 1 deletion src/rat/run_rat.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from rat.utils.logging import init_logger,close_logger,LOG_LEVEL1_NAME
import rat.ee_utils.ee_config as ee_configuration
from rat.rat_basin import rat_basin
from rat.plugins.forecasting import forecast

#------------ Define Variables ------------#
def run_rat(config_fn, operational_latency=None):
Expand Down Expand Up @@ -92,6 +91,11 @@ def run_rat(config_fn, operational_latency=None):
no_errors, latest_altimetry_cycle = rat_basin(config, log)
# Run RAT forecast for basin if forecast is True
if config.get('PLUGINS', {}).get('forecasting'):
# Importing the forecast module
try:
from rat.plugins.forecasting import forecast
except:
log.exception("Failed to import Forecast plugin due to missing package(s).")
log.info('############## Starting RAT forecast for '+config['BASIN']['basin_name']+' #################')
forecast_no_errors = forecast(config, log)
if(forecast_no_errors>0):
Expand Down Expand Up @@ -173,6 +177,11 @@ def run_rat(config_fn, operational_latency=None):
no_errors, latest_altimetry_cycle = rat_basin(config_copy, log)
# Run RAT forecast for basin if forecast is True
if config.get('PLUGINS', {}).get('forecasting'):
# Importing the forecast module
try:
from rat.plugins.forecasting import forecast
except:
log.exception("Failed to import Forecast plugin due to missing package(s).")
log.info('############## Starting RAT forecast for '+config['BASIN']['basin_name']+' #################')
forecast_no_errors = forecast(config, log)
if(forecast_no_errors>0):
Expand Down