class_docstr: Helper class to create a model with added dependency wheels from an existing registered model.
  The `wheeled` model contains all the model dependencies as wheels stored as model artifacts.
  .. note::
      This utility only operates on a model that has been registered to the Model Registry.
class_docstr_tok: ["Helper","class","to","create","a","model","with","added","dependency","wheels","from","an","existing","registered","model",".","The","`","wheeled","`","model","contains","all","the","model","dependencies","as","wheels","stored","as","model","artifacts",".","..","note",":",":","This","utility","only","operates","on","a","model","that","has","been","registered","to","the","Model","Registry","."]
docstr: Given an existing registered model, saves the model along with it's dependencies stored as
  wheels to a path on the local file system.
  
  This does not modify existing model behavior or existing model flavors. It simply downloads
  the model dependencies as wheels and modifies the requirements.txt and conda.yaml file to
  point to the downloaded wheels.
  
  The download_command defaults to downloading only binary packages using the
  `--only-binary=:all:` option. This behavior can be overridden using an environment
  variable `MLFLOW_WHEELED_MODEL_PIP_DOWNLOAD_OPTIONS`, which will allows setting
  different options such as `--prefer-binary`, `--no-binary`, etc.
  :param path: Local path where the model is to be saved.
  :param mlflow_model: The new :py:mod:`mlflow.models.Model` metadata file to store the
                       updated model metadata.
docstr_tok: ["Given","an","existing","registered","model",",","saves","the","model","along","with","it","'s","dependencies","stored","as","wheels","to","a","path","on","the","local","file","system",".","This","does","not","modify","existing","model","behavior","or","existing","model","flavors",".","It","simply","downloads","the","model","dependencies","as","wheels","and","modifies","the","requirements.txt","and","conda.yaml","file","to","point","to","the","downloaded","wheels",".","The","download_command","defaults","to","downloading","only","binary","packages","using","the","`","--","only-binary=",":","all",":","`","option",".","This","behavior","can","be","overridden","using","an","environment","variable","`","MLFLOW_WHEELED_MODEL_PIP_DOWNLOAD_OPTIONS","`",",","which","will","allows","setting","different","options","such","as","`","--","prefer-binary","`",",","`","--","no-binary","`",",","etc",".",":","param","path",":","Local","path","where","the","model","is","to","be","saved",".",":","param","mlflow_model",":","The","new",":","py",":","mod",":","`","mlflow.models.Model","`","metadata","file","to","store","the","updated","model","metadata","."]
code: def save_model(self, path, mlflow_model=None):
      """
      Given an existing registered model, saves the model along with it's dependencies stored as
      wheels to a path on the local file system.
  
      This does not modify existing model behavior or existing model flavors. It simply downloads
      the model dependencies as wheels and modifies the requirements.txt and conda.yaml file to
      point to the downloaded wheels.
  
      The download_command defaults to downloading only binary packages using the
      `--only-binary=:all:` option. This behavior can be overridden using an environment
      variable `MLFLOW_WHEELED_MODEL_PIP_DOWNLOAD_OPTIONS`, which will allows setting
      different options such as `--prefer-binary`, `--no-binary`, etc.
      :param path: Local path where the model is to be saved.
      :param mlflow_model: The new :py:mod:`mlflow.models.Model` metadata file to store the
                           updated model metadata.
      """
      from mlflow.pyfunc import ENV, FLAVOR_NAME, _extract_conda_env
  
      path = os.path.abspath(path)
      _validate_and_prepare_target_save_path(path)
  
      local_model_path = _download_artifact_from_uri(
          self._model_uri, output_path=path
      )
  
      wheels_dir = os.path.join(local_model_path, _WHEELS_FOLDER_NAME)
      pip_requirements_path = os.path.join(
          local_model_path, _REQUIREMENTS_FILE_NAME
      )
      model_metadata_path = os.path.join(
          local_model_path, MLMODEL_FILE_NAME
      )
  
      model_metadata = Model.load(model_metadata_path)
  
      # Check if the model file has `wheels` set to True
      if (
          model_metadata.__dict__.get(_WHEELS_FOLDER_NAME, None)
          is not None
      ):
          raise MlflowException(
              "Model libraries are already added", BAD_REQUEST
          )
  
      conda_env = _extract_conda_env(
          model_metadata.flavors.get(FLAVOR_NAME, {}).get(ENV, None)
      )
      conda_env_path = os.path.join(local_model_path, conda_env)
      if conda_env is None and not os.path.isfile(
          pip_requirements_path
      ):
          raise MlflowException(
              "Cannot add libraries for model with no logged dependencies.",
              BAD_REQUEST,
          )
  
      if not os.path.isfile(pip_requirements_path):
          self._create_pip_requirement(
              conda_env_path, pip_requirements_path
          )
  
      WheeledModel._download_wheels(
          pip_requirements_path=pip_requirements_path,
          dst_path=wheels_dir,
      )
  
      # Keep a copy of the original requirement.txt
      shutil.copy2(
          pip_requirements_path,
          os.path.join(local_model_path, _ORIGINAL_REQ_FILE_NAME),
      )
  
      # Update requirements.txt with wheels
      pip_deps = self._overwrite_pip_requirements_with_wheels(
          pip_requirements_path=pip_requirements_path,
          wheels_dir=wheels_dir,
      )
  
      # Update conda.yaml with wheels
      self._update_conda_env(pip_deps, conda_env_path)
  
      # Update MLModel File
      mlflow_model = self._update_mlflow_model(
          original_model_metadata=model_metadata,
          mlflow_model=mlflow_model,
      )
      mlflow_model.save(model_metadata_path)
      return mlflow_model
  
imports: import os
  import platform
  import shutil
  import subprocess
  import sys
  import yaml
  import mlflow
  from mlflow import MlflowClient
  from mlflow.environment_variables import MLFLOW_WHEELED_MODEL_PIP_DOWNLOAD_OPTIONS
  from mlflow.exceptions import MlflowException
  from mlflow.protos.databricks_pb2 import BAD_REQUEST
  from mlflow.pyfunc.model import MLMODEL_FILE_NAME, Model
  from mlflow.store.artifact.utils.models import _parse_model_uri, get_model_name_and_version
  from mlflow.tracking.artifact_utils import _download_artifact_from_uri
  from mlflow.utils.annotations import experimental
  from mlflow.utils.environment import _REQUIREMENTS_FILE_NAME, _get_pip_deps, _mlflow_additional_pip_env, _overwrite_pip_deps
  from mlflow.utils.model_utils import _validate_and_prepare_target_save_path
  from mlflow.utils.uri import get_databricks_profile_uri_from_artifact_uri
label_desc: Use image node_id 3 for calling the WheeledModel obj's underlying member method code with example usage: obj.save_model(path, mlflow_model) and returns: mlflow_model