From 51462d9321aedcff4dd7726471fa56d2b74d54cb Mon Sep 17 00:00:00 2001 From: Benedikt Hegner Date: Mon, 11 Sep 2023 22:41:01 +0200 Subject: [PATCH] addressing PR comments --- python/podio_class_generator.py | 20 ++++++-------------- python/podio_schema_evolution.py | 11 +++++++++++ src/SchemaEvolution.cc | 1 - 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/python/podio_class_generator.py b/python/podio_class_generator.py index a23b8ac4e..2063280c6 100755 --- a/python/podio_class_generator.py +++ b/python/podio_class_generator.py @@ -306,8 +306,9 @@ def _process_component(self, name, component): self._fill_templates('Component', component) self.root_schema_component_names.add(name + self.old_schema_version) - def _replaceComponentInPaths(self, oldname, newname, paths): - """Replace component in paths""" + @staticmethod + def _replace_component_in_paths(oldname, newname, paths): + """Replace component name by another one in existing paths""" # strip the namespace shortoldname = oldname.split("::")[-1] shortnewname = newname.split("::")[-1] @@ -334,7 +335,7 @@ def _process_datatype(self, name, definition): if member.is_array: if member.array_type in self.root_schema_dict: needs_schema_evolution = True - self._replaceComponentInPaths(member.array_type, member.array_type + self.old_schema_version, + self._replace_component_in_paths(member.array_type, member.array_type + self.old_schema_version, schema_evolution_datatype['includes_data']) member.full_type = member.full_type.replace(member.array_type, member.array_type + self.old_schema_version) member.array_type = member.array_type + self.old_schema_version @@ -345,16 +346,7 @@ def _process_datatype(self, name, definition): # prepare the ROOT I/O rule print(member.full_type) dir(member) -# iorule = RootIoRule() -# iorule.sourceClass = member.full_type -# iorule.targetClass = member.full_type -# iorule.version = 2 #self.schema_version.lstrip("v") -# iorule.target = "y" -# iorule.source = "int y_old" -# iorule.code = "std::cout<< onfile.y_old << y << std::endl; y = onfile.y_old;" -# if len(self.root_schema_iorules) == 0: -# self.root_schema_iorules.add(iorule) - self._replaceComponentInPaths(member.full_type, member.full_type + self.old_schema_version, + self._replace_component_in_paths(member.full_type, member.full_type + self.old_schema_version, schema_evolution_datatype['includes_data']) member.full_type = member.full_type + self.old_schema_version member.bare_type = member.bare_type + self.old_schema_version @@ -395,7 +387,7 @@ def prepare_iorules(self): iorule.version = self.old_schema_version.lstrip("v") iorule.source = f'{member_type} {schema_change.member_name_old}' iorule.target = schema_change.member_name_new - iorule.code = f'std::cout<< "reading {schema_change.member_name_old} with value " << onfile.{schema_change.member_name_old} << std::endl; {iorule.target} = onfile.{schema_change.member_name_old};' # noqa + iorule.code = f'{iorule.target} = onfile.{schema_change.member_name_old};' self.root_schema_iorules.add(iorule) else: raise NotImplementedError("Schema evolution for this type not yet implemented") diff --git a/python/podio_schema_evolution.py b/python/podio_schema_evolution.py index 947a44da9..e2b7a916f 100755 --- a/python/podio_schema_evolution.py +++ b/python/podio_schema_evolution.py @@ -107,6 +107,17 @@ def __init__(self, name, member_name_old, member_name_new): super().__init__(f"'{self.name}': member '{self.member_name_old}' renamed to '{self.member_name_new}'.") +class RootIoRule: + """A placeholder IORule class""" + def __init__(self): + self.sourceClass = None + self.targetClass = None + self.version = None + self.source = None + self.target = None + self.code = None + + def sio_filter(schema_changes): """ Checks what is required/supported for the SIO backend diff --git a/src/SchemaEvolution.cc b/src/SchemaEvolution.cc index 8a42e074a..4576cde1e 100644 --- a/src/SchemaEvolution.cc +++ b/src/SchemaEvolution.cc @@ -68,7 +68,6 @@ void SchemaEvolution::registerEvolutionFunc(const std::string& collType, SchemaV } } - podio::CollectionReadBuffers SchemaEvolution::noOpSchemaEvolution(podio::CollectionReadBuffers&& buffers, SchemaVersionT) { return buffers;