fix: do not crash if type_variety is not defined when saving network

before autodesign type_variety may not be created yet, while ther is one default in params:
use type_variety from params

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: I556bc8fa1a8241054c81cee386cf52b94a76a0bc
This commit is contained in:
EstherLerouzic
2024-10-29 14:56:53 +01:00
parent 56e615c713
commit 6f9897fe40
2 changed files with 6 additions and 2 deletions

View File

@@ -1772,9 +1772,9 @@ class Multiband_amplifier(_Node):
"""
return {'uid': self.uid,
'type': type(self).__name__,
'type_variety': self.type_variety,
'type_variety': self.params.type_variety,
'amplifiers': [{
'type_variety': amp.type_variety,
'type_variety': amp.params.type_variety,
'operational': {
'gain_target': round(amp.effective_gain, 6),
'delta_p': amp.delta_p,

View File

@@ -1267,8 +1267,12 @@ def set_egress_amplifier(network: DiGraph, this_node: Union[elements.Roadm, elem
network, _restrictions, equipment, verbose,
deviation_db=deviation_db[band_name], tilt_target=tilt_target[band_name])
amps_type_varieties = [a.type_variety for a in node.amplifiers.values()]
amps_bands = [a.params.bands[0] for a in node.amplifiers.values()]
try:
node.type_variety = find_type_variety(amps_type_varieties, equipment)[0]
# overwrite type_variety and bands to be consistent with selected type_variety
node.params.type_variety = node.type_variety
node.params.bands = amps_bands
except ConfigurationError as e:
# should never come here... only for debugging
msg = f'In {node.uid}: {e}'