Skip to content

Commit

Permalink
refactor: rename hostable entity name to entity name
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulFarault committed Nov 21, 2024
1 parent 8d7c668 commit 2bdf195
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tdp/cli/commands/vars/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
6 changes: 3 additions & 3 deletions tdp/core/cluster_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tdp/core/collections/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tdp/core/deployment/deployment_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


@dataclass(frozen=True)
class HostableEntityName(ABC):
class EntityName(ABC):
service: str

@property
Expand All @@ -33,15 +33,15 @@ def __str__(self):


@dataclass(frozen=True)
class ServiceName(HostableEntityName):
class ServiceName(EntityName):

@property
def name(self) -> str:
return self.service


@dataclass(frozen=True)
class ServiceComponentName(HostableEntityName):
class ServiceComponentName(EntityName):
component: str

def __post_init__(self):
Expand Down
8 changes: 4 additions & 4 deletions tdp/core/entities/hosted_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -16,7 +16,7 @@
class HostedEntity(ABC):
@property
@abstractmethod
def name(self) -> HostableEntityName:
def name(self) -> EntityName:
pass

@property
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions tdp/core/variables/service_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tdp/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test_dag_order/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down

0 comments on commit 2bdf195

Please sign in to comment.