Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dag parsing logic #628

Merged
merged 14 commits into from
Nov 14, 2024
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
14 changes: 8 additions & 6 deletions tdp/cli/commands/default_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def default_diff(collections: Collections, vars: Path, service: Optional[str] =
service_diff(collections, service_variables)


def service_diff(collections, service):
def service_diff(collections: Collections, service):
"""Computes the difference between the default variables from a service, and the variables from your service variables inside your tdp_vars.

Args:
Expand All @@ -44,12 +44,14 @@ def service_diff(collections, service):
"""
# key: filename with extension, value: PosixPath(filepath)
default_service_vars_paths = OrderedDict()
for collection in collections.values():
default_vars = collection.get_service_default_vars(service.name)
if not default_vars:
for collection_default_vars_dir in collections.default_vars_dirs.values():
service_default_vars_dir = collection_default_vars_dir / service.name
if not service_default_vars_dir.exists():
continue
for name, path in default_vars:
default_service_vars_paths.setdefault(name, []).append(path)
for default_vars_path in service_default_vars_dir.iterdir():
default_service_vars_paths.setdefault(default_vars_path.name, []).append(
default_vars_path
)

for (
default_service_vars_filename,
Expand Down
2 changes: 1 addition & 1 deletion tdp/cli/commands/vars/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def edit(
# Check if component exists
entity_name = parse_hostable_entity_name(variables_file.stem)
if isinstance(entity_name, ServiceComponentName):
if entity_name not in collections.get_components_from_service(service_name):
if entity_name not in collections.hostable_entities[service_name]:
raise click.ClickException(
f"Error unknown component '{entity_name.component}' for service '{entity_name.service}'"
)
Expand Down
6 changes: 1 addition & 5 deletions tdp/cli/params/collections_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import click
from click.decorators import FC

from tdp.core.collection import Collection
from tdp.core.collections import Collections


Expand All @@ -29,10 +28,7 @@ def _collections_from_paths(
if not value:
raise click.BadParameter("cannot be empty", ctx=ctx, param=param)

collections_list = [Collection.from_path(path) for path in value]
collections = Collections.from_collection_list(collections_list)

return collections
return Collections.from_collection_paths(value)


def collections_option(func: FC) -> FC:
Expand Down
3 changes: 1 addition & 2 deletions tdp/cli/params/status/component_argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def _check_component(
collections: Collections = ctx.params["collections"]
service: str = ctx.params["service"]
if value and value not in [
sc_name.component
for sc_name in collections.get_components_from_service(service)
sc_name.component for sc_name in collections.hostable_entities[service]
]:
raise click.UsageError(
f"Component '{value}' does not exists in service '{service}'."
Expand Down
304 changes: 0 additions & 304 deletions tdp/core/collection.py

This file was deleted.

4 changes: 4 additions & 0 deletions tdp/core/collections/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2022 TOSIT.IO
# SPDX-License-Identifier: Apache-2.0

from .collections import Collections
Loading
Loading