def register_stack(self, key: str, stack: BaseStack) -> None: """Register a stack. Args: key: Unique key for the stack. stack: Stack to be registered. """ logger.debug(f"Registering stack with key {key}, details: " f"{stack.dict()}") # Check if the individual components actually exist. # TODO [ENG-190]: Add tests to check cases of registering a stack with a # non-existing individual component. We can also improve the error # logging for the CLI while we're at it. self.get_orchestrator(stack.orchestrator_name) self.get_artifact_store(stack.artifact_store_name) self.get_metadata_store(stack.metadata_store_name) if key in self.stacks: raise AlreadyExistsException( message=f"Stack `{key}` already exists!") # Add the mapping. self.stacks[key] = stack self.update()
def __init__(self, name: Text, _id: Text = None, *args, **kwargs): """ Construct the datasource Args: name (str): name of datasource schema (dict): schema of datasource _id: unique ID (for internal use) """ if _id: # Its loaded from config self._id = _id logger.debug(f'Datasource {name} loaded.') else: # If none, then this is assumed to be 'new'. Check dupes. all_names = Repository.get_instance().get_datasource_names() if any(d == name for d in all_names): raise AlreadyExistsException(name=name, resource_type='datasource') self._id = str(uuid4()) track(event=CREATE_DATASOURCE) logger.info(f'Datasource {name} created.') self.name = name self._immutable = False self._source = source_utils.resolve_class(self.__class__)
def register_orchestrator(self, key: str, orchestrator: "BaseOrchestrator") -> None: """Register an orchestrator. Args: orchestrator: Metadata store to be registered. key: Unique key for the orchestrator. """ logger.debug(f"Registering orchestrator with key {key}, details: " f"{orchestrator.dict()}") if key in self.orchestrator_map: raise AlreadyExistsException( message=f"Orchestrator `{key}` already exists!") # Add the mapping. orchestrator.update() source = source_utils.resolve_class(orchestrator.__class__) self.orchestrator_map[key] = UUIDSourceTuple(uuid=orchestrator.uuid, source=source) self.update()
def register_metadata_store(self, key: str, metadata_store: "BaseMetadataStore") -> None: """Register a metadata store. Args: metadata_store: Metadata store to be registered. key: Unique key for the metadata store. """ logger.debug(f"Registering metadata store with key {key}, details: " f"{metadata_store.dict()}") if key in self.metadata_store_map: raise AlreadyExistsException( message=f"Metadata store `{key}` already exists!") # Add the mapping. metadata_store.update() source = source_utils.resolve_class(metadata_store.__class__) self.metadata_store_map[key] = UUIDSourceTuple( uuid=metadata_store.uuid, source=source) self.update()
def register_artifact_store(self, key: str, artifact_store: "BaseArtifactStore") -> None: """Register an artifact store. Args: artifact_store: Artifact store to be registered. key: Unique key for the artifact store. """ logger.debug(f"Registering artifact store with key {key}, details: " f"{artifact_store.dict()}") if key in self.artifact_store_map: raise AlreadyExistsException( message=f"Artifact Store `{key}` already exists!") # Add the mapping. artifact_store.update() source = source_utils.resolve_class(artifact_store.__class__) self.artifact_store_map[key] = UUIDSourceTuple( uuid=artifact_store.uuid, source=source) self.update()
def _check_registered(self): if Repository.get_instance().get_pipeline_by_name( self.name) is not None: raise AlreadyExistsException(name=self.name, resource_type='pipeline')