mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2026-01-27 02:21:40 +00:00
feat: improve path request results on the cli print
Signed-off-by: JennyLescop <jenny.lescop@orange.com> Change-Id: Id733e39c144dc75e573568b47b3255478a5f0e27
This commit is contained in:
committed by
EstherLerouzic
parent
b3d4b8c60a
commit
32bd4d669e
@@ -20,6 +20,9 @@ from pathlib import Path
|
||||
from typing import Union, List
|
||||
from math import ceil
|
||||
from numpy import mean
|
||||
import pandas as pd
|
||||
from tabulate import tabulate
|
||||
|
||||
|
||||
from gnpy.core import ansi_escapes
|
||||
from gnpy.core.elements import Transceiver, Fiber, RamanFiber
|
||||
@@ -408,46 +411,51 @@ def path_requests_run(args=None):
|
||||
print(f'Network (after autodesign) saved to {args.save_network}')
|
||||
|
||||
print(f'{ansi_escapes.blue}Result summary{ansi_escapes.reset}')
|
||||
header = ['req id', ' demand', ' GSNR@bandwidth A-Z (Z-A)', ' GSNR@0.1nm A-Z (Z-A)',
|
||||
' Receiver minOSNR', ' mode', ' Gbit/s', ' nb of tsp pairs',
|
||||
'N,M or blocking reason']
|
||||
header = ['req id\n', 'demand\n', 'GSNR@bandwidth\nA-Z (Z-A)', 'GSNR@0.1nm\nA-Z (Z-A)', 'OSNR@bandwidth\nA-Z (Z-A)',
|
||||
'OSNR@0.1nm\nA-Z (Z-A)', 'Receiver\nminOSNR', 'mode', 'Gbit/s', 'nb of \ntsp pairs',
|
||||
'N,M or\nblocking reason']
|
||||
|
||||
data = []
|
||||
data.append(header)
|
||||
for i, this_p in enumerate(propagatedpths):
|
||||
rev_pth = reversed_propagatedpths[i]
|
||||
psnrb = None
|
||||
psnr = None
|
||||
posnrb = None
|
||||
posnr = None
|
||||
if rev_pth and this_p:
|
||||
psnrb = f'{round(mean(this_p[-1].snr), 2)} ({round(mean(rev_pth[-1].snr), 2)})'
|
||||
psnr = f'{round(mean(this_p[-1].snr_01nm), 2)}' +\
|
||||
f' ({round(mean(rev_pth[-1].snr_01nm), 2)})'
|
||||
posnrb = f'{round(mean(this_p[-1].osnr_ase), 2)} ({round(mean(rev_pth[-1].osnr_ase), 2)})'
|
||||
posnr = f'{round(mean(this_p[-1].osnr_ase_01nm), 2)}' +\
|
||||
f' ({round(mean(rev_pth[-1].osnr_ase_01nm), 2)})'
|
||||
|
||||
elif this_p:
|
||||
psnrb = f'{round(mean(this_p[-1].snr), 2)}'
|
||||
psnr = f'{round(mean(this_p[-1].snr_01nm), 2)}'
|
||||
posnrb = f'{round(mean(this_p[-1].osnr_ase), 2)}'
|
||||
posnr = f'{round(mean(this_p[-1].osnr_ase_01nm), 2)}'
|
||||
|
||||
try:
|
||||
id_request = rqs[i].request_id[0:min(30, len(rqs[i].request_id))]
|
||||
if rqs[i].blocking_reason in BLOCKING_NOPATH:
|
||||
line = [f'{rqs[i].request_id}', f' {rqs[i].source} to {rqs[i].destination} :',
|
||||
line = [f'{id_request}', f' {rqs[i].source} to {rqs[i].destination} :',
|
||||
'-', '-', '-', f'{rqs[i].tsp_mode}', f'{round(rqs[i].path_bandwidth * 1e-9, 2)}',
|
||||
'-', '{rqs[i].blocking_reason}']
|
||||
else:
|
||||
line = [f'{rqs[i].request_id}', f' {rqs[i].source} to {rqs[i].destination} : ', psnrb,
|
||||
psnr, '-', f'{rqs[i].tsp_mode}', f'{round(rqs[i].path_bandwidth * 1e-9, 2)}',
|
||||
line = [f'{id_request}', f' {rqs[i].source} to {rqs[i].destination} : ', psnrb,
|
||||
psnr, posnrb, posnr, '-', f'{rqs[i].tsp_mode}', f'{round(rqs[i].path_bandwidth * 1e-9, 2)}',
|
||||
'-', f'{rqs[i].blocking_reason}']
|
||||
except AttributeError:
|
||||
line = [f'{rqs[i].request_id}', f' {rqs[i].source} to {rqs[i].destination} : ', psnrb,
|
||||
psnr, f'{rqs[i].OSNR + equipment["SI"]["default"].sys_margins}',
|
||||
line = [f'{id_request}', f' {rqs[i].source} to {rqs[i].destination} : ', psnrb,
|
||||
psnr, posnrb, posnr, f'{rqs[i].OSNR + equipment["SI"]["default"].sys_margins}',
|
||||
f'{rqs[i].tsp_mode}', f'{round(rqs[i].path_bandwidth * 1e-9, 2)}',
|
||||
f'{ceil(rqs[i].path_bandwidth / rqs[i].bit_rate)}', f'({rqs[i].N},{rqs[i].M})']
|
||||
data.append(line)
|
||||
|
||||
col_width = max(len(word) for row in data for word in row[2:]) # padding
|
||||
firstcol_width = max(len(row[0]) for row in data) # padding
|
||||
secondcol_width = max(len(row[1]) for row in data) # padding
|
||||
for row in data:
|
||||
firstcol = ''.join(row[0].ljust(firstcol_width))
|
||||
secondcol = ''.join(row[1].ljust(secondcol_width))
|
||||
remainingcols = ''.join(word.center(col_width, ' ') for word in row[2:])
|
||||
print(f'{firstcol} {secondcol} {remainingcols}')
|
||||
print(f'{ansi_escapes.yellow}Result summary shows mean GSNR and OSNR (average over all channels){ansi_escapes.reset}')
|
||||
df = pd.DataFrame(data, columns=header)
|
||||
print(tabulate(df, headers='keys', tablefmt='psql', stralign='center', numalign='center', showindex=False))
|
||||
print('Result summary shows mean GSNR and OSNR (average over all channels)')
|
||||
|
||||
if args.output:
|
||||
result = []
|
||||
|
||||
@@ -61,9 +61,12 @@ install_requires =
|
||||
numpy>=1.24.4,<2
|
||||
oopt_gnpy_libyang>=0.0.14
|
||||
openpyxl>=3.1.5,<4
|
||||
# pandas 2.1 removed support for Python 3.8
|
||||
pandas>=2.0.3,<3
|
||||
pbr>=6.0.0,<7
|
||||
# scipy 1.11 removed support for Python 3.8
|
||||
scipy>=1.10.1,<2
|
||||
tabulate>=0.9.0,<1
|
||||
# xlrd 2.x removed support for .xlsx, it's only .xls now
|
||||
xlrd>=2.0.1,<3
|
||||
|
||||
@@ -71,8 +74,6 @@ install_requires =
|
||||
tests =
|
||||
build>=1.0.3,<2
|
||||
pytest>=7.4.3,<8
|
||||
# pandas 2.1 removed support for Python 3.8
|
||||
pandas>=2.0.3,<3
|
||||
# flake v6 killed the --diff option
|
||||
flake8>=5.0.4,<6
|
||||
|
||||
|
||||
@@ -125,12 +125,16 @@
|
||||
loose-list: []
|
||||
]
|
||||
[1;34;40mResult summary[0m
|
||||
req id demand GSNR@bandwidth A-Z (Z-A) GSNR@0.1nm A-Z (Z-A) Receiver minOSNR mode Gbit/s nb of tsp pairs N,M or blocking reason
|
||||
0 trx Lorient_KMA to trx Vannes_KBE : 24.83 28.92 14 mode 1 100.0 1 ([-284],[4])
|
||||
1 trx Brest_KLA to trx Vannes_KBE : 17.73 21.81 14 mode 1 200.0 2 ([-272],[8])
|
||||
3 trx Lannion_CAS to trx Rennes_STA : 22.18 26.26 13 mode 1 60.0 1 ([-284],[4])
|
||||
4 trx Rennes_STA to trx Lannion_CAS : 16.04 23.27 17 mode 2 150.0 1 ([-258],[6])
|
||||
5 trx Rennes_STA to trx Lannion_CAS : 20.27 27.5 17 mode 2 20.0 1 ([-274],[6])
|
||||
7 | 6 trx Lannion_CAS to trx Lorient_KMA : 19.52 23.6 14 mode 1 700.0 7 ([-224],[28])
|
||||
7b trx Lannion_CAS to trx Lorient_KMA : 19.61 23.69 14 mode 1 400.0 4 ([-172],[24])
|
||||
[1;33;40mResult summary shows mean GSNR and OSNR (average over all channels)[0m
|
||||
+----------+--------------------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------+
|
||||
| req id | demand | GSNR@bandwidth | GSNR@0.1nm | OSNR@bandwidth | OSNR@0.1nm | Receiver | mode | Gbit/s | nb of | N,M or |
|
||||
| | | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | minOSNR | | | tsp pairs | blocking reason |
|
||||
|----------+--------------------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------|
|
||||
| 0 | trx Lorient_KMA to trx Vannes_KBE : | 24.83 | 28.92 | 24.83 | 28.92 | 14 | mode 1 | 100 | 1 | ([-284],[4]) |
|
||||
| 1 | trx Brest_KLA to trx Vannes_KBE : | 17.73 | 21.81 | 18.56 | 22.65 | 14 | mode 1 | 200 | 2 | ([-272],[8]) |
|
||||
| 3 | trx Lannion_CAS to trx Rennes_STA : | 22.18 | 26.26 | 25.14 | 29.23 | 13 | mode 1 | 60 | 1 | ([-284],[4]) |
|
||||
| 4 | trx Rennes_STA to trx Lannion_CAS : | 16.04 | 23.27 | 16.58 | 23.81 | 17 | mode 2 | 150 | 1 | ([-258],[6]) |
|
||||
| 5 | trx Rennes_STA to trx Lannion_CAS : | 20.27 | 27.5 | 22.65 | 29.88 | 17 | mode 2 | 20 | 1 | ([-274],[6]) |
|
||||
| 7 | 6 | trx Lannion_CAS to trx Lorient_KMA : | 19.52 | 23.6 | 19.8 | 23.89 | 14 | mode 1 | 700 | 7 | ([-224],[28]) |
|
||||
| 7b | trx Lannion_CAS to trx Lorient_KMA : | 19.61 | 23.69 | 19.81 | 23.89 | 14 | mode 1 | 400 | 4 | ([-172],[24]) |
|
||||
+----------+--------------------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------+
|
||||
Result summary shows mean GSNR and OSNR (average over all channels)
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
loose-list: []
|
||||
]
|
||||
[1;34;40mResult summary[0m
|
||||
req id demand GSNR@bandwidth A-Z (Z-A) GSNR@0.1nm A-Z (Z-A) Receiver minOSNR mode Gbit/s nb of tsp pairs N,M or blocking reason
|
||||
0 trx Abilene to trx Albany : 8.92 14.39 - mode 3 100.0 - MODE_NOT_FEASIBLE
|
||||
[1;33;40mResult summary shows mean GSNR and OSNR (average over all channels)[0m
|
||||
+----------+-----------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------+
|
||||
| req id | demand | GSNR@bandwidth | GSNR@0.1nm | OSNR@bandwidth | OSNR@0.1nm | Receiver | mode | Gbit/s | nb of | N,M or |
|
||||
| | | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | minOSNR | | | tsp pairs | blocking reason |
|
||||
|----------+-----------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------|
|
||||
| 0 | trx Abilene to trx Albany : | 8.92 | 14.39 | 9.64 | 15.11 | - | mode 3 | 100 | - | MODE_NOT_FEASIBLE |
|
||||
+----------+-----------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------+
|
||||
Result summary shows mean GSNR and OSNR (average over all channels)
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
loose-list: []
|
||||
]
|
||||
[1;34;40mResult summary[0m
|
||||
req id demand GSNR@bandwidth A-Z (Z-A) GSNR@0.1nm A-Z (Z-A) Receiver minOSNR mode Gbit/s nb of tsp pairs N,M or blocking reason
|
||||
0 trx Brest_KLA to trx Lannion_CAS : 21.29 28.12 26 SFF-ID:70 400.0 1 ([-280],[8])
|
||||
[1;33;40mResult summary shows mean GSNR and OSNR (average over all channels)[0m
|
||||
+----------+------------------------------------+------------------+--------------+------------------+--------------+------------+-----------+----------+-------------+-------------------+
|
||||
| req id | demand | GSNR@bandwidth | GSNR@0.1nm | OSNR@bandwidth | OSNR@0.1nm | Receiver | mode | Gbit/s | nb of | N,M or |
|
||||
| | | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | minOSNR | | | tsp pairs | blocking reason |
|
||||
|----------+------------------------------------+------------------+--------------+------------------+--------------+------------+-----------+----------+-------------+-------------------|
|
||||
| 0 | trx Brest_KLA to trx Lannion_CAS : | 21.29 | 28.12 | 21.48 | 28.31 | 26 | SFF-ID:70 | 400 | 1 | ([-280],[8]) |
|
||||
+----------+------------------------------------+------------------+--------------+------------------+--------------+------------+-----------+----------+-------------+-------------------+
|
||||
Result summary shows mean GSNR and OSNR (average over all channels)
|
||||
|
||||
Reference in New Issue
Block a user