From 2bdf195eb844221d06c0fc4bf55eaae7f39b6759 Mon Sep 17 00:00:00 2001 From: Paul Farault <paul@adaltas.com> Date: Thu, 21 Nov 2024 11:43:31 +0100 Subject: [PATCH] refactor: rename hostable entity name to entity name --- tdp/cli/commands/vars/edit.py | 2 +- tdp/core/cluster_status.py | 6 +++--- tdp/core/collections/collections.py | 2 +- tdp/core/deployment/deployment_iterator.py | 2 +- .../entities/{hostable_entity_name.py => entity_name.py} | 6 +++--- tdp/core/entities/hosted_entity.py | 8 ++++---- tdp/core/variables/service_variables.py | 6 ++---- tdp/dao.py | 2 +- test_dag_order/helpers.py | 2 +- 9 files changed, 17 insertions(+), 19 deletions(-) rename tdp/core/entities/{hostable_entity_name.py => entity_name.py} (94%) diff --git a/tdp/cli/commands/vars/edit.py b/tdp/cli/commands/vars/edit.py index 2be7bde1..423c6f8e 100644 --- a/tdp/cli/commands/vars/edit.py +++ b/tdp/cli/commands/vars/edit.py @@ -16,7 +16,7 @@ ) from tdp.core.collections import Collections from tdp.core.constants import YML_EXTENSION -from tdp.core.entities.hostable_entity_name import ( +from tdp.core.entities.entity_name import ( ServiceComponentName, parse_hostable_entity_name, ) diff --git a/tdp/core/cluster_status.py b/tdp/core/cluster_status.py index 69bf25a9..8dac553c 100644 --- a/tdp/core/cluster_status.py +++ b/tdp/core/cluster_status.py @@ -8,8 +8,8 @@ from typing import TYPE_CHECKING, Optional from tdp.core.dag import Dag -from tdp.core.entities.hostable_entity_name import ( - HostableEntityName, +from tdp.core.entities.entity_name import ( + EntityName, create_hostable_entity_name, ) from tdp.core.entities.hosted_entity import ( @@ -198,7 +198,7 @@ def update_hosted_entity( ) def is_sc_stale( - self, entity_name: HostableEntityName, /, hosts: Optional[Iterable[str]] + self, entity_name: EntityName, /, hosts: Optional[Iterable[str]] ) -> bool: """Whether a service or component is stale. diff --git a/tdp/core/collections/collections.py b/tdp/core/collections/collections.py index 05024b34..bb2d5eb1 100644 --- a/tdp/core/collections/collections.py +++ b/tdp/core/collections/collections.py @@ -17,7 +17,7 @@ from pathlib import Path from typing import TYPE_CHECKING, Optional -from tdp.core.entities.hostable_entity_name import ServiceComponentName +from tdp.core.entities.entity_name import ServiceComponentName from tdp.core.entities.operation import Operations, Playbook from tdp.core.inventory_reader import InventoryReader from tdp.core.operation import Operation diff --git a/tdp/core/deployment/deployment_iterator.py b/tdp/core/deployment/deployment_iterator.py index 241bd018..2b9ae781 100644 --- a/tdp/core/deployment/deployment_iterator.py +++ b/tdp/core/deployment/deployment_iterator.py @@ -11,7 +11,7 @@ from typing import TYPE_CHECKING, Optional from tdp.core.constants import OPERATION_SLEEP_NAME -from tdp.core.entities.hostable_entity_name import create_hostable_entity_name +from tdp.core.entities.entity_name import create_hostable_entity_name from tdp.core.entities.hosted_entity import create_hosted_entity from tdp.core.models import ( DeploymentModel, diff --git a/tdp/core/entities/hostable_entity_name.py b/tdp/core/entities/entity_name.py similarity index 94% rename from tdp/core/entities/hostable_entity_name.py rename to tdp/core/entities/entity_name.py index c69d59a0..62efac2e 100644 --- a/tdp/core/entities/hostable_entity_name.py +++ b/tdp/core/entities/entity_name.py @@ -11,7 +11,7 @@ @dataclass(frozen=True) -class HostableEntityName(ABC): +class EntityName(ABC): service: str @property @@ -33,7 +33,7 @@ def __str__(self): @dataclass(frozen=True) -class ServiceName(HostableEntityName): +class ServiceName(EntityName): @property def name(self) -> str: @@ -41,7 +41,7 @@ def name(self) -> str: @dataclass(frozen=True) -class ServiceComponentName(HostableEntityName): +class ServiceComponentName(EntityName): component: str def __post_init__(self): diff --git a/tdp/core/entities/hosted_entity.py b/tdp/core/entities/hosted_entity.py index 60c1c73d..bf73965c 100644 --- a/tdp/core/entities/hosted_entity.py +++ b/tdp/core/entities/hosted_entity.py @@ -5,8 +5,8 @@ from dataclasses import dataclass from typing import Optional, Union -from tdp.core.entities.hostable_entity_name import ( - HostableEntityName, +from tdp.core.entities.entity_name import ( + EntityName, ServiceComponentName, ServiceName, ) @@ -16,7 +16,7 @@ class HostedEntity(ABC): @property @abstractmethod - def name(self) -> HostableEntityName: + def name(self) -> EntityName: pass @property @@ -54,7 +54,7 @@ def host(self) -> Optional[str]: def create_hosted_entity( - name: HostableEntityName, host: Optional[str] + name: EntityName, host: Optional[str] ) -> Union[HostedService, HostedServiceComponent]: if isinstance(name, ServiceName): return HostedService(name, host) diff --git a/tdp/core/variables/service_variables.py b/tdp/core/variables/service_variables.py index bd6cb286..8d136049 100644 --- a/tdp/core/variables/service_variables.py +++ b/tdp/core/variables/service_variables.py @@ -19,7 +19,7 @@ ) if TYPE_CHECKING: - from tdp.core.entities.hostable_entity_name import HostableEntityName + from tdp.core.entities.entity_name import EntityName from tdp.core.repository.repository import Repository from tdp.core.variables.schema.service_schema import ServiceSchema from tdp.core.variables.variables import _VariablesIOWrapper @@ -141,9 +141,7 @@ def open_files( with self.repository.validate(validation_message) as repo: repo.add_for_validation(open_files.keys()) - def is_entity_modified_from_version( - self, entity: HostableEntityName, version: str - ) -> bool: + def is_entity_modified_from_version(self, entity: EntityName, version: str) -> bool: """Check if a component has been modified since the given version. A component is modified if the component variable file is modified diff --git a/tdp/dao.py b/tdp/dao.py index 78d4420a..82635726 100644 --- a/tdp/dao.py +++ b/tdp/dao.py @@ -7,7 +7,7 @@ from sqlalchemy.orm import aliased, sessionmaker from tdp.core.cluster_status import ClusterStatus -from tdp.core.entities.hostable_entity_name import create_hostable_entity_name +from tdp.core.entities.entity_name import create_hostable_entity_name from tdp.core.entities.hosted_entity import create_hosted_entity from tdp.core.entities.hosted_entity_status import HostedEntityStatus from tdp.core.models.deployment_model import DeploymentModel diff --git a/test_dag_order/helpers.py b/test_dag_order/helpers.py index f33de363..6a02c075 100644 --- a/test_dag_order/helpers.py +++ b/test_dag_order/helpers.py @@ -18,7 +18,7 @@ PathIsNotADirectoryError, ) from tdp.core.constants import YML_EXTENSION -from tdp.core.entities.hostable_entity_name import ( +from tdp.core.entities.entity_name import ( ServiceName, parse_hostable_entity_name, )