class_docstr: ModelCardToolkit provides utilities to generate a ModelCard.
  
  ModelCardToolkit is a tool for ML practitioners to create Model Cards,
  documentation for model information such as owners, use cases, training and
  evaluation data, performance, etc. A Model Card document can be displayed in
  output formats including HTML, Markdown, etc.
  
  The ModelCardToolkit includes an API designed for a human-in-the-loop process
  to elaborate the ModelCard. If model training is integrated with ML Metadata
  (e.g., TFX pipelines), the ModelCardToolkit can further populate ModelCard
  fields by extract metadata and lineage from the model's MLMD instance.
  
  The ModelCardToolkit organizes the ModelCard assets (e.g., structured data,
  plots, and UI templates) in a user-specified directory, and updates them
  incrementally via its API.
  
  
  Standard workflow:
  
  ```python
  import model_card_toolkit as mct
  
  # Initialize the Model Card Toolkit with a path to store generate assets
  model_card_dir_path = ...
  toolkit = mct.ModelCardToolkit(model_card_dir_path)
  
  # Initialize the ModelCard, which can be freely populated
  model_card = toolkit.scaffold_assets()
  model_card.model_details.name = 'My Model'
  
  # Write the model card data to a proto file
  toolkit.update_model_card(model_card)
  
  # Return the model card document as an HTML page
  html = toolkit.export_format()
  ```
class_docstr_tok: ["ModelCardToolkit","provides","utilities","to","generate","a","ModelCard",".","ModelCardToolkit","is","a","tool","for","ML","practitioners","to","create","Model","Cards",",","documentation","for","model","information","such","as","owners",",","use","cases",",","training","and","evaluation","data",",","performance",",","etc",".","A","Model","Card","document","can","be","displayed","in","output","formats","including","HTML",",","Markdown",",","etc",".","The","ModelCardToolkit","includes","an","API","designed","for","a","human-in-the-loop","process","to","elaborate","the","ModelCard",".","If","model","training","is","integrated","with","ML","Metadata","(","e.g.",",","TFX","pipelines",")",",","the","ModelCardToolkit","can","further","populate","ModelCard","fields","by","extract","metadata","and","lineage","from","the","model","'s","MLMD","instance",".","The","ModelCardToolkit","organizes","the","ModelCard","assets","(","e.g.",",","structured","data",",","plots",",","and","UI","templates",")","in","a","user-specified","directory",",","and","updates","them","incrementally","via","its","API",".","Standard","workflow",":","``","`","python","import","model_card_toolkit","as","mct","#","Initialize","the","Model","Card","Toolkit","with","a","path","to","store","generate","assets","model_card_dir_path","=","...","toolkit","=","mct.ModelCardToolkit","(","model_card_dir_path",")","#","Initialize","the","ModelCard",",","which","can","be","freely","populated","model_card","=","toolkit.scaffold_assets","(",")","model_card.model_details.name","=","'My","Model'","#","Write","the","model","card","data","to","a","proto","file","toolkit.update_model_card","(","model_card",")","#","Return","the","model","card","document","as","an","HTML","page","html","=","toolkit.export_format","(",")","``","`"]
docstr: Initializes the ModelCardToolkit.
  
  This function does not generate any assets by itself. Use the other API
  functions to generate Model Card assets. See class-level documentation for
  example usage.
  
  Args:
    output_dir: The path where MCT assets (such as data files and model cards)
      are written to. If not provided, a temp directory is used.
    mlmd_source: The ML Metadata Store to retrieve metadata and lineage
      information about the model. If given, a set of model card properties
      can be auto-populated from the `store`.
    source: A collection of sources to extract data for a model card. This can
      be used instead of `mlmd_source`, or alongside it. Useful when using
      tools like TensorFlow Model Analysis and Data Validation without writing
      to a MLMD store.
  
  Raises:
    ValueError: If a model cannot be found at mlmd_source.model_uri.
    ImportError: If a `source` or `mlmd_source` is provided but necessary
    extra dependencies are not installed.
docstr_tok: ["Initializes","the","ModelCardToolkit",".","This","function","does","not","generate","any","assets","by","itself",".","Use","the","other","API","functions","to","generate","Model","Card","assets",".","See","class-level","documentation","for","example","usage",".","Args",":","output_dir",":","The","path","where","MCT","assets","(","such","as","data","files","and","model","cards",")","are","written","to",".","If","not","provided",",","a","temp","directory","is","used",".","mlmd_source",":","The","ML","Metadata","Store","to","retrieve","metadata","and","lineage","information","about","the","model",".","If","given",",","a","set","of","model","card","properties","can","be","auto-populated","from","the","`","store","`",".","source",":","A","collection","of","sources","to","extract","data","for","a","model","card",".","This","can","be","used","instead","of","`","mlmd_source","`",",","or","alongside","it",".","Useful","when","using","tools","like","TensorFlow","Model","Analysis","and","Data","Validation","without","writing","to","a","MLMD","store",".","Raises",":","ValueError",":","If","a","model","can","not","be","found","at","mlmd_source.model_uri",".","ImportError",":","If","a","`","source","`","or","`","mlmd_source","`","is","provided","but","necessary","extra","dependencies","are","not","installed","."]
code: def __init__(
      self,
      output_dir: Optional[str] = None,
      mlmd_source: Optional[MlmdSource] = None,
      source: Optional[Source] = None,
  ):
      """Initializes the ModelCardToolkit.
  
      This function does not generate any assets by itself. Use the other API
      functions to generate Model Card assets. See class-level documentation for
      example usage.
  
      Args:
        output_dir: The path where MCT assets (such as data files and model cards)
          are written to. If not provided, a temp directory is used.
        mlmd_source: The ML Metadata Store to retrieve metadata and lineage
          information about the model. If given, a set of model card properties
          can be auto-populated from the `store`.
        source: A collection of sources to extract data for a model card. This can
          be used instead of `mlmd_source`, or alongside it. Useful when using
          tools like TensorFlow Model Analysis and Data Validation without writing
          to a MLMD store.
  
      Raises:
        ValueError: If a model cannot be found at mlmd_source.model_uri.
        ImportError: If a `source` or `mlmd_source` is provided but necessary
        extra dependencies are not installed.
      """
  
      if source or mlmd_source:
          dependencies.ensure_tensorflow_extra_deps_installed()
  
      self.output_dir = output_dir or tempfile.mkdtemp()
      self._mcta_proto_file = os.path.join(
          self.output_dir, _MCTA_PROTO_FILE
      )
      self._mcta_template_dir = os.path.join(
          self.output_dir, _MCTA_TEMPLATE_DIR
      )
      self.default_template = os.path.join(
          self._mcta_template_dir, _DEFAULT_UI_TEMPLATE_FILE
      )
      self._model_cards_dir = os.path.join(
          self.output_dir, _MODEL_CARDS_DIR
      )
      self._source = source
  
      # set in _process_mlmd_source()
      self._store = None
      self._artifact_with_model_uri = None
      if mlmd_source:
          self._process_mlmd_source(mlmd_source)
  
file_path: model-card-toolkit/model_card_toolkit/core.py
imports: import logging
  import os
  import pkgutil
  import tempfile
  from typing import Any, Dict, Optional, Union
  from model_card_toolkit import dependencies
  from model_card_toolkit.model_card import ModelCard, load_model_card
  from model_card_toolkit.proto import model_card_pb2
  from model_card_toolkit.utils import io_utils
label_desc: Use image node_id 1 to create a new ModelCardToolkit object  with example: obj = ModelCardToolkit(output_dir, mlmd_source, source)