def get_artifact_type(self, type_name): """Gets an artifact type by name. Args: type_name: the type with that name. Returns: The type with name type_name. Raises: tensorflow.errors.NotFoundError: if no type exists tensorflow.errors.InternalError: if query execution fails """ request = metadata_store_service_pb2.GetArtifactTypeRequest() request.type_name = type_name response = metadata_store_service_pb2.GetArtifactTypeResponse() self._swig_call(metadata_store_serialized.GetArtifactType, request, response) return response.artifact_type
def _get_artifacts_with_type_and_pipeline( self, type_name: Text, pipeline_name: Text) -> List[metadata_store_pb2.Artifact]: """Helper function returns artifacts of specified pipeline and type.""" # 1. Find the pipeline context according to its name. request = metadata_store_service_pb2.GetContextByTypeAndNameRequest( type_name=_CONTEXT_TYPE_PIPELINE, context_name=pipeline_name) pipeline_context = self._stub.GetContextByTypeAndName(request) # 2. Find the artifacts associated with the pipeline context. request = metadata_store_service_pb2.GetArtifactsByContextRequest( context_id=pipeline_context.context.id) artifacts_response = self._stub.GetArtifactsByContext(request) # 3. Find the specified artifact type id. artifact_type_request = metadata_store_service_pb2.GetArtifactTypeRequest( type_name=type_name) artifact_type = self._stub.GetArtifactType( artifact_type_request).artifact_type # 4. Filter the returned artifacts according to their types and return. return [ artifact for artifact in artifacts_response.artifacts if artifact.type_id == artifact_type.id ]