We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[DOC-FIX] No documentation body for mlflow.search_model_versions
### Willingness to contribute

No. I cannot contribute a documentation fix at this time.

### URL(s) with the issue

(https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.search_model_versions)

### Description of proposal (what needs changing)

There is no documentation body for mlflow. search_model_versions() unlike for mlflow.mlflow.search_registered_models().

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mlflow/tracking/_model_registry/fluent.py`
Content:
```
1 from mlflow.tracking.client import MlflowClient
2 from mlflow.exceptions import MlflowException
3 from mlflow.entities.model_registry import ModelVersion
4 from mlflow.entities.model_registry import RegisteredModel
5 from mlflow.protos.databricks_pb2 import RESOURCE_ALREADY_EXISTS, ALREADY_EXISTS, ErrorCode
6 from mlflow.store.artifact.runs_artifact_repo import RunsArtifactRepository
7 from mlflow.utils.logging_utils import eprint
8 from mlflow.utils import get_results_from_paginated_fn
9 from mlflow.tracking._model_registry import DEFAULT_AWAIT_MAX_SLEEP_SECONDS
10 from mlflow.store.model_registry import (
11     SEARCH_REGISTERED_MODEL_MAX_RESULTS_DEFAULT,
12     SEARCH_MODEL_VERSION_MAX_RESULTS_DEFAULT,
13 )
14 from typing import Any, Dict, Optional, List
15 
16 
17 def register_model(
18     model_uri,
19     name,
20     await_registration_for=DEFAULT_AWAIT_MAX_SLEEP_SECONDS,
21     *,
22     tags: Optional[Dict[str, Any]] = None,
23 ) -> ModelVersion:
24     """
25     Create a new model version in model registry for the model files specified by ``model_uri``.
26     Note that this method assumes the model registry backend URI is the same as that of the
27     tracking backend.
28 
29     :param model_uri: URI referring to the MLmodel directory. Use a ``runs:/`` URI if you want to
30                       record the run ID with the model in model registry. ``models:/`` URIs are
31                       currently not supported.
32     :param name: Name of the registered model under which to create a new model version. If a
33                  registered model with the given name does not exist, it will be created
34                  automatically.
35     :param await_registration_for: Number of seconds to wait for the model version to finish
36                             being created and is in ``READY`` status. By default, the function
37                             waits for five minutes. Specify 0 or None to skip waiting.
38     :param tags: A dictionary of key-value pairs that are converted into
39                  :py:class:`mlflow.entities.model_registry.ModelVersionTag` objects.
40     :return: Single :py:class:`mlflow.entities.model_registry.ModelVersion` object created by
41              backend.
42 
43     .. test-code-block:: python
44         :caption: Example
45 
46         import mlflow.sklearn
47         from mlflow.models import infer_signature
48         from sklearn.datasets import make_regression
49         from sklearn.ensemble import RandomForestRegressor
50 
51         mlflow.set_tracking_uri("sqlite:////tmp/mlruns.db")
52         params = {"n_estimators": 3, "random_state": 42}
53         X, y = make_regression(n_features=4, n_informative=2, random_state=0, shuffle=False)
54 
55         # Log MLflow entities
56         with mlflow.start_run() as run:
57             rfr = RandomForestRegressor(**params).fit(X, y)
58             signature = infer_signature(X, rfr.predict(X))
59             mlflow.log_params(params)
60             mlflow.sklearn.log_model(rfr, artifact_path="sklearn-model", signature=signature)
61 
62         model_uri = "runs:/{}/sklearn-model".format(run.info.run_id)
63         mv = mlflow.register_model(model_uri, "RandomForestRegressionModel")
64         print("Name: {}".format(mv.name))
65         print("Version: {}".format(mv.version))
66 
67     .. code-block:: text
68         :caption: Output
69 
70         Name: RandomForestRegressionModel
71         Version: 1
72     """
73     return _register_model(
74         model_uri=model_uri, name=name, await_registration_for=await_registration_for, tags=tags
75     )
76 
77 
78 def _register_model(
79     model_uri,
80     name,
81     await_registration_for=DEFAULT_AWAIT_MAX_SLEEP_SECONDS,
82     *,
83     tags: Optional[Dict[str, Any]] = None,
84     local_model_path=None,
85 ) -> ModelVersion:
86     client = MlflowClient()
87     try:
88         create_model_response = client.create_registered_model(name)
89         eprint(f"Successfully registered model '{create_model_response.name}'.")
90     except MlflowException as e:
91         if e.error_code in (
92             ErrorCode.Name(RESOURCE_ALREADY_EXISTS),
93             ErrorCode.Name(ALREADY_EXISTS),
94         ):
95             eprint(
96                 "Registered model '%s' already exists. Creating a new version of this model..."
97                 % name
98             )
99         else:
100             raise e
101 
102     run_id = None
103     source = model_uri
104     if RunsArtifactRepository.is_runs_uri(model_uri):
105         source = RunsArtifactRepository.get_underlying_uri(model_uri)
106         (run_id, _) = RunsArtifactRepository.parse_runs_uri(model_uri)
107 
108     create_version_response = client._create_model_version(
109         name=name,
110         source=source,
111         run_id=run_id,
112         tags=tags,
113         await_creation_for=await_registration_for,
114         local_model_path=local_model_path,
115     )
116     eprint(
117         f"Created version '{create_version_response.version}' of model "
118         f"'{create_version_response.name}'."
119     )
120     return create_version_response
121 
122 
123 def search_registered_models(
124     max_results: Optional[int] = None,
125     filter_string: Optional[str] = None,
126     order_by: Optional[List[str]] = None,
127 ) -> List[RegisteredModel]:
128     """
129     Search for registered models that satisfy the filter criteria.
130 
131     :param filter_string: Filter query string
132         (e.g., ``"name = 'a_model_name' and tag.key = 'value1'"``),
133         defaults to searching for all registered models. The following identifiers, comparators,
134         and logical operators are supported.
135 
136         Identifiers
137           - ``name``: registered model name.
138           - ``tags.<tag_key>``: registered model tag. If ``tag_key`` contains spaces, it must be
139             wrapped with backticks (e.g., ``"tags.`extra key`"``).
140 
141         Comparators
142           - ``=``: Equal to.
143           - ``!=``: Not equal to.
144           - ``LIKE``: Case-sensitive pattern match.
145           - ``ILIKE``: Case-insensitive pattern match.
146 
147         Logical operators
148           - ``AND``: Combines two sub-queries and returns True if both of them are True.
149 
150     :param max_results: If passed, specifies the maximum number of models desired. If not
151                         passed, all models will be returned.
152     :param order_by: List of column names with ASC|DESC annotation, to be used for ordering
153                      matching search results.
154     :return: A list of :py:class:`mlflow.entities.model_registry.RegisteredModel` objects
155              that satisfy the search expressions.
156 
157     .. test-code-block:: python
158         :caption: Example
159 
160         import mlflow
161         from sklearn.linear_model import LogisticRegression
162 
163         with mlflow.start_run():
164             mlflow.sklearn.log_model(
165                 LogisticRegression(),
166                 "Cordoba",
167                 registered_model_name="CordobaWeatherForecastModel",
168             )
169             mlflow.sklearn.log_model(
170                 LogisticRegression(),
171                 "Boston",
172                 registered_model_name="BostonWeatherForecastModel",
173             )
174 
175         # Get search results filtered by the registered model name
176         filter_string = "name = 'CordobaWeatherForecastModel'"
177         results = mlflow.search_registered_models(filter_string=filter_string)
178         print("-" * 80)
179         for res in results:
180             for mv in res.latest_versions:
181                 print("name={}; run_id={}; version={}".format(mv.name, mv.run_id, mv.version))
182 
183         # Get search results filtered by the registered model name that matches
184         # prefix pattern
185         filter_string = "name LIKE 'Boston%'"
186         results = mlflow.search_registered_models(filter_string=filter_string)
187         print("-" * 80)
188         for res in results:
189             for mv in res.latest_versions:
190                 print("name={}; run_id={}; version={}".format(mv.name, mv.run_id, mv.version))
191 
192         # Get all registered models and order them by ascending order of the names
193         results = mlflow.search_registered_models(order_by=["name ASC"])
194         print("-" * 80)
195         for res in results:
196             for mv in res.latest_versions:
197                 print("name={}; run_id={}; version={}".format(mv.name, mv.run_id, mv.version))
198 
199     .. code-block:: text
200         :caption: Output
201 
202         --------------------------------------------------------------------------------
203         name=CordobaWeatherForecastModel; run_id=248c66a666744b4887bdeb2f9cf7f1c6; version=1
204         --------------------------------------------------------------------------------
205         name=BostonWeatherForecastModel; run_id=248c66a666744b4887bdeb2f9cf7f1c6; version=1
206         --------------------------------------------------------------------------------
207         name=BostonWeatherForecastModel; run_id=248c66a666744b4887bdeb2f9cf7f1c6; version=1
208         name=CordobaWeatherForecastModel; run_id=248c66a666744b4887bdeb2f9cf7f1c6; version=1
209 
210     """
211 
212     def pagination_wrapper_func(number_to_get, next_page_token):
213         return MlflowClient().search_registered_models(
214             max_results=number_to_get,
215             filter_string=filter_string,
216             order_by=order_by,
217             page_token=next_page_token,
218         )
219 
220     return get_results_from_paginated_fn(
221         pagination_wrapper_func,
222         SEARCH_REGISTERED_MODEL_MAX_RESULTS_DEFAULT,
223         max_results,
224     )
225 
226 
227 def search_model_versions(
228     max_results: Optional[int] = None,
229     filter_string: Optional[str] = None,
230     order_by: Optional[List[str]] = None,
231 ) -> List[ModelVersion]:
232     def pagination_wrapper_func(number_to_get, next_page_token):
233         return MlflowClient().search_model_versions(
234             max_results=number_to_get,
235             filter_string=filter_string,
236             order_by=order_by,
237             page_token=next_page_token,
238         )
239 
240     return get_results_from_paginated_fn(
241         paginated_fn=pagination_wrapper_func,
242         max_results_per_page=SEARCH_MODEL_VERSION_MAX_RESULTS_DEFAULT,
243         max_results=max_results,
244     )
245
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mlflow/tracking/_model_registry/fluent.py b/mlflow/tracking/_model_registry/fluent.py
--- a/mlflow/tracking/_model_registry/fluent.py
+++ b/mlflow/tracking/_model_registry/fluent.py
@@ -229,6 +229,77 @@
     filter_string: Optional[str] = None,
     order_by: Optional[List[str]] = None,
 ) -> List[ModelVersion]:
