class_docstr: This entity may change or be removed in a future release without warning.
  SQLAlchemy compliant backend store for tracking meta data for MLflow entities. MLflow
  supports the database dialects ``mysql``, ``mssql``, ``sqlite``, and ``postgresql``.
  As specified in the
  `SQLAlchemy docs <https://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls>`_ ,
  the database URI is expected in the format
  ``<dialect>+<driver>://<username>:<password>@<host>:<port>/<database>``. If you do not
  specify a driver, SQLAlchemy uses a dialect's default driver.
  
  This store interacts with SQL store using SQLAlchemy abstractions defined for MLflow entities.
  :py:class:`mlflow.store.model_registry.models.RegisteredModel` and
  :py:class:`mlflow.store.model_registry.models.ModelVersion`
docstr: Create a new model version from given source and run ID.
  
  :param name: Registered model name.
  :param source: URI indicating the location of the model artifacts.
  :param run_id: Run ID from MLflow tracking server that generated the model.
  :param tags: A list of :py:class:`mlflow.entities.model_registry.ModelVersionTag`
               instances associated with this model version.
  :param run_link: Link to the run from an MLflow tracking server that generated this model.
  :param description: Description of the version.
  :return: A single object of :py:class:`mlflow.entities.model_registry.ModelVersion`
           created in the backend.
docstr_tok: ["Create","a","new","model","version","from","given","source","and","run","ID",".",":","param","name",":","Registered","model","name",".",":","param","source",":","URI","indicating","the","location","of","the","model","artifacts",".",":","param","run_id",":","Run","ID","from","MLflow","tracking","server","that","generated","the","model",".",":","param","tags",":","A","list","of",":","py",":","class",":","`","mlflow.entities.model_registry.ModelVersionTag","`","instances","associated","with","this","model","version",".",":","param","run_link",":","Link","to","the","run","from","an","MLflow","tracking","server","that","generated","this","model",".",":","param","description",":","Description","of","the","version",".",":","return",":","A","single","object","of",":","py",":","class",":","`","mlflow.entities.model_registry.ModelVersion","`","created","in","the","backend","."]
code: def create_model_version(
      self,
      name,
      source,
      run_id=None,
      tags=None,
      run_link=None,
      description=None,
      local_model_path=None,
  ):
      """
      Create a new model version from given source and run ID.
  
      :param name: Registered model name.
      :param source: URI indicating the location of the model artifacts.
      :param run_id: Run ID from MLflow tracking server that generated the model.
      :param tags: A list of :py:class:`mlflow.entities.model_registry.ModelVersionTag`
                   instances associated with this model version.
      :param run_link: Link to the run from an MLflow tracking server that generated this model.
      :param description: Description of the version.
      :return: A single object of :py:class:`mlflow.entities.model_registry.ModelVersion`
               created in the backend.
      """
  
      def next_version(sql_registered_model):
          if sql_registered_model.model_versions:
              return (
                  max(
                      [
                          mv.version
                          for mv in sql_registered_model.model_versions
                      ]
                  )
                  + 1
              )
          else:
              return 1
  
      _validate_model_name(name)
      for tag in tags or []:
          _validate_model_version_tag(tag.key, tag.value)
      storage_location = source
      if urllib.parse.urlparse(source).scheme == "models":
          parsed_model_uri = _parse_model_uri(source)
          try:
              storage_location = self.get_model_version_download_uri(
                  parsed_model_uri.name, parsed_model_uri.version
              )
          except Exception as e:
              raise MlflowException(
                  f"Unable to fetch model from model URI source artifact location '{source}'."
                  f"Error: {e}"
              ) from e
      with self.ManagedSessionMaker() as session:
          creation_time = get_current_time_millis()
          for attempt in range(self.CREATE_MODEL_VERSION_RETRIES):
              try:
                  sql_registered_model = self._get_registered_model(
                      session, name
                  )
                  sql_registered_model.last_updated_time = creation_time
                  version = next_version(sql_registered_model)
                  model_version = SqlModelVersion(
                      name=name,
                      version=version,
                      creation_time=creation_time,
                      last_updated_time=creation_time,
                      source=source,
                      storage_location=storage_location,
                      run_id=run_id,
                      run_link=run_link,
                      description=description,
                  )
                  tags_dict = {}
                  for tag in tags or []:
                      tags_dict[tag.key] = tag.value
                  model_version.model_version_tags = [
                      SqlModelVersionTag(key=key, value=value)
                      for key, value in tags_dict.items()
                  ]
                  session.add_all([sql_registered_model, model_version])
                  session.flush()
                  return self._populate_model_version_aliases(
                      session, name, model_version.to_mlflow_entity()
                  )
              except sqlalchemy.exc.IntegrityError:
                  more_retries = (
                      self.CREATE_MODEL_VERSION_RETRIES - attempt - 1
                  )
                  _logger.info(
                      "Model Version creation error (name=%s) Retrying %s more time%s.",
                      name,
                      str(more_retries),
                      "s" if more_retries > 1 else "",
                  )
      raise MlflowException(
          f"Model Version creation error (name={name}). Giving up after "
          f"{self.CREATE_MODEL_VERSION_RETRIES} attempts."
      )
  
imports: import logging
  import urllib
  import sqlalchemy
  from sqlalchemy.future import select
  import mlflow.store.db.utils
  from mlflow.entities.model_registry.model_version_stages import ALL_STAGES, DEFAULT_STAGES_FOR_GET_LATEST_VERSIONS, STAGE_ARCHIVED, STAGE_DELETED_INTERNAL, get_canonical_stage
  from mlflow.exceptions import MlflowException
  from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE, INVALID_STATE, RESOURCE_ALREADY_EXISTS, RESOURCE_DOES_NOT_EXIST
  from mlflow.store.artifact.utils.models import _parse_model_uri
  from mlflow.store.entities.paged_list import PagedList
  from mlflow.store.model_registry import SEARCH_MODEL_VERSION_MAX_RESULTS_DEFAULT, SEARCH_MODEL_VERSION_MAX_RESULTS_THRESHOLD, SEARCH_REGISTERED_MODEL_MAX_RESULTS_DEFAULT, SEARCH_REGISTERED_MODEL_MAX_RESULTS_THRESHOLD
  from mlflow.store.model_registry.abstract_store import AbstractStore
  from mlflow.store.model_registry.dbmodels.models import SqlModelVersion, SqlModelVersionTag, SqlRegisteredModel, SqlRegisteredModelAlias, SqlRegisteredModelTag
  from mlflow.utils.search_utils import SearchModelUtils, SearchModelVersionUtils, SearchUtils
  from mlflow.utils.time import get_current_time_millis
  from mlflow.utils.uri import extract_db_type_from_uri
  from mlflow.utils.validation import _validate_model_alias_name, _validate_model_name, _validate_model_version, _validate_model_version_tag, _validate_registered_model_tag, _validate_tag_name
label_desc: Use image node_id 22 for calling the SqlAlchemyStore obj's underlying member method code with example usage: obj.create_model_version(name, source, run_id, tags, run_link, description, local_model_path) and returns: unknown, int, self