From dbb09e41086cd8b9b89aeb3f32656d59fc863f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Wed, 10 Jun 2020 13:23:25 +0200 Subject: [PATCH] CLI: Allow Raman in path_requests_run There's no need to limit this to just the transmission_main_example, so let's unify this handling. Change-Id: I585f407c7f80da12fd33baf7261c35c736d78df2 --- gnpy/tools/cli_examples.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gnpy/tools/cli_examples.py b/gnpy/tools/cli_examples.py index cbd190bc..f55095a7 100644 --- a/gnpy/tools/cli_examples.py +++ b/gnpy/tools/cli_examples.py @@ -47,8 +47,9 @@ def show_example_data_dir(): print(f'{_examples_dir}/') -def load_common_data(equipment_filename, topology_filename, simulation_filename=None): +def load_common_data(equipment_filename, topology_filename, simulation_filename): '''Load common configuration from JSON files''' + try: equipment = load_equipment(equipment_filename) network = load_network(topology_filename, equipment) @@ -91,6 +92,9 @@ def _add_common_options(parser: argparse.ArgumentParser, network_default: Path): help='Increase verbosity (can be specified several times)') parser.add_argument('-e', '--equipment', type=Path, metavar=_help_fname_json, default=_examples_dir / 'eqpt_config.json', help='Equipment library') + parser.add_argument('--sim-params', type=Path, metavar=_help_fname_json, + default=None, help='Path to the JSON containing simulation parameters (required for Raman). ' + f'Example: {_examples_dir / "sim_params.json"}') parser.add_argument('--save-network', type=Path, metavar=_help_fname_json, help='Save the final network as a JSON file') @@ -102,8 +106,6 @@ def transmission_main_example(args=None): formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) _add_common_options(parser, network_default=_examples_dir / 'edfa_example_network.json') - parser.add_argument('--sim-params', type=Path, metavar=_help_fname_json, - default=None, help='Path to the JSON containing simulation parameters (required for Raman)') parser.add_argument('--show-channels', action='store_true', help='Show final per-channel OSNR summary') parser.add_argument('-pl', '--plot', action='store_true') parser.add_argument('-l', '--list-nodes', action='store_true', help='list all transceiver nodes') @@ -297,7 +299,7 @@ def path_requests_run(args=None): _logger.info(f'Computing path requests {args.service_filename} into JSON format') print(f'{ansi_escapes.blue}Computing path requests {os.path.relpath(args.service_filename)} into JSON format{ansi_escapes.reset}') - (equipment, network) = load_common_data(args.equipment, args.topology) + (equipment, network) = load_common_data(args.equipment, args.topology, args.sim_params) # Build the network once using the default power defined in SI in eqpt config # TODO power density: db2linp(ower_dbm": 0)/power_dbm": 0 * nb channels as defined by