diff --git a/tdp/core/variables/cluster_variables.py b/tdp/core/variables/cluster_variables.py index 1379b896..2b7027ca 100644 --- a/tdp/core/variables/cluster_variables.py +++ b/tdp/core/variables/cluster_variables.py @@ -104,7 +104,7 @@ def initialize_cluster_variables( else: repo = repository_class.init(service_tdp_vars) schemas = collections.get_service_schema(service) - service_variables = ServiceVariables(service, repo, schemas) + service_variables = ServiceVariables(repo, schemas) cluster_variables[service] = service_variables try: @@ -155,9 +155,7 @@ def get_cluster_variables( if path.is_dir(): repo = repository_class(tdp_vars / path.name) schemas = collections.get_service_schema(path.stem) - cluster_variables[path.name] = ServiceVariables( - path.name, repo, schemas - ) + cluster_variables[path.name] = ServiceVariables(repo, schemas) cluster_variables = ClusterVariables(cluster_variables) diff --git a/tdp/core/variables/service_variables.py b/tdp/core/variables/service_variables.py index 2cb7d1c6..d7fc6cb2 100644 --- a/tdp/core/variables/service_variables.py +++ b/tdp/core/variables/service_variables.py @@ -43,7 +43,7 @@ def __repr__(self): class ServiceVariables: """Variables of a service.""" - def __init__(self, service_name: str, repository: Repository, schema: dict): + def __init__(self, repository: Repository, schema: dict): """Initialize a ServiceVariables object. Args: @@ -54,16 +54,16 @@ def __init__(self, service_name: str, repository: Repository, schema: dict): Raises: ValueError: If the service name is longer than SERVICE_NAME_MAX_LENGTH. """ - if len(service_name) > SERVICE_NAME_MAX_LENGTH: - raise ValueError(f"{service_name} is longer than {SERVICE_NAME_MAX_LENGTH}") - self._name = service_name self._repo = repository + # Check that the service name is not too long + if len(self.name) > SERVICE_NAME_MAX_LENGTH: + raise ValueError(f"{self.name} is longer than {SERVICE_NAME_MAX_LENGTH}") self._schema = schema @property def name(self) -> str: """Name of the service.""" - return self._name + return self.path.name @property def repository(self) -> Repository: