コード例 #1
0
    def get_artifacts_by_context(
            self, context_id: int) -> List[metadata_store_pb2.Artifact]:
        """Gets all direct artifacts that a context attributes to.

    Args:
      context_id: The id of the querying context

    Returns:
      Artifacts attributing to the context.
    """
        request = metadata_store_service_pb2.GetArtifactsByContextRequest()
        request.context_id = context_id
        request.options.max_result_size = 100
        request.options.order_by_field.field = (
            metadata_store_pb2.ListOperationOptions.OrderByField.Field.
            CREATE_TIME)
        request.options.order_by_field.is_asc = False

        result = []
        while True:
            response = metadata_store_service_pb2.GetArtifactsByContextResponse(
            )
            self._call('GetArtifactsByContext', request, response)
            for x in response.artifacts:
                result.append(x)

            if not response.next_page_token:
                break

            request.options.next_page_token = response.next_page_token

        return result
コード例 #2
0
    def get_artifacts_by_context(
            self, context_id: int) -> List[metadata_store_pb2.Artifact]:
        """Gets all direct artifacts that a context attributes to.

    Args:
      context_id: The id of the querying context

    Returns:
      Artifacts attributing to the context.
    """
        request = metadata_store_service_pb2.GetArtifactsByContextRequest()
        request.context_id = context_id
        response = metadata_store_service_pb2.GetArtifactsByContextResponse()

        self._call('GetArtifactsByContext', request, response)
        result = []
        for x in response.artifacts:
            result.append(x)
        return result
コード例 #3
0
 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
     ]