Commit 605da138 authored by Unknown's avatar Unknown
Browse files

Put request input logic into multiple_hubs to match ehub

Currently kept the runtime error but could also use a default input if that is preferred 
parent 0ca78dd3
Loading
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -221,15 +221,18 @@ def multiple_hubs(minimize_carbon=False, output_filename=None, input_files=None,
    Core function for solving of multiple PyEHub models.
    """

    #TODO: Put the network request logic here
    # The default excel file for network, in the network directory
    if network_excel is None:
        network_excel_file = 'Input_files/network_input/network.xlsx'
    # Additional option for tests for multiple_hubs. To input a different network excel files.
    else:
    if network_excel:
        network_excel_file = network_excel
    network = network_to_request_format.convert(network_excel_file)
    _net_data = InputData(network)
        network_request = network_to_request_format.convert(network_excel_file)

        if network_request:
            _net_data = InputData(network_request)
        else:
            # The default excel file for network, in the network directory
            # network_excel_file = 'Input_files/network_input/network.xlsx'
            # network_request = network_to_request_format.convert(network_excel_file)
            # _net_data = InputData(network_request)
            raise RuntimeError("Can't create a network with no network data.")

    # Create all the hubs
    hubs = []
@@ -243,7 +246,7 @@ def multiple_hubs(minimize_carbon=False, output_filename=None, input_files=None,
        excel_file = file_name

        hub = NetworkModel(excel=excel_file, name=f'hub{i+1}', max_carbon=max_carbon,
                                            network=network_excel_file, hub_id=i)
                                            network=network_excel_file, network_request=network_request, hub_id=i)
        hubs.append(hub)

    # Creating a list of all the constraints from all the hubs