tfx/orchestration/portable/input_resolution/mlmd_resolver/metadata_resolver.py [167:231]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      self,
      artifacts: List[metadata_store_pb2.Artifact],
      max_num_hops: int = _MAX_NUM_HOPS,
      filter_query: str = '',
      event_filter: Optional[Callable[[metadata_store_pb2.Event], bool]] = None,
  ) -> Dict[
      Union[str, int],
      List[Tuple[metadata_store_pb2.Artifact, metadata_store_pb2.ArtifactType]],
  ]:
    """Given a list of artifacts, get their provenance successor artifacts.

    For each provided artifact, treat it as a starting
    artifact and get artifacts that are connected to them within `max_num_hops`
    via a path in the downstream direction like:
    artifact_i -> INPUT_event -> execution_j -> OUTPUT_event -> artifact_k.

    A hop is defined as a jump to the next node following the path of node
    -> event -> next_node.
    For example, in the lineage graph artifact_1 -> event -> execution_1
    -> event -> artifact_2:
    artifact_2 is 2 hops away from artifact_1, and execution_1 is 1 hop away
    from artifact_1.

    Args:
        artifacts: a list of starting artifacts. At most 100 ids are supported.
          Returns empty result if `artifacts` is empty.
        max_num_hops: maximum number of hops performed for downstream tracing.
          `max_num_hops` cannot exceed 100 nor be negative.
        filter_query: a query string filtering downstream artifacts by their own
          attributes or the attributes of immediate neighbors. Please refer to
          go/mlmd-filter-query-guide for more detailed guidance. Note: if
          `filter_query` is specified and `max_num_hops` is 0, it's equivalent
          to getting filtered artifacts by artifact ids with `get_artifacts()`.
        event_filter: an optional callable object for filtering events in the
          paths towards the downstream artifacts. Only an event with
          `event_filter(event)` evaluated to True will be considered as valid
          and kept in the path.

    Returns:
      Mapping of artifact ids to a list of downstream artifacts.
    """
    if not artifacts:
      return {}

    # Precondition check.
    if len(artifacts) > _MAX_NUM_STARTING_NODES:
      raise ValueError(
          'Number of artifacts is larger than supported value of %d.'
          % _MAX_NUM_STARTING_NODES
      )
    if max_num_hops > _MAX_NUM_HOPS or max_num_hops < 0:
      raise ValueError(
          'Number of hops %d is larger than supported value of %d or is'
          ' negative.' % (max_num_hops, _MAX_NUM_HOPS)
      )

    internal_artifact_ids = [a.id for a in artifacts if not a.external_id]
    external_artifact_ids = [a.external_id for a in artifacts if a.external_id]
    if internal_artifact_ids and external_artifact_ids:
      raise ValueError(
          'Provided artifacts contain both internal and external artifacts. It'
          ' is not supported.'
      )

    if not external_artifact_ids:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



tfx/orchestration/portable/input_resolution/mlmd_resolver/metadata_resolver.py [462:526]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      self,
      artifacts: List[metadata_store_pb2.Artifact],
      max_num_hops: int = _MAX_NUM_HOPS,
      filter_query: str = '',
      event_filter: Optional[Callable[[metadata_store_pb2.Event], bool]] = None,
  ) -> Dict[
      Union[str, int],
      List[Tuple[metadata_store_pb2.Artifact, metadata_store_pb2.ArtifactType]],
  ]:
    """Given a list of artifacts, get their provenance ancestor artifacts.

    For each provided artifact, treat it as a starting
    artifact and get artifacts that are connected to them within `max_num_hops`
    via a path in the upstream direction like:
    artifact_i -> INPUT_event -> execution_j -> OUTPUT_event -> artifact_k.

    A hop is defined as a jump to the next node following the path of node
    -> event -> next_node.
    For example, in the lineage graph artifact_1 -> event -> execution_1
    -> event -> artifact_2:
    artifact_2 is 2 hops away from artifact_1, and execution_1 is 1 hop away
    from artifact_1.

    Args:
        artifacts: a list of starting artifacts. At most 100 ids are supported.
          Returns empty result if `artifacts` is empty.
        max_num_hops: maximum number of hops performed for upstream tracing.
          `max_num_hops` cannot exceed 100 nor be negative.
        filter_query: a query string filtering upstream artifacts by their own
          attributes or the attributes of immediate neighbors. Please refer to
          go/mlmd-filter-query-guide for more detailed guidance. Note: if
          `filter_query` is specified and `max_num_hops` is 0, it's equivalent
          to getting filtered artifacts by artifact ids with `get_artifacts()`.
        event_filter: an optional callable object for filtering events in the
          paths towards the upstream artifacts. Only an event with
          `event_filter(event)` evaluated to True will be considered as valid
          and kept in the path.

    Returns:
      Mapping of artifact ids to a list of upstream artifacts.
    """
    if not artifacts:
      return {}

    # Precondition check.
    if len(artifacts) > _MAX_NUM_STARTING_NODES:
      raise ValueError(
          'Number of artifacts is larger than supported value of %d.'
          % _MAX_NUM_STARTING_NODES
      )
    if max_num_hops > _MAX_NUM_HOPS or max_num_hops < 0:
      raise ValueError(
          'Number of hops %d is larger than supported value of %d or is'
          ' negative.' % (max_num_hops, _MAX_NUM_HOPS)
      )

    internal_artifact_ids = [a.id for a in artifacts if not a.external_id]
    external_artifact_ids = [a.external_id for a in artifacts if a.external_id]
    if internal_artifact_ids and external_artifact_ids:
      raise ValueError(
          'Provided artifacts contain both internal and external artifacts. It'
          ' is not supported.'
      )

    if not external_artifact_ids:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



