class_docstr: Helper class to handle metadata I/O.
  
  Not thread-safe without external synchronisation.
docstr: Prepares a context proto.
docstr_tok: ["Prepares","a","context","proto","."]
code: def _prepare_context(
      self,
      context_type_name: str,
      context_name: str,
      properties: Optional[Dict[str, Union[int, float, str]]] = None,
  ) -> metadata_store_pb2.Context:
      """Prepares a context proto."""
      # TODO(ruoyu): Centralize the type definition / mapping along with Artifact
      # property types.
      properties = properties or {}
      property_type_mapping = {
          int: metadata_store_pb2.INT,
          str: metadata_store_pb2.STRING,
          float: metadata_store_pb2.DOUBLE,
      }
      context_type_id = self._register_context_type_if_not_exist(
          context_type_name,
          dict(
              (k, property_type_mapping[type(v)])
              for k, v in properties.items()
          ),
      )
  
      context = metadata_store_pb2.Context(
          type_id=context_type_id, name=context_name
      )
      for k, v in properties.items():
          if isinstance(v, int):
              context.properties[k].int_value = v
          elif isinstance(v, str):
              context.properties[k].string_value = v
          elif isinstance(v, float):
              context.properties[k].double_value = v
          else:
              raise RuntimeError(
                  "Unexpected property type: %s" % type(v)
              )
      return context
  
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 28 for calling the Metadata obj's underlying member method code with example usage: obj._prepare_context(context_type_name, context_name, properties) and returns: context