Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
enable-cache: true

- name: Install dependencies
run: uv sync --locked
run: uv sync --locked --extra cpu --no-install-package llama-cpp-python

- name: Prepare frontend build
run: mkdir -p DashAI/front/build
Expand All @@ -57,4 +57,4 @@ jobs:
name: react-build
path: DashAI/front/build
- name: Test with pytest
run: uv run pytest -v
run: uv run --no-sync pytest -v
12 changes: 6 additions & 6 deletions .github/workflows/db-migrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
enable-cache: true

- name: Install dependencies
run: uv sync --locked
run: uv sync --locked --extra cpu --no-install-package llama-cpp-python

- name: Set DB env vars
run: |
Expand All @@ -36,7 +36,7 @@ jobs:

- name: Show Alembic info
run: |
uv run alembic --version
uv run --no-sync alembic --version
echo "DB will be at: $DATABASE_URL"

- name: Prepare temp dir
Expand All @@ -47,15 +47,15 @@ jobs:
# upgrade to head
- name: Upgrade to head
run: |
uv run alembic -x url="$DATABASE_URL" upgrade head
uv run --no-sync alembic -x url="$DATABASE_URL" upgrade head

# Checks downgrade and upgrade again (reversibility)
- name: Downgrade to base and upgrade again (reversibility check)
run: |
uv run alembic -x url="$DATABASE_URL" downgrade base
uv run alembic -x url="$DATABASE_URL" upgrade head
uv run --no-sync alembic -x url="$DATABASE_URL" downgrade base
uv run --no-sync alembic -x url="$DATABASE_URL" upgrade head

- name: Check for pending autogenerate (python-based)
env:
PYTHONPATH: "${PYTHONPATH}:."
run: uv run python -m scripts.ci_alembic_check
run: uv run --no-sync python -m scripts.ci_alembic_check
46 changes: 38 additions & 8 deletions DashAI/back/dependencies/registry/component_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,33 @@ def _get_base_type(self, new_component: type) -> str:

return base_classes_cantidates[0].TYPE

@staticmethod
@beartype
def _collect_compatible_components(component: type) -> List[str]:
"""Collect the union of ``COMPATIBLE_COMPONENTS`` declared along the MRO.

Each class in the component's MRO contributes only the entries it
declares itself, so mixins and base classes compose instead of the
first declaration shadowing the rest (e.g. a task mixin declaring the
task plus a model base class declaring its supported explainers).

Parameters
----------
component : type
The component class to inspect.

Returns
-------
List[str]
Deduplicated compatible component names in MRO order.
"""
compatible_components: List[str] = []
for klass in component.__mro__:
for entry in vars(klass).get("COMPATIBLE_COMPONENTS", []):
if entry not in compatible_components:
compatible_components.append(entry)
return compatible_components

@beartype
def register_component(self, new_component: Type) -> None:
"""Register a component within the registry.
Expand Down Expand Up @@ -232,7 +259,9 @@ def register_component(self, new_component: Type) -> None:
self._set_download_status(new_register_component)

if hasattr(new_component, "COMPATIBLE_COMPONENTS"):
for compatible_component in new_component.COMPATIBLE_COMPONENTS:
for compatible_component in self._collect_compatible_components(
new_component
):
self._relationship_manager.add_relationship(
new_component.__name__,
compatible_component,
Expand Down Expand Up @@ -316,12 +345,11 @@ def unregister_component(self, component: Type) -> None:
f"in the registry. Exception: {e}"
) from e

if hasattr(component, "COMPATIBLE_COMPONENTS"):
for compatible_component in component.COMPATIBLE_COMPONENTS:
self._relationship_manager.remove_relationship(
component.__name__,
compatible_component,
)
for compatible_component in self._collect_compatible_components(component):
self._relationship_manager.remove_relationship(
component.__name__,
compatible_component,
)

@beartype
def get_components_by_types(
Expand Down Expand Up @@ -491,7 +519,8 @@ def get_related_components(self, component_id: str) -> List[Dict[str, Any]]:
"""Obtain any related component of the given component name.

If the component has no related components, then the method returns an empty
list.
list. Related names that are not registered components (e.g. an explainer
declared by a model but provided by an uninstalled plugin) are skipped.

Parameters
----------
Expand All @@ -516,4 +545,5 @@ def get_related_components(self, component_id: str) -> List[Dict[str, Any]]:
return [
self.__getitem__(related_component_id)
for related_component_id in self._relationship_manager[component_id]
if self.__contains__(related_component_id)
]
Loading
Loading