Deltares / ra2ce

RA2CE helps to quantify resilience of critical infrastructure networks, prioritize interventions and adaptation measures and select the most appropriate action perspective to increase resilience considering future conditions.
https://deltares.github.io/ra2ce/
Other
9 stars 2 forks source link

feat: It is now possible to run an analysis by simply providing dataclasses or ini files. #461

Closed Carsopre closed 2 months ago

Carsopre commented 2 months ago

Issue addressed

Solves #460

Code of conduct

What has been done?

Created two static methods in the Ra2ceHandler to streamline the multistep .configure() - .run_analysis().

Given:

_network_file = Path("data", "network.ini")
_analysis_file = Path("data", "analysis.ini")

Previous situation:

_network_config_data = NetworkConfigDataReader().read(_network_file )
_analysis_config_data = AnalysisConfigDataReader().read(_analysis_file)
_handler = Ra2ceHandler.from_config(_network_config_data , _analysis_config_data )
_handler.configure()
_handler.run_analysis()

New situation:

# Option 1: With `.ini` files
Ra2ceHandler.run_with_ini_files(_network_file , _analysis_file)

# Option 2: With config files
_network_config_data = NetworkConfigDataReader().read(_network_file )
_analysis_config_data = AnalysisConfigDataReader().read(_analysis_file)
Ra2ceHandler.run_with_config_data(_network_config_data , _analysis_config_data)

Checklist

Additional Notes (optional)

Improve the tests in test_ra2ce_handler so they are easier to maintain as well as faster to run.