+    """
+    Search for model versions that satisfy the filter criteria.
+
+    :param filter_string: Filter query string
+        (e.g., ``"name = 'a_model_name' and tag.key = 'value1'"``),
+        defaults to searching for all model versions. The following identifiers, comparators,
+        and logical operators are supported.
+
+        Identifiers
+          - ``name``: model name.
+          - ``source_path``: model version source path.
+          - ``run_id``: The id of the mlflow run that generates the model version.
+          - ``tags.<tag_key>``: model version tag. If ``tag_key`` contains spaces, it must be
+            wrapped with backticks (e.g., ``"tags.`extra key`"``).
+
+        Comparators
+          - ``=``: Equal to.
+          - ``!=``: Not equal to.
+          - ``LIKE``: Case-sensitive pattern match.
+          - ``ILIKE``: Case-insensitive pattern match.
+          - ``IN``: In a value list. Only ``run_id`` identifier supports ``IN`` comparator.
+
+        Logical operators
+          - ``AND``: Combines two sub-queries and returns True if both of them are True.
+
+    :param max_results: If passed, specifies the maximum number of models desired. If not
+                        passed, all models will be returned.
+    :param order_by: List of column names with ASC|DESC annotation, to be used for ordering
+                    matching search results.
+    :return: A list of :py:class:`mlflow.entities.model_registry.ModelVersion` objects
+            that satisfy the search expressions.
+
+    .. test-code-block:: python
+        :caption: Example
+
+        import mlflow
+        from sklearn.linear_model import LogisticRegression
+
+        for _ in range(2):
+            with mlflow.start_run():
+                mlflow.sklearn.log_model(
+                    LogisticRegression(),
+                    "Cordoba",
+                    registered_model_name="CordobaWeatherForecastModel",
+                )
+
+        # Get all versions of the model filtered by name
+        filter_string = "name = 'CordobaWeatherForecastModel'"
+        results = mlflow.search_model_versions(filter_string=filter_string)
+        print("-" * 80)
+        for res in results:
+            print("name={}; run_id={}; version={}".format(res.name, res.run_id, res.version))
+
+        # Get the version of the model filtered by run_id
+        filter_string = "run_id = 'ae9a606a12834c04a8ef1006d0cff779'"
+        results = mlflow.search_model_versions(filter_string=filter_string)
+        print("-" * 80)
+        for res in results:
+            print("name={}; run_id={}; version={}".format(res.name, res.run_id, res.version))
+
+    .. code-block:: text
+        :caption: Output
+
+        --------------------------------------------------------------------------------
+        name=CordobaWeatherForecastModel; run_id=ae9a606a12834c04a8ef1006d0cff779; version=2
+        name=CordobaWeatherForecastModel; run_id=d8f028b5fedf4faf8e458f7693dfa7ce; version=1
+        --------------------------------------------------------------------------------
+        name=CordobaWeatherForecastModel; run_id=ae9a606a12834c04a8ef1006d0cff779; version=2
+
+    """
+
     def pagination_wrapper_func(number_to_get, next_page_token):
         return MlflowClient().search_model_versions(
             max_results=number_to_get,

{"golden_diff": "diff --git a/mlflow/tracking/_model_registry/fluent.py b/mlflow/tracking/_model_registry/fluent.py\n--- a/mlflow/tracking/_model_registry/fluent.py\n+++ b/mlflow/tracking/_model_registry/fluent.py\n@@ -229,6 +229,77 @@\n     filter_string: Optional[str] = None,\n     order_by: Optional[List[str]] = None,\n ) -> List[ModelVersion]:\n+    \"\"\"\n+    Search for model versions that satisfy the filter criteria.\n+\n+    :param filter_string: Filter query string\n+        (e.g., ``\"name = 'a_model_name' and tag.key = 'value1'\"``),\n+        defaults to searching for all model versions. The following identifiers, comparators,\n+        and logical operators are supported.\n+\n+        Identifiers\n+          - ``name``: model name.\n+          - ``source_path``: model version source path.\n+          - ``run_id``: The id of the mlflow run that generates the model version.\n+          - ``tags.<tag_key>``: model version tag. If ``tag_key`` contains spaces, it must be\n+            wrapped with backticks (e.g., ``\"tags.`extra key`\"``).\n+\n+        Comparators\n+          - ``=``: Equal to.\n+          - ``!=``: Not equal to.\n+          - ``LIKE``: Case-sensitive pattern match.\n+          - ``ILIKE``: Case-insensitive pattern match.\n+          - ``IN``: In a value list. Only ``run_id`` identifier supports ``IN`` comparator.\n+\n+        Logical operators\n+          - ``AND``: Combines two sub-queries and returns True if both of them are True.\n+\n+    :param max_results: If passed, specifies the maximum number of models desired. If not\n+                        passed, all models will be returned.\n+    :param order_by: List of column names with ASC|DESC annotation, to be used for ordering\n+                    matching search results.\n+    :return: A list of :py:class:`mlflow.entities.model_registry.ModelVersion` objects\n+            that satisfy the search expressions.\n+\n+    .. test-code-block:: python\n+        :caption: Example\n+\n+        import mlflow\n+        from sklearn.linear_model import LogisticRegression\n+\n+        for _ in range(2):\n+            with mlflow.start_run():\n+                mlflow.sklearn.log_model(\n+                    LogisticRegression(),\n+                    \"Cordoba\",\n+                    registered_model_name=\"CordobaWeatherForecastModel\",\n+                )\n+\n+        # Get all versions of the model filtered by name\n+        filter_string = \"name = 'CordobaWeatherForecastModel'\"\n+        results = mlflow.search_model_versions(filter_string=filter_string)\n+        print(\"-\" * 80)\n+        for res in results:\n+            print(\"name={}; run_id={}; version={}\".format(res.name, res.run_id, res.version))\n+\n+        # Get the version of the model filtered by run_id\n+        filter_string = \"run_id = 'ae9a606a12834c04a8ef1006d0cff779'\"\n+        results = mlflow.search_model_versions(filter_string=filter_string)\n+        print(\"-\" * 80)\n+        for res in results:\n+            print(\"name={}; run_id={}; version={}\".format(res.name, res.run_id, res.version))\n+\n+    .. code-block:: text\n+        :caption: Output\n+\n+        --------------------------------------------------------------------------------\n+        name=CordobaWeatherForecastModel; run_id=ae9a606a12834c04a8ef1006d0cff779; version=2\n+        name=CordobaWeatherForecastModel; run_id=d8f028b5fedf4faf8e458f7693dfa7ce; version=1\n+        --------------------------------------------------------------------------------\n+        name=CordobaWeatherForecastModel; run_id=ae9a606a12834c04a8ef1006d0cff779; version=2\n+\n+    \"\"\"\n+\n     def pagination_wrapper_func(number_to_get, next_page_token):\n         return MlflowClient().search_model_versions(\n             max_results=number_to_get,\n", "issue": "[DOC-FIX] No documentation body for mlflow.search_model_versions\n### Willingness to contribute\n\nNo. I cannot contribute a documentation fix at this time.\n\n### URL(s) with the issue\n\n(https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.search_model_versions)\n\n### Description of proposal (what needs changing)\n\nThere is no documentation body for mlflow. search_model_versions() unlike for mlflow.mlflow.search_registered_models().\n", "before_files": [{"content": "from mlflow.tracking.client import MlflowClient\nfrom mlflow.exceptions import MlflowException\nfrom mlflow.entities.model_registry import ModelVersion\nfrom mlflow.entities.model_registry import RegisteredModel\nfrom mlflow.protos.databricks_pb2 import RESOURCE_ALREADY_EXISTS, ALREADY_EXISTS, ErrorCode\nfrom mlflow.store.artifact.runs_artifact_repo import RunsArtifactRepository\nfrom mlflow.utils.logging_utils import eprint\nfrom mlflow.utils import get_results_from_paginated_fn\nfrom mlflow.tracking._model_registry import DEFAULT_AWAIT_MAX_SLEEP_SECONDS\nfrom mlflow.store.model_registry import (\n    SEARCH_REGISTERED_MODEL_MAX_RESULTS_DEFAULT,\n    SEARCH_MODEL_VERSION_MAX_RESULTS_DEFAULT,\n)\nfrom typing import Any, Dict, Optional, List\n\n\ndef register_model(\n    model_uri,\n    name,\n    await_registration_for=DEFAULT_AWAIT_MAX_SLEEP_SECONDS,\n    *,\n    tags: Optional[Dict[str, Any]] = None,\n) -> ModelVersion:\n    \"\"\"\n    Create a new model version in model registry for the model files specified by ``model_uri``.\n    Note that this method assumes the model registry backend URI is the same as that of the\n    tracking backend.\n\n    :param model_uri: URI referring to the MLmodel directory. Use a ``runs:/`` URI if you want to\n                      record the run ID with the model in model registry. ``models:/`` URIs are\n                      currently not supported.\n    :param name: Name of the registered model under which to create a new model version. If a\n                 registered model with the given name does not exist, it will be created\n                 automatically.\n    :param await_registration_for: Number of seconds to wait for the model version to finish\n                            being created and is in ``READY`` status. By default, the function\n                            waits for five minutes. Specify 0 or None to skip waiting.\n    :param tags: A dictionary of key-value pairs that are converted into\n                 :py:class:`mlflow.entities.model_registry.ModelVersionTag` objects.\n    :return: Single :py:class:`mlflow.entities.model_registry.ModelVersion` object created by\n             backend.\n\n    .. test-code-block:: python\n        :caption: Example\n\n        import mlflow.sklearn\n        from mlflow.models import infer_signature\n        from sklearn.datasets import make_regression\n        from sklearn.ensemble import RandomForestRegressor\n\n        mlflow.set_tracking_uri(\"sqlite:////tmp/mlruns.db\")\n        params = {\"n_estimators\": 3, \"random_state\": 42}\n        X, y = make_regression(n_features=4, n_informative=2, random_state=0, shuffle=False)\n\n        # Log MLflow entities\n        with mlflow.start_run() as run:\n            rfr = RandomForestRegressor(**params).fit(X, y)\n            signature = infer_signature(X, rfr.predict(X))\n            mlflow.log_params(params)\n            mlflow.sklearn.log_model(rfr, artifact_path=\"sklearn-model\", signature=signature)\n\n        model_uri = \"runs:/{}/sklearn-model\".format(run.info.run_id)\n        mv = mlflow.register_model(model_uri, \"RandomForestRegressionModel\")\n        print(\"Name: {}\".format(mv.name))\n        print(\"Version: {}\".format(mv.version))\n\n    .. code-block:: text\n        :caption: Output\n\n        Name: RandomForestRegressionModel\n        Version: 1\n    \"\"\"\n    return _register_model(\n        model_uri=model_uri, name=name, await_registration_for=await_registration_for, tags=tags\n    )\n\n\ndef _register_model(\n    model_uri,\n    name,\n    await_registration_for=DEFAULT_AWAIT_MAX_SLEEP_SECONDS,\n    *,\n    tags: Optional[Dict[str, Any]] = None,\n    local_model_path=None,\n) -> ModelVersion:\n    client = MlflowClient()\n    try:\n        create_model_response = client.create_registered_model(name)\n        eprint(f\"Successfully registered model '{create_model_response.name}'.\")\n    except MlflowException as e:\n        if e.error_code in (\n            ErrorCode.Name(RESOURCE_ALREADY_EXISTS),\n            ErrorCode.Name(ALREADY_EXISTS),\n        ):\n            eprint(\n                \"Registered model '%s' already exists. Creating a new version of this model...\"\n                % name\n            )\n        else:\n            raise e\n\n    run_id = None\n    source = model_uri\n    if RunsArtifactRepository.is_runs_uri(model_uri):\n        source = RunsArtifactRepository.get_underlying_uri(model_uri)\n        (run_id, _) = RunsArtifactRepository.parse_runs_uri(model_uri)\n\n    create_version_response = client._create_model_version(\n        name=name,\n        source=source,\n        run_id=run_id,\n        tags=tags,\n        await_creation_for=await_registration_for,\n        local_model_path=local_model_path,\n    )\n    eprint(\n        f\"Created version '{create_version_response.version}' of model \"\n        f\"'{create_version_response.name}'.\"\n    )\n    return create_version_response\n\n\ndef search_registered_models(\n    max_results: Optional[int] = None,\n    filter_string: Optional[str] = None,\n    order_by: Optional[List[str]] = None,\n) -> List[RegisteredModel]:\n    \"\"\"\n    Search for registered models that satisfy the filter criteria.\n\n    :param filter_string: Filter query string\n        (e.g., ``\"name = 'a_model_name' and tag.key = 'value1'\"``),\n        defaults to searching for all registered models. The following identifiers, comparators,\n        and logical operators are supported.\n\n        Identifiers\n          - ``name``: registered model name.\n          - ``tags.<tag_key>``: registered model tag. If ``tag_key`` contains spaces, it must be\n            wrapped with backticks (e.g., ``\"tags.`extra key`\"``).\n\n        Comparators\n          - ``=``: Equal to.\n          - ``!=``: Not equal to.\n          - ``LIKE``: Case-sensitive pattern match.\n          - ``ILIKE``: Case-insensitive pattern match.\n\n        Logical operators\n          - ``AND``: Combines two sub-queries and returns True if both of them are True.\n\n    :param max_results: If passed, specifies the maximum number of models desired. If not\n                        passed, all models will be returned.\n    :param order_by: List of column names with ASC|DESC annotation, to be used for ordering\n                     matching search results.\n    :return: A list of :py:class:`mlflow.entities.model_registry.RegisteredModel` objects\n             that satisfy the search expressions.\n\n    .. test-code-block:: python\n        :caption: Example\n\n        import mlflow\n        from sklearn.linear_model import LogisticRegression\n\n        with mlflow.start_run():\n            mlflow.sklearn.log_model(\n                LogisticRegression(),\n                \"Cordoba\",\n                registered_model_name=\"CordobaWeatherForecastModel\",\n            )\n            mlflow.sklearn.log_model(\n                LogisticRegression(),\n                \"Boston\",\n                registered_model_name=\"BostonWeatherForecastModel\",\n            )\n\n        # Get search results filtered by the registered model name\n        filter_string = \"name = 'CordobaWeatherForecastModel'\"\n        results = mlflow.search_registered_models(filter_string=filter_string)\n        print(\"-\" * 80)\n        for res in results:\n            for mv in res.latest_versions:\n                print(\"name={}; run_id={}; version={}\".format(mv.name, mv.run_id, mv.version))\n\n        # Get search results filtered by the registered model name that matches\n        # prefix pattern\n        filter_string = \"name LIKE 'Boston%'\"\n        results = mlflow.search_registered_models(filter_string=filter_string)\n        print(\"-\" * 80)\n        for res in results:\n            for mv in res.latest_versions:\n                print(\"name={}; run_id={}; version={}\".format(mv.name, mv.run_id, mv.version))\n\n        # Get all registered models and order them by ascending order of the names\n        results = mlflow.search_registered_models(order_by=[\"name ASC\"])\n        print(\"-\" * 80)\n        for res in results:\n            for mv in res.latest_versions:\n                print(\"name={}; run_id={}; version={}\".format(mv.name, mv.run_id, mv.version))\n\n    .. code-block:: text\n        :caption: Output\n\n        --------------------------------------------------------------------------------\n        name=CordobaWeatherForecastModel; run_id=248c66a666744b4887bdeb2f9cf7f1c6; version=1\n        --------------------------------------------------------------------------------\n        name=BostonWeatherForecastModel; run_id=248c66a666744b4887bdeb2f9cf7f1c6; version=1\n        --------------------------------------------------------------------------------\n        name=BostonWeatherForecastModel; run_id=248c66a666744b4887bdeb2f9cf7f1c6; version=1\n        name=CordobaWeatherForecastModel; run_id=248c66a666744b4887bdeb2f9cf7f1c6; version=1\n\n    \"\"\"\n\n    def pagination_wrapper_func(number_to_get, next_page_token):\n        return MlflowClient().search_registered_models(\n            max_results=number_to_get,\n            filter_string=filter_string,\n            order_by=order_by,\n            page_token=next_page_token,\n        )\n\n    return get_results_from_paginated_fn(\n        pagination_wrapper_func,\n        SEARCH_REGISTERED_MODEL_MAX_RESULTS_DEFAULT,\n        max_results,\n    )\n\n\ndef search_model_versions(\n    max_results: Optional[int] = None,\n    filter_string: Optional[str] = None,\n    order_by: Optional[List[str]] = None,\n) -> List[ModelVersion]:\n    def pagination_wrapper_func(number_to_get, next_page_token):\n        return MlflowClient().search_model_versions(\n            max_results=number_to_get,\n            filter_string=filter_string,\n            order_by=order_by,\n            page_token=next_page_token,\n        )\n\n    return get_results_from_paginated_fn(\n        paginated_fn=pagination_wrapper_func,\n        max_results_per_page=SEARCH_MODEL_VERSION_MAX_RESULTS_DEFAULT,\n        max_results=max_results,\n    )\n", "path": "mlflow/tracking/_model_registry/fluent.py"}], "after_files": [{"content": "from mlflow.tracking.client import MlflowClient\nfrom mlflow.exceptions import MlflowException\nfrom mlflow.entities.model_registry import ModelVersion\nfrom mlflow.entities.model_registry import RegisteredModel\nfrom mlflow.protos.databricks_pb2 import RESOURCE_ALREADY_EXISTS, ALREADY_EXISTS, ErrorCode\nfrom mlflow.store.artifact.runs_artifact_repo import RunsArtifactRepository\nfrom mlflow.utils.logging_utils import eprint\nfrom mlflow.utils import get_results_from_paginated_fn\nfrom mlflow.tracking._model_registry import DEFAULT_AWAIT_MAX_SLEEP_SECONDS\nfrom mlflow.store.model_registry import (\n    SEARCH_REGISTERED_MODEL_MAX_RESULTS_DEFAULT,\n    SEARCH_MODEL_VERSION_MAX_RESULTS_DEFAULT,\n)\nfrom typing import Any, Dict, Optional, List\n\n\ndef register_model(\n    model_uri,\n    name,\n    await_registration_for=DEFAULT_AWAIT_MAX_SLEEP_SECONDS,\n    *,\n    tags: Optional[Dict[str, Any]] = None,\n) -> ModelVersion:\n    \"\"\"\n    Create a new model version in model registry for the model files specified by ``model_uri``.\n    Note that this method assumes the model registry backend URI is the same as that of the\n    tracking backend.\n\n    :param model_uri: URI referring to the MLmodel directory. Use a ``runs:/`` URI if you want to\n                      record the run ID with the model in model registry. ``models:/`` URIs are\n                      currently not supported.\n    :param name: Name of the registered model under which to create a new model version. If a\n                 registered model with the given name does not exist, it will be created\n                 automatically.\n    :param await_registration_for: Number of seconds to wait for the model version to finish\n                            being created and is in ``READY`` status. By default, the function\n                            waits for five minutes. Specify 0 or None to skip waiting.\n    :param tags: A dictionary of key-value pairs that are converted into\n                 :py:class:`mlflow.entities.model_registry.ModelVersionTag` objects.\n    :return: Single :py:class:`mlflow.entities.model_registry.ModelVersion` object created by\n             backend.\n\n    .. test-code-block:: python\n        :caption: Example\n\n        import mlflow.sklearn\n        from mlflow.models import infer_signature\n        from sklearn.datasets import make_regression\n        from sklearn.ensemble import RandomForestRegressor\n\n        mlflow.set_tracking_uri(\"sqlite:////tmp/mlruns.db\")\n        params = {\"n_estimators\": 3, \"random_state\": 42}\n        X, y = make_regression(n_features=4, n_informative=2, random_state=0, shuffle=False)\n\n        # Log MLflow entities\n        with mlflow.start_run() as run:\n            rfr = RandomForestRegressor(**params).fit(X, y)\n            signature = infer_signature(X, rfr.predict(X))\n            mlflow.log_params(params)\n            mlflow.sklearn.log_model(rfr, artifact_path=\"sklearn-model\", signature=signature)\n\n        model_uri = \"runs:/{}/sklearn-model\".format(run.info.run_id)\n        mv = mlflow.register_model(model_uri, \"RandomForestRegressionModel\")\n        print(\"Name: {}\".format(mv.name))\n        print(\"Version: {}\".format(mv.version))\n\n    .. code-block:: text\n        :caption: Output\n\n        Name: RandomForestRegressionModel\n        Version: 1\n    \"\"\"\n    return _register_model(\n        model_uri=model_uri, name=name, await_registration_for=await_registration_for, tags=tags\n    )\n\n\ndef _register_model(\n    model_uri,\n    name,\n    await_registration_for=DEFAULT_AWAIT_MAX_SLEEP_SECONDS,\n    *,\n    tags: Optional[Dict[str, Any]] = None,\n    local_model_path=None,\n) -> ModelVersion:\n    client = MlflowClient()\n    try:\n        create_model_response = client.create_registered_model(name)\n        eprint(f\"Successfully registered model '{create_model_response.name}'.\")\n    except MlflowException as e:\n        if e.error_code in (\n            ErrorCode.Name(RESOURCE_ALREADY_EXISTS),\n            ErrorCode.Name(ALREADY_EXISTS),\n        ):\n            eprint(\n                \"Registered model '%s' already exists. Creating a new version of this model...\"\n                % name\n            )\n        else:\n            raise e\n\n    run_id = None\n    source = model_uri\n    if RunsArtifactRepository.is_runs_uri(model_uri):\n        source = RunsArtifactRepository.get_underlying_uri(model_uri)\n        (run_id, _) = RunsArtifactRepository.parse_runs_uri(model_uri)\n\n    create_version_response = client._create_model_version(\n        name=name,\n        source=source,\n        run_id=run_id,\n        tags=tags,\n        await_creation_for=await_registration_for,\n        local_model_path=local_model_path,\n    )\n    eprint(\n        f\"Created version '{create_version_response.version}' of model \"\n        f\"'{create_version_response.name}'.\"\n    )\n    return create_version_response\n\n\ndef search_registered_models(\n    max_results: Optional[int] = None,\n    filter_string: Optional[str] = None,\n    order_by: Optional[List[str]] = None,\n) -> List[RegisteredModel]:\n    \"\"\"\n    Search for registered models that satisfy the filter criteria.\n\n    :param filter_string: Filter query string\n        (e.g., ``\"name = 'a_model_name' and tag.key = 'value1'\"``),\n        defaults to searching for all registered models. The following identifiers, comparators,\n        and logical operators are supported.\n\n        Identifiers\n          - ``name``: registered model name.\n          - ``tags.<tag_key>``: registered model tag. If ``tag_key`` contains spaces, it must be\n            wrapped with backticks (e.g., ``\"tags.`extra key`\"``).\n\n        Comparators\n          - ``=``: Equal to.\n          - ``!=``: Not equal to.\n          - ``LIKE``: Case-sensitive pattern match.\n          - ``ILIKE``: Case-insensitive pattern match.\n\n        Logical operators\n          - ``AND``: Combines two sub-queries and returns True if both of them are True.\n\n    :param max_results: If passed, specifies the maximum number of models desired. If not\n                        passed, all models will be returned.\n    :param order_by: List of column names with ASC|DESC annotation, to be used for ordering\n                     matching search results.\n    :return: A list of :py:class:`mlflow.entities.model_registry.RegisteredModel` objects\n             that satisfy the search expressions.\n\n    .. test-code-block:: python\n        :caption: Example\n\n        import mlflow\n        from sklearn.linear_model import LogisticRegression\n\n        with mlflow.start_run():\n            mlflow.sklearn.log_model(\n                LogisticRegression(),\n                \"Cordoba\",\n                registered_model_name=\"CordobaWeatherForecastModel\",\n            )\n            mlflow.sklearn.log_model(\n                LogisticRegression(),\n                \"Boston\",\n                registered_model_name=\"BostonWeatherForecastModel\",\n            )\n\n        # Get search results filtered by the registered model name\n        filter_string = \"name = 'CordobaWeatherForecastModel'\"\n        results = mlflow.search_registered_models(filter_string=filter_string)\n        print(\"-\" * 80)\n        for res in results:\n            for mv in res.latest_versions:\n                print(\"name={}; run_id={}; version={}\".format(mv.name, mv.run_id, mv.version))\n\n        # Get search results filtered by the registered model name that matches\n        # prefix pattern\n        filter_string = \"name LIKE 'Boston%'\"\n        results = mlflow.search_registered_models(filter_string=filter_string)\n        print(\"-\" * 80)\n        for res in results:\n            for mv in res.latest_versions:\n                print(\"name={}; run_id={}; version={}\".format(mv.name, mv.run_id, mv.version))\n\n        # Get all registered models and order them by ascending order of the names\n        results = mlflow.search_registered_models(order_by=[\"name ASC\"])\n        print(\"-\" * 80)\n        for res in results:\n            for mv in res.latest_versions:\n                print(\"name={}; run_id={}; version={}\".format(mv.name, mv.run_id, mv.version))\n\n    .. code-block:: text\n        :caption: Output\n\n        --------------------------------------------------------------------------------\n        name=CordobaWeatherForecastModel; run_id=248c66a666744b4887bdeb2f9cf7f1c6; version=1\n        --------------------------------------------------------------------------------\n        name=BostonWeatherForecastModel; run_id=248c66a666744b4887bdeb2f9cf7f1c6; version=1\n        --------------------------------------------------------------------------------\n        name=BostonWeatherForecastModel; run_id=248c66a666744b4887bdeb2f9cf7f1c6; version=1\n        name=CordobaWeatherForecastModel; run_id=248c66a666744b4887bdeb2f9cf7f1c6; version=1\n\n    \"\"\"\n\n    def pagination_wrapper_func(number_to_get, next_page_token):\n        return MlflowClient().search_registered_models(\n            max_results=number_to_get,\n            filter_string=filter_string,\n            order_by=order_by,\n            page_token=next_page_token,\n        )\n\n    return get_results_from_paginated_fn(\n        pagination_wrapper_func,\n        SEARCH_REGISTERED_MODEL_MAX_RESULTS_DEFAULT,\n        max_results,\n    )\n\n\ndef search_model_versions(\n    max_results: Optional[int] = None,\n    filter_string: Optional[str] = None,\n    order_by: Optional[List[str]] = None,\n) -> List[ModelVersion]:\n    \"\"\"\n    Search for model versions that satisfy the filter criteria.\n\n    :param filter_string: Filter query string\n        (e.g., ``\"name = 'a_model_name' and tag.key = 'value1'\"``),\n        defaults to searching for all model versions. The following identifiers, comparators,\n        and logical operators are supported.\n\n        Identifiers\n          - ``name``: model name.\n          - ``source_path``: model version source path.\n          - ``run_id``: The id of the mlflow run that generates the model version.\n          - ``tags.<tag_key>``: model version tag. If ``tag_key`` contains spaces, it must be\n            wrapped with backticks (e.g., ``\"tags.`extra key`\"``).\n\n        Comparators\n          - ``=``: Equal to.\n          - ``!=``: Not equal to.\n          - ``LIKE``: Case-sensitive pattern match.\n          - ``ILIKE``: Case-insensitive pattern match.\n          - ``IN``: In a value list. Only ``run_id`` identifier supports ``IN`` comparator.\n\n        Logical operators\n          - ``AND``: Combines two sub-queries and returns True if both of them are True.\n\n    :param max_results: If passed, specifies the maximum number of models desired. If not\n                        passed, all models will be returned.\n    :param order_by: List of column names with ASC|DESC annotation, to be used for ordering\n                    matching search results.\n    :return: A list of :py:class:`mlflow.entities.model_registry.ModelVersion` objects\n            that satisfy the search expressions.\n\n    .. test-code-block:: python\n        :caption: Example\n\n        import mlflow\n        from sklearn.linear_model import LogisticRegression\n\n        for _ in range(2):\n            with mlflow.start_run():\n                mlflow.sklearn.log_model(\n                    LogisticRegression(),\n                    \"Cordoba\",\n                    registered_model_name=\"CordobaWeatherForecastModel\",\n                )\n\n        # Get all versions of the model filtered by name\n        filter_string = \"name = 'CordobaWeatherForecastModel'\"\n        results = mlflow.search_model_versions(filter_string=filter_string)\n        print(\"-\" * 80)\n        for res in results:\n            print(\"name={}; run_id={}; version={}\".format(res.name, res.run_id, res.version))\n\n        # Get the version of the model filtered by run_id\n        filter_string = \"run_id = 'ae9a606a12834c04a8ef1006d0cff779'\"\n        results = mlflow.search_model_versions(filter_string=filter_string)\n        print(\"-\" * 80)\n        for res in results:\n            print(\"name={}; run_id={}; version={}\".format(res.name, res.run_id, res.version))\n\n    .. code-block:: text\n        :caption: Output\n\n        --------------------------------------------------------------------------------\n        name=CordobaWeatherForecastModel; run_id=ae9a606a12834c04a8ef1006d0cff779; version=2\n        name=CordobaWeatherForecastModel; run_id=d8f028b5fedf4faf8e458f7693dfa7ce; version=1\n        --------------------------------------------------------------------------------\n        name=CordobaWeatherForecastModel; run_id=ae9a606a12834c04a8ef1006d0cff779; version=2\n\n    \"\"\"\n\n    def pagination_wrapper_func(number_to_get, next_page_token):\n        return MlflowClient().search_model_versions(\n            max_results=number_to_get,\n            filter_string=filter_string,\n            order_by=order_by,\n            page_token=next_page_token,\n        )\n\n    return get_results_from_paginated_fn(\n        paginated_fn=pagination_wrapper_func,\n        max_results_per_page=SEARCH_MODEL_VERSION_MAX_RESULTS_DEFAULT,\n        max_results=max_results,\n    )\n", "path": "mlflow/tracking/_model_registry/fluent.py"}]}