move update_link_label code to a function
@@ -464,9 +464,8 @@ class DatasetModels(collections.abc.Sequence):
data, sort_keys=False, indent=4, width=80, default_flow_style=False
)
- def to_dict(self, full_output=False, overwrite_templates=False):
- """Convert to dict."""
- # update linked parameters labels
+ def update_link_label(self):
+ """update linked parameters labels used for serialization and print"""
params_list = []
params_shared = []
for param in self.parameters:
@@ -478,6 +477,12 @@ class DatasetModels(collections.abc.Sequence):
for param in params_shared:
param._link_label_io = param.name + "@" + make_name()
+
+ def to_dict(self, full_output=False, overwrite_templates=False):
+ """Convert to dict."""
+
+ self.update_link_label()
+
models_data = []
for model in self._models:
model_data = model.to_dict(full_output)
@@ -554,6 +559,9 @@ class DatasetModels(collections.abc.Sequence):
table.write(make_path(filename), **kwargs)
def __str__(self):
+
+ self.update_link_label()
+
str_ = f"{self.__class__.__name__}\n\n"
for idx, model in enumerate(self):
