class_docstr: An object which handles communicating with metadata db through MLMD.
class_docstr_tok: ["An","object","which","handles","communicating","with","metadata","db","through","MLMD","."]
docstr: Initializes a new MLMD connection instance.
  
  Args:
    phoenix_spec: PhoenixSpec proto.
    study_name: The name of the study.
    study_owner: The owner (username) of the study.
    optimization_goal: minimize or maximize (string).
    optimization_metric: what metric are we optimizing (string).
    connection_config: a metadata_store_pb2.ConnectionConfig() proto. If None,
      we fall back on the flags above.
docstr_tok: ["Initializes","a","new","MLMD","connection","instance",".","Args",":","phoenix_spec",":","PhoenixSpec","proto",".","study_name",":","The","name","of","the","study",".","study_owner",":","The","owner","(","username",")","of","the","study",".","optimization_goal",":","minimize","or","maximize","(","string",")",".","optimization_metric",":","what","metric","are","we","optimizing","(","string",")",".","connection_config",":","a","metadata_store_pb2.ConnectionConfig","(",")","proto",".","If","None",",","we","fall","back","on","the","flags","above","."]
code: def __init__(
      self,
      phoenix_spec,
      study_name,
      study_owner,
      optimization_goal="minimize",
      optimization_metric="loss",
      connection_config=None,
  ):
      """Initializes a new MLMD connection instance.
  
      Args:
        phoenix_spec: PhoenixSpec proto.
        study_name: The name of the study.
        study_owner: The owner (username) of the study.
        optimization_goal: minimize or maximize (string).
        optimization_metric: what metric are we optimizing (string).
        connection_config: a metadata_store_pb2.ConnectionConfig() proto. If None,
          we fall back on the flags above.
      """
      self._study_name = study_name
      self._study_owner = study_owner
      self._phoenix_spec = phoenix_spec
      self._optimization_goal = optimization_goal
      self._optimization_metric = optimization_metric
  
      self._connection_config = connection_config
      if not FLAGS.is_parsed():
          logging.error(
              "Flags are not parsed. Using default in file mlmd database."
              " Please run main with absl.app.run(main) to fix this. "
              "If running in distributed mode, this means that the "
              "trainers are not sharing information between one another."
          )
      if self._connection_config is None:
          if FLAGS.is_parsed() and FLAGS.mlmd_default_sqllite_filename:
              self._connection_config = (
                  metadata_store_pb2.ConnectionConfig()
              )
              self._connection_config.sqlite.filename_uri = (
                  FLAGS.mlmd_default_sqllite_filename
              )
              self._connection_config.sqlite.connection_mode = 3
          elif FLAGS.is_parsed() and FLAGS.mlmd_socket:
              self._connection_config = (
                  metadata_store_pb2.ConnectionConfig()
              )
              self._connection_config.mysql.socket = FLAGS.mlmd_socket
              self._connection_config.mysql.database = (
                  FLAGS.mlmd_database
              )
              self._connection_config.mysql.user = FLAGS.mlmd_user
              self._connection_config.mysql.password = (
                  FLAGS.mlmd_password
              )
          else:
              self._connection_config = (
                  metadata_store_pb2.ConnectionConfig()
              )
              self._connection_config.sqlite.filename_uri = (
                  "/tmp/filedb-%d" % random.randint(0, 1000000)
              )
              self._connection_config.sqlite.connection_mode = 3
      self._store = metadata_store.MetadataStore(
          self._connection_config
      )
  
      trial_type = metadata_store_pb2.ExecutionType()
      trial_type.name = "Trial"
      trial_type.properties["id"] = metadata_store_pb2.INT
      trial_type.properties["state"] = metadata_store_pb2.STRING
      trial_type.properties[
          "serialized_data"
      ] = metadata_store_pb2.STRING
      trial_type.properties["model_dir"] = metadata_store_pb2.STRING
      trial_type.properties["evaluation"] = metadata_store_pb2.STRING
      self._trial_type_id = self._store.put_execution_type(trial_type)
      self._trial_id_to_run_id = {}
  
file_path: model_search/model_search/metadata/ml_metadata_db.py
imports: import json
  import os
  import random
  from absl import flags
  from absl import logging
  from model_search.metadata import metadata
  from model_search.metadata import trial
  from ml_metadata import metadata_store
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 1 to create a new MLMetaData object from inherited base classes: metadata with example: obj = MLMetaData(phoenix_spec, study_name, study_owner, optimization_goal, optimization_metric, connection_config)