class_docstr: Helper class to handle metadata I/O.
  
  Not thread-safe without external synchronisation.
docstr: Updates the given execution in MLMD based on given information.
  
  All artifacts provided will be registered if not already. Registered id will
  be reflected inline.
  
  Args:
    execution: the execution to be updated. It is required that the execution
      passed in has an id.
    component_info: the information of the current running component
    input_artifacts: artifacts to be declared as inputs of the execution
    output_artifacts: artifacts to be declared as outputs of the execution
    exec_properties: execution properties of the execution
    execution_state: state the execution to be updated to
    artifact_state: state the artifacts to be updated to
    contexts: a list of contexts the execution and artifacts to be linked to
  
  Raises:
    RuntimeError: if the execution to be updated has no id.
docstr_tok: ["Updates","the","given","execution","in","MLMD","based","on","given","information",".","All","artifacts","provided","will","be","registered","if","not","already",".","Registered","id","will","be","reflected","inline",".","Args",":","execution",":","the","execution","to","be","updated",".","It","is","required","that","the","execution","passed","in","has","an","id",".","component_info",":","the","information","of","the","current","running","component","input_artifacts",":","artifacts","to","be","declared","as","inputs","of","the","execution","output_artifacts",":","artifacts","to","be","declared","as","outputs","of","the","execution","exec_properties",":","execution","properties","of","the","execution","execution_state",":","state","the","execution","to","be","updated","to","artifact_state",":","state","the","artifacts","to","be","updated","to","contexts",":","a","list","of","contexts","the","execution","and","artifacts","to","be","linked","to","Raises",":","RuntimeError",":","if","the","execution","to","be","updated","has","no","id","."]
code: def update_execution(
      self,
      execution: metadata_store_pb2.Execution,
      component_info: data_types.ComponentInfo,
      input_artifacts: Optional[Dict[str, List[_Artifact]]] = None,
      output_artifacts: Optional[Dict[str, List[_Artifact]]] = None,
      exec_properties: Optional[Dict[str, Any]] = None,
      execution_state: Optional[str] = None,
      artifact_state: Optional[str] = None,
      contexts: Optional[List[metadata_store_pb2.Context]] = None,
  ) -> None:
      """Updates the given execution in MLMD based on given information.
  
      All artifacts provided will be registered if not already. Registered id will
      be reflected inline.
  
      Args:
        execution: the execution to be updated. It is required that the execution
          passed in has an id.
        component_info: the information of the current running component
        input_artifacts: artifacts to be declared as inputs of the execution
        output_artifacts: artifacts to be declared as outputs of the execution
        exec_properties: execution properties of the execution
        execution_state: state the execution to be updated to
        artifact_state: state the artifacts to be updated to
        contexts: a list of contexts the execution and artifacts to be linked to
  
      Raises:
        RuntimeError: if the execution to be updated has no id.
      """
      if not execution.id:
          raise RuntimeError(
              "No id attached to the execution to be updated."
          )
      events = self.store.get_events_by_execution_ids([execution.id])
      registered_input_artifact_ids = set(
          e.artifact_id
          for e in events
          if e.type == metadata_store_pb2.Event.INPUT
      )
      registered_output_artifact_ids = set(
          e.artifact_id
          for e in events
          if e.type == metadata_store_pb2.Event.OUTPUT
      )
      artifacts_and_events = []
      if input_artifacts:
          artifacts_and_events.extend(
              self._artifact_and_event_pairs(
                  artifact_dict=input_artifacts,
                  event_type=metadata_store_pb2.Event.INPUT,
                  new_state=artifact_state,
                  registered_artifacts_ids=registered_input_artifact_ids,
              )
          )
      if output_artifacts:
          artifacts_and_events.extend(
              self._artifact_and_event_pairs(
                  artifact_dict=output_artifacts,
                  event_type=metadata_store_pb2.Event.OUTPUT,
                  new_state=artifact_state,
                  registered_artifacts_ids=registered_output_artifact_ids,
              )
          )
      # If execution properties change, we need to potentially update execution
      # schema.
      if exec_properties:
          execution.type_id = self._prepare_execution_type(
              component_info.component_type, exec_properties
          )
      if exec_properties or execution_state:
          self._update_execution_proto(
              execution=execution,
              exec_properties=exec_properties,
              state=execution_state,
              pipeline_info=component_info.pipeline_info,
              component_info=component_info,
          )
      _, a_ids, _ = self.store.put_execution(
          execution, artifacts_and_events, contexts or []
      )
      for artifact_and_event, a_id in zip(artifacts_and_events, a_ids):
          artifact_and_event[0].id = a_id
  
imports: import collections
  import copy
  import hashlib
  import itertools
  import os
  import random
  import time
  import types
  from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
  import absl
  from tfx.dsl.io import fileio
  from tfx.orchestration import data_types
  from tfx.orchestration.portable.mlmd import event_lib
  from tfx.types import artifact
  from tfx.types import artifact_utils
  import ml_metadata
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 19 for calling the Metadata obj's underlying member method code with example usage: obj.update_execution(execution, component_info, input_artifacts, output_artifacts, exec_properties, execution_state, artifact_state, contexts) without return types