From f2c8b1b890c4515ff6f9d148655e74e21c8f9331 Mon Sep 17 00:00:00 2001 From: ClaraBuettner Date: Tue, 5 Mar 2024 13:56:24 +0100 Subject: [PATCH] Add try/except statement to allow importing etrago object before optimization when "market-grid" is selected --- etrago/tools/network.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/etrago/tools/network.py b/etrago/tools/network.py index 70008a75..4dccebc2 100644 --- a/etrago/tools/network.py +++ b/etrago/tools/network.py @@ -221,9 +221,22 @@ def __init__( ) if self.args["method"]["type"] == "market_grid": - self.market_model = Network( - csv_folder_name + "/market", name, ignore_standard_types - ) + try: + self.market_model = Network( + csv_folder_name + "/market", + name, + ignore_standard_types, + ) + except ValueError: + logger.warning( + """ + Could not import a market_model but the selected + method in the args indicated that it should be there. + This happens when the exported network was not solved + yet.Run 'etrago.optimize()' to build and solve the + market model. + """ + ) self.get_clustering_data(csv_folder_name)