Skip to content

Commit

Permalink
unique components (#285)
Browse files Browse the repository at this point in the history
* unique components

* test fix

---------

Co-authored-by: Alzbeta Pokorna <[email protected]>
  • Loading branch information
Alzpeta and Alzbeta Pokorna authored Dec 11, 2024
1 parent a7e4121 commit a21096b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ class {{ vars.service_config|class_header }}:
components_list.extend(process_service_configs(type(self).mro()[2:]))
additional_components = [{% for c in vars.service_config.components %}{{ c|extra_code }}{% if not loop.last %}, {% endif %}{% endfor %}]
components_list.extend(additional_components)
return components_list
seen = set()
unique_components = []
for component in components_list:
if component not in seen:
unique_components.append(component)
seen.add(component)

return unique_components

model = "{{ vars.module.qualified }}"

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-model-builder
version = 4.0.98
version = 4.0.99
description = A utility library that generates OARepo required data model files from a JSON specification file
authors = Miroslav Bauer <[email protected]>, Miroslav Simek <[email protected]>
readme = README.md
Expand Down
9 changes: 8 additions & 1 deletion tests/test_simple_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,14 @@ def components(self):
components_list.extend(process_service_configs(type(self).mro()[2:]))
additional_components = []
components_list.extend(additional_components)
return components_list
seen = set()
unique_components = []
for component in components_list:
if component not in seen:
unique_components.append(component)
seen.add(component)
return unique_components
model = "test"
Expand Down

0 comments on commit a21096b

Please sign in to comment.