Skip to content

Commit

Permalink
addressing PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hegner committed Sep 11, 2023
1 parent 6b8fe15 commit 51462d9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
20 changes: 6 additions & 14 deletions python/podio_class_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand Down
11 changes: 11 additions & 0 deletions python/podio_schema_evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/SchemaEvolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ void SchemaEvolution::registerEvolutionFunc(const std::string& collType, SchemaV
}
}


podio::CollectionReadBuffers SchemaEvolution::noOpSchemaEvolution(podio::CollectionReadBuffers&& buffers,
SchemaVersionT) {
return buffers;
Expand Down

0 comments on commit 51462d9

Please sign in to comment.