Skip to content

Commit

Permalink
Component order fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mesemus committed Feb 9, 2025
1 parent ad316a0 commit 2c031af
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions oarepo_runtime/services/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from flask import current_app
from invenio_accounts.models import User
from invenio_base.utils import obj_or_import_string
from invenio_drafts_resources.services.records.config import (
RecordServiceConfig as DraftsRecordServiceConfig,
)
Expand Down Expand Up @@ -219,16 +220,22 @@ def _prepare_component_placement(components) -> list[ComponentPlacement]:
for dep in getattr(placement.component, "depends_on", []):
if dep == "*":
continue
dep = obj_or_import_string(dep)
for pl in _matching_placements(placements_without_this, dep):
placement.depends_on.append(pl)
pl.affects.append(placement)
if pl not in placement.depends_on:
placement.depends_on.append(pl)
if placement not in pl.affects:
pl.affects.append(placement)

for dep in getattr(placement.component, "affects", []):
if dep == "*":
continue
dep = obj_or_import_string(dep)
for pl in _matching_placements(placements_without_this, dep):
placement.affects.append(pl)
pl.depends_on.append(placement)
if pl not in placement.affects:
placement.affects.append(pl)
if placement not in pl.depends_on:
pl.depends_on.append(placement)

# star dependencies
for idx, placement in enumerate(placements):
Expand All @@ -238,16 +245,20 @@ def _prepare_component_placement(components) -> list[ComponentPlacement]:
# if this placement is not in placements that pl depends on
# (added via direct dependencies above), add it
if placement not in pl.depends_on:
placement.depends_on.append(pl)
pl.affects.append(placement)
if pl not in placement.depends_on:
placement.depends_on.append(pl)
if placement not in pl.affects:
pl.affects.append(placement)

if "*" in getattr(placement.component, "affects", []):
for pl in placements_without_this:
# if this placement is not in placements that pl affects
# (added via direct dependencies above), add it
if placement not in pl.affects:
placement.affects.append(pl)
pl.depends_on.append(placement)
if pl not in placement.affects:
placement.affects.append(pl)
if placement not in pl.depends_on:
pl.depends_on.append(placement)
return placements


Expand Down

0 comments on commit 2c031af

Please sign in to comment.