def add_scenario(ctx, network_id, scen, return_summary): """ Add a scenario to a specified network. """ new_scen = scenario.add_scenario(network_id, scen, **ctx.in_header.__dict__) if return_summary == 'Y': return Scenario(new_scen, summary=True) else: return Scenario(new_scen, summary=False)
def get_scenario(ctx, scenario_id, return_summary): """ Get the specified scenario """ scen = scenario.get_scenario(scenario_id, **ctx.in_header.__dict__) if return_summary == 'Y': return Scenario(scen, summary=True) else: return Scenario(scen, summary=False)
def update_scenario(ctx, scen, update_data, update_groups, return_summary): """ Update a single scenario as all resources already exist, there is no need to worry about negative IDS """ upd_data = True if update_data == 'Y' else False upd_grp = True if update_groups == 'Y' else False updated_scen = scenario.update_scenario(scen, update_data=upd_data, update_groups=upd_grp, **ctx.in_header.__dict__) if return_summary == 'Y': return Scenario(updated_scen, summary=True) else: return Scenario(updated_scen, summary=False)
def get_dataset_scenarios(ctx, dataset_id): """ Get all the scenarios attached to a dataset @returns a list of scenario_ids """ scenarios = scenario.get_dataset_scenarios(dataset_id, **ctx.in_header.__dict__) return [Scenario(s, summary=True) for s in scenarios]
def get_scenarios_data(ctx, networks, nodes, links, scenario_id, attr_id, type_id): """ Get all scenarios and resourcescenarios filtered by scenario_id, attr_id, and/or type_id. """ scenarios = scenario.get_scenarios_data(networks, nodes, links, scenario_id, attr_id, type_id, **ctx.in_header.__dict__) ret_data = [Scenario(s, summary=False) for s in scenarios] return ret_data
def get_scenarios(ctx, network_id): """ Get all the scenarios in a given network. Args: network_id (int): The network from which to retrieve the scenarios Returns: List(hydra_complexmodels.Scenario): All the scenarios in the network Raises: ResourceNotFoundError: If the network is not found """ scenarios_i = network.get_scenarios(network_id, **ctx.in_header.__dict__) scenarios = [Scenario(scen) for scen in scenarios_i] return scenarios
def clone_scenario(ctx, scenario_id): cloned_scen = scenario.clone_scenario(scenario_id, **ctx.in_header.__dict__) return Scenario(cloned_scen, summary=True)