internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: mlflow/mlflow

Issue:
Typo fix: `infered_model_type` -> `inferred_model_type`
Fix `infered_model_type` to `inferred_model_type`.

https://github.com/mlflow/mlflow/blob/4b7c41e42d9fdb7f0e4c5d8937a8eb7296d22d1f/mlflow/models/evaluation/default_evaluator.py#L903-L908


Discussion:

Resolving patch:
diff --git a/mlflow/models/evaluation/default_evaluator.py b/mlflow/models/evaluation/default_evaluator.py
--- a/mlflow/models/evaluation/default_evaluator.py
+++ b/mlflow/models/evaluation/default_evaluator.py
@@ -900,12 +900,12 @@ def evaluate(
             self.metrics = dict()
             self.artifacts = {}
 
-            infered_model_type = _infer_model_type_by_labels(self.y)
+            inferred_model_type = _infer_model_type_by_labels(self.y)
 
-            if infered_model_type is not None and model_type != infered_model_type:
+            if inferred_model_type is not None and model_type != inferred_model_type:
                 _logger.warning(
                     f"According to the evaluation dataset label values, the model type looks like "
-                    f"{infered_model_type}, but you specified model type {model_type}. Please "
+                    f"{inferred_model_type}, but you specified model type {model_type}. Please "
                     f"verify that you set the `model_type` and `dataset` arguments correctly."
                 )
 


Test patch:
Repository: mlflow/mlflow

Issue:
[DOC-FIX] Mistake in the docs of mlflow.pytorch.autolog
### Willingness to contribute

Yes. I can contribute a documentation fix independently.

### URL(s) with the issue

https://www.mlflow.org/docs/latest/python_api/mlflow.pytorch.html#module-mlflow.pytorch

### Description of proposal (what needs changing)

Hi,

I found the small mistake in the example of `mlflow.pytorch.autolog`.

As shown under code, it calculated the accuracy comparing the loss and y (label).

```python
class MNISTModel(pl.LightningModule):
    def __init__(self):
        super(MNISTModel, self).__init__()
        self.l1 = torch.nn.Linear(28 * 28, 10)

    def forward(self, x):
        return torch.relu(self.l1(x.view(x.size(0), -1)))

    def training_step(self, batch, batch_nb):
        x, y = batch
        loss = F.cross_entropy(self(x), y)
        acc = accuracy(loss, y)

```

However, it raise the under error,

```
IndexError: tuple index out of range
```

The reason for this error is that it calculated the accuracy using the wrong values.
So, I think that it is better to fix the docs like under code.

```python
class MNISTModel(pl.LightningModule):
    def __init__(self):
        super(MNISTModel, self).__init__()
        self.l1 = torch.nn.Linear(28 * 28, 10)

    def forward(self, x):
        return torch.relu(self.l1(x.view(x.size(0), -1)))

    def training_step(self, batch, batch_nb):
        x, y = batch
        logits = self(x)
        loss = F.cross_entropy(logits, y)
        pred = logits.argmax(dim=1)
        acc = accuracy(pred, y)
```


If I am right, I'm going to open PR.
Thanks! 


Discussion:
@comojin1994 Thank you for pointing this out! We would be very excited to review a PR that fixes this issue. Thank you in advance for your contribution!

Resolving patch:
diff --git a/mlflow/pytorch/__init__.py b/mlflow/pytorch/__init__.py
--- a/mlflow/pytorch/__init__.py
+++ b/mlflow/pytorch/__init__.py
@@ -964,8 +964,10 @@ def forward(self, x):
 
             def training_step(self, batch, batch_nb):
                 x, y = batch
-                loss = F.cross_entropy(self(x), y)
-                acc = accuracy(loss, y)
+                logits = self(x)
+                loss = F.cross_entropy(logits, y)
+                pred = logits.argmax(dim=1)
+                acc = accuracy(pred, y)
 
                 # Use the current of PyTorch logger
                 self.log("train_loss", loss, on_epoch=True)


Test patch:
Repository: mlflow/mlflow

Issue:
Enable `useless-object-inheritance` for pylint
### Task

Enable `useless-object-inheritance` for pylint to prevent useless object inheritance:
https://pylint.pycqa.org/en/latest/user_guide/messages/refactor/useless-object-inheritance.html

### Lines that need to be changed

https://github.com/mlflow/mlflow/blob/4f5d3f095da9ed6699941d8aacb9925488ff2fb5/pylintrc#L174-L177



Discussion:

Resolving patch:
diff --git a/mlflow/_spark_autologging.py b/mlflow/_spark_autologging.py
--- a/mlflow/_spark_autologging.py
+++ b/mlflow/_spark_autologging.py
@@ -169,7 +169,7 @@ def _get_repl_id():
     return "PythonSubscriber[{filename}][{id}]".format(filename=main_file, id=uuid.uuid4().hex)
 
 
-class PythonSubscriber(object, metaclass=ExceptionSafeClass):
+class PythonSubscriber(metaclass=ExceptionSafeClass):
     """
     Subscriber, intended to be instantiated once per Python process, that logs Spark table
     information propagated from Java to the current MLflow run, starting a run if necessary.
diff --git a/mlflow/tracking/default_experiment/abstract_context.py b/mlflow/tracking/default_experiment/abstract_context.py
--- a/mlflow/tracking/default_experiment/abstract_context.py
+++ b/mlflow/tracking/default_experiment/abstract_context.py
@@ -1,7 +1,7 @@
 from abc import ABCMeta, abstractmethod
 
 
-class DefaultExperimentProvider(object):
+class DefaultExperimentProvider:
     """
     Abstract base class for objects that provide the ID of an MLflow Experiment based on the
     current client context. For example, when the MLflow client is running in a Databricks Job,
diff --git a/mlflow/tracking/default_experiment/registry.py b/mlflow/tracking/default_experiment/registry.py
--- a/mlflow/tracking/default_experiment/registry.py
+++ b/mlflow/tracking/default_experiment/registry.py
@@ -23,7 +23,7 @@
 )
 
 
-class DefaultExperimentProviderRegistry(object):
+class DefaultExperimentProviderRegistry:
     """Registry for default experiment provider implementations
 
     This class allows the registration of default experiment providers, which are used to provide


Test patch:
Repository: mlflow/mlflow

Issue:
[DOC-FIX] Fix documentation bug for MlflowClient.search_runs()
### 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.tracking.html#mlflow.tracking.MlflowClient.search_runs



### Description of proposal (what needs changing)

Is now: Search experiments that fit the search criteria.

Shoud be: Search runs in the specified experiment IDs that fit the search criteria.


Discussion:

Resolving patch:
diff --git a/mlflow/tracking/client.py b/mlflow/tracking/client.py
--- a/mlflow/tracking/client.py
+++ b/mlflow/tracking/client.py
@@ -1646,7 +1646,7 @@ def search_runs(
         page_token: Optional[str] = None,
     ) -> PagedList[Run]:
         """
-        Search experiments that fit the search criteria.
+        Search for Runs that fit the specified criteria.
 
         :param experiment_ids: List of experiment IDs, or a single int or string id.
         :param filter_string: Filter query string, defaults to searching all runs.
diff --git a/mlflow/tracking/fluent.py b/mlflow/tracking/fluent.py
--- a/mlflow/tracking/fluent.py
+++ b/mlflow/tracking/fluent.py
@@ -1334,7 +1334,7 @@ def search_runs(
     experiment_names: Optional[List[str]] = None,
 ) -> Union[List[Run], "pandas.DataFrame"]:
     """
-    Get a pandas DataFrame of runs that fit the search criteria.
+    Search for Runs that fit the specified criteria.
 
     :param experiment_ids: List of experiment IDs. Search can work with experiment IDs or
                            experiment names, but not both in the same call. Values other than


Test patch:
Repository: mlflow/mlflow

Issue:
Remove useless `os.system` calls
We can remove the following useless `os.system` calls:

https://github.com/mlflow/mlflow/blob/f15aa399c0fab866e95b54dab858b794a760cfe5/mlflow/models/container/__init__.py#L190-L192

https://github.com/mlflow/mlflow/blob/bd56ed75f776cbfaf4bb8b4c5f204d59acbe6fc6/mlflow/models/docker_utils.py#L193


Discussion:

Resolving patch:
diff --git a/mlflow/models/container/__init__.py b/mlflow/models/container/__init__.py
--- a/mlflow/models/container/__init__.py
+++ b/mlflow/models/container/__init__.py
@@ -187,9 +187,6 @@ def _serve_pyfunc(model, env_manager):
         procs.append(nginx)
 
     cpu_count = multiprocessing.cpu_count()
-    os.system("pip -V")
-    os.system("python -V")
-    os.system('python -c"from mlflow.version import VERSION as V; print(V)"')
 
     inference_server = mlserver if enable_mlserver else scoring_server
     # Since MLServer will run without NGINX, expose the server in the `8080`
diff --git a/mlflow/models/docker_utils.py b/mlflow/models/docker_utils.py
--- a/mlflow/models/docker_utils.py
+++ b/mlflow/models/docker_utils.py
@@ -190,7 +190,6 @@ def _build_image(
                 )
             )
         _logger.info("Building docker image with name %s", image_name)
-        os.system("find {cwd}/".format(cwd=cwd))
         _build_image_from_context(context_dir=cwd, image_name=image_name)
 
 


Test patch:
Repository: mlflow/mlflow

Issue:
[DOC-FIX] MLFLOW_TRACKING_AWS_SIGV4 environment variable does not appear in the python API docs
### Willingness to contribute

Yes. I can contribute a documentation fix independently.

### URL(s) with the issue

https://www.mlflow.org/docs/latest/python_api/mlflow.environment_variables.html

### Description of proposal (what needs changing)

Fix the doc-string in `mlflow.environment_variables` to ensure the documentation compiles correctly (there is a missing semicolon)


Discussion:

Resolving patch:
diff --git a/mlflow/environment_variables.py b/mlflow/environment_variables.py
--- a/mlflow/environment_variables.py
+++ b/mlflow/environment_variables.py
@@ -86,8 +86,8 @@ def get(self):
 MLFLOW_HTTP_REQUEST_TIMEOUT = _EnvironmentVariable("MLFLOW_HTTP_REQUEST_TIMEOUT", int, 120)
 
 #: Specifies whether MLFlow HTTP requests should be signed using AWS signature V4. It will overwrite
-#: (default: ``False``). When set, it will overwrite the "Authorization" HTTP header
-# See https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html for more information.
+#: (default: ``False``). When set, it will overwrite the "Authorization" HTTP header.
+#: See https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html for more information.
 MLFLOW_TRACKING_AWS_SIGV4 = _BooleanEnvironmentVariable("MLFLOW_TRACKING_AWS_SIGV4", False)
 
 #: Specifies the chunk size to use when downloading a file from GCS


Test patch:
Repository: mlflow/mlflow

Issue:
Convert `. code-block:: python` to `.. test-code-block:: python` in `mlflow/tracking/_model_registry/fluent.py`
See #7457 for more information.


Discussion:
cc @tsugumi-sys if you're interestd in working on this.
Thanks! Got it:)

Resolving patch:
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
@@ -37,7 +37,7 @@ def register_model(
     :return: Single :py:class:`mlflow.entities.model_registry.ModelVersion` object created by
              backend.
 
-    .. code-block:: python
+    .. test-code-block:: python
         :caption: Example
 
         import mlflow.sklearn


Test patch:
Repository: mlflow/mlflow

Issue:
get_metric_history does not work
This calling code https://github.com/mlflow/mlflow/blob/aef0936a4bbc3e56519e3c64bb60701f0114095c/mlflow/tracking/_tracking_service/client.py#L88 expects a dict of the token and the list while the called function just gives the pure list, so line 94 will always fail.


Discussion:
@birkhola Thanks for reporting this issue. 

```python
import mlflow


with mlflow.start_run() as run:
    mlflow.log_metric("m", 1)

print(mlflow.MlflowClient().get_metric_history(run.info.run_id, "non-exisitng-metric"))
```

can reproduce the issue. I'll file a PR.

Resolving patch:
diff --git a/mlflow/store/tracking/file_store.py b/mlflow/store/tracking/file_store.py
--- a/mlflow/store/tracking/file_store.py
+++ b/mlflow/store/tracking/file_store.py
@@ -773,7 +773,7 @@ def get_metric_history(self, run_id, metric_key, max_results=None, page_token=No
 
         parent_path, metric_files = self._get_run_files(run_info, "metric")
         if metric_key not in metric_files:
-            return []
+            return PagedList([], None)
         return PagedList(
             [
                 FileStore._get_metric_from_line(metric_key, line)


Test patch:
diff --git a/tests/store/tracking/test_file_store.py b/tests/store/tracking/test_file_store.py
--- a/tests/store/tracking/test_file_store.py
+++ b/tests/store/tracking/test_file_store.py
@@ -23,6 +23,7 @@
     RunData,
     ExperimentTag,
 )
+from mlflow.store.entities.paged_list import PagedList
 from mlflow.exceptions import MlflowException, MissingConfigException
 from mlflow.store.tracking import SEARCH_MAX_RESULTS_DEFAULT
 from mlflow.store.tracking.file_store import FileStore
@@ -1787,4 +1788,5 @@ def test_get_metric_history_on_non_existent_metric_key(self):
         run = self._create_run(file_store)
         run_id = run.info.run_id
         test_metrics = file_store.get_metric_history(run_id, "test_metric")
+        assert isinstance(test_metrics, PagedList)
         assert test_metrics == []
Repository: mlflow/mlflow

Issue:
[DOC-FIX] 404 links
### Willingness to contribute

Yes. I would be willing to contribute a document fix with guidance from the MLflow community.

### URL(s) with the issue

The examples link leads to a 404 in Github. The link appears at least here https://mlflow.org/docs/latest/python_api/mlflow.tensorflow.html#mlflow.tensorflow.autolog and (twice) here https://mlflow.org/docs/latest/tracking.html#keras  
The link itself is https://github.com/mlflow/mlflow/tree/master/examples/tensorflow  



### Description of proposal (what needs changing)

Either a) the links to Tensorflow examples need to be removed, b) the links should only point to Keras examples, or c) there needs to be specific Tensorflow examples.

And the docs probably need some kind of check for 404s in the outgoing links when they compile. But you probably have that already.


Discussion:
@grofte Thanks for catching the issue. Which page contains 404 links?
Hi @harupy 

The docs link to https://github.com/mlflow/mlflow/tree/master/examples/tensorflow which is a 404. But that's a page controlled by MLflow so you can either stop pointing to it or add something there.

The first place the MLflow docs link to that page are https://mlflow.org/docs/latest/tracking.html#keras (specifically in the text "See example usages with [Keras](https://github.com/mlflow/mlflow/tree/master/examples/keras) and [TensorFlow](https://github.com/mlflow/mlflow/tree/master/examples/tensorflow)." and "As an example, try running the [MLflow TensorFlow examples](https://github.com/mlflow/mlflow/tree/master/examples/tensorflow).")

The second place is https://mlflow.org/docs/latest/python_api/mlflow.tensorflow.html#mlflow.tensorflow.autolog (specifically in "As an example, try running the [TensorFlow examples](https://github.com/mlflow/mlflow/tree/master/examples/tensorflow).")

And there may be more places of course. I don't know where to search the docs source.
@grofte Understood, can we replace the broken link with https://github.com/mlflow/mlflow/blob/master/examples/keras/train.py?

Would you be interested in filing a PR to fix this?
Sure. I would probably name it Keras/Tensorflow instead.

I can make a PR but like I said I can't even find the source for the docs right now.
I think you can just search https://github.com/mlflow/mlflow/tree/master/examples/tensorflow:
https://github.com/mlflow/mlflow/search?q=https%3A%2F%2Fgithub.com%2Fmlflow%2Fmlflow%2Ftree%2Fmaster%2Fexamples%2Ftensorflow

Resolving patch:
diff --git a/mlflow/tensorflow/__init__.py b/mlflow/tensorflow/__init__.py
--- a/mlflow/tensorflow/__init__.py
+++ b/mlflow/tensorflow/__init__.py
@@ -982,7 +982,7 @@ def autolog(
     Enables autologging for ``tf.keras`` and ``keras``.
     Note that only ``tensorflow>=2.3`` are supported.
     As an example, try running the
-    `TensorFlow examples <https://github.com/mlflow/mlflow/tree/master/examples/tensorflow>`_.
+    `Keras/TensorFlow example <https://github.com/mlflow/mlflow/blob/master/examples/keras/train.py>`_.
 
     For each TensorFlow module, autologging captures the following information:
 


Test patch:
Repository: mlflow/mlflow

Issue:
[DOC-FIX]
### Willingness to contribute

Yes. I can contribute a documentation fix independently.

### URL(s) with the issue

https://mlflow.org/docs/latest/models.html#model-signature-and-input-example

### Description of proposal (what needs changing)

The current typing for `ColSpec` goes as follow:
```
    def __init__(
        self, type: DataType, name: Optional[str] = None  # pylint: disable=redefined-builtin
    ):
```
As such, the examples of the documentation are confusing, because they go against the specified typing of the method (one shouldn't be able to pass `"double"` but `DataType.double` instead, for instance.

In view of the implementation of `__init__`, there is a clear intent to support strings as well. But the typing is against.

There should be a documentation update if `DataType` is meant to be the correct type, or else a doc-string update together with a typing update, if `str` is explicitly allowed:
```
type: Union[DataType, str]
```
for example (likely with a doc-string explanation that the intent of `str` is to refer to one of the key supported in `DataType`). The documentation online should make it explicit too.


Discussion:
@Judekeyser `Union[DataType, str]` sounds good to me, looking forward to your PR!
OOps, I ticked the wrong box ; but it's okay I guess I can do that ; 

Resolving patch:
diff --git a/mlflow/types/schema.py b/mlflow/types/schema.py
--- a/mlflow/types/schema.py
+++ b/mlflow/types/schema.py
@@ -69,7 +69,9 @@ class ColSpec:
     """
 
     def __init__(
-        self, type: DataType, name: Optional[str] = None  # pylint: disable=redefined-builtin
+        self,
+        type: Union[DataType, str],  # pylint: disable=redefined-builtin
+        name: Optional[str] = None,
     ):
         self._name = name
         try:


Test patch:
Repository: mlflow/mlflow

Issue:
[DOC-FIX]
### 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.set_experiment

### Description of proposal (what needs changing)

Explicitly following the Python API for the mlflow.set_experiment() function using the experiment_name parameter to create a new experiment produced the following error for me on Azure Databricks:

RestException: INVALID_PARAMETER_VALUE: Got an invalid experiment name 'correlation_threshold_efx_corev2'. An experiment name must be an absolute path within the Databricks workspace,

Nothing in the description of set_experiment says anything about name needing to be a valid path, and the example experiment name is simply a string "Social NLP Experiments".

Someone using mlflow for the first time should be given sufficient information to write code that will successfully execute. If name is a string on some platforms but a path on other platforms, a sentence warning users about this would be useful.


Discussion:

Resolving patch:
diff --git a/mlflow/tracking/fluent.py b/mlflow/tracking/fluent.py
--- a/mlflow/tracking/fluent.py
+++ b/mlflow/tracking/fluent.py
@@ -72,7 +72,8 @@ def set_experiment(experiment_name: str = None, experiment_id: str = None) -> Ex
 
     :param experiment_name: Case sensitive name of the experiment to be activated. If an experiment
                             with this name does not exist, a new experiment wth this name is
-                            created.
+                            created. On certain platforms such as Databricks, the experiment name
+                            must an absolute path, e.g. ``"/Users/<username>/my-experiment"``.
     :param experiment_id: ID of the experiment to be activated. If an experiment with this ID
                           does not exist, an exception is thrown.
     :return: An instance of :py:class:`mlflow.entities.Experiment` representing the new active


Test patch:
Repository: mlflow/mlflow

Issue:
[DOC-FIX] Misleading documentation for `sagemaker.push_model_to_sagemaker`
### Willingness to contribute

Yes. I can contribute a documentation fix independently.

### URL(s) with the issue

https://mlflow.org/docs/latest/python_api/mlflow.sagemaker.html#mlflow.sagemaker.push_model_to_sagemaker

### Description of proposal (what needs changing)

The documentation describes, quote "Push an MLflow model to AWS SageMaker model registry."
This is confusing since it suggests that you can push an MLflow model to a SageMaker Model Registry, while in reality it is only creating a SageMaker Model, which is not going to the SageMaker Model Registry.

Please fix the docs to : "Push an MLflow model to Amazon SageMaker and create a SageMaker Model" or something along that line


Discussion:
Agreed! Feel free to file a PR ! 

Resolving patch:
diff --git a/mlflow/sagemaker/__init__.py b/mlflow/sagemaker/__init__.py
--- a/mlflow/sagemaker/__init__.py
+++ b/mlflow/sagemaker/__init__.py
@@ -888,7 +888,7 @@ def push_model_to_sagemaker(
     flavor=None,
 ):
     """
-    Push an MLflow model to AWS SageMaker model registry.
+    Create a SageMaker Model from an MLflow model artifact.
     The currently active AWS account must have correct permissions set up.
 
     :param model_name: Name of the Sagemaker model.


Test patch:
Repository: mlflow/mlflow

Issue:
clean and transparent store registration
These lines

https://github.com/mlflow/mlflow/blob/152063e0b6fbadfbb2baecaf7d0ac7ca1b304b31/mlflow/tracking/_tracking_service/utils.py#L194C1-L206C1

initialize a global variable holding important information about store endpoints. 

But the style is not good:
- should be moved to the top and marked clearly
- perhaps it would be beneficial to wrap them to be recycled per user request (re-register / re-initialize)


Discussion:

Resolving patch:
diff --git a/mlflow/tracking/_tracking_service/utils.py b/mlflow/tracking/_tracking_service/utils.py
--- a/mlflow/tracking/_tracking_service/utils.py
+++ b/mlflow/tracking/_tracking_service/utils.py
@@ -191,18 +191,27 @@ def _get_databricks_uc_rest_store(store_uri, **_):
 
 
 _tracking_store_registry = TrackingStoreRegistry()
-_tracking_store_registry.register("", _get_file_store)
-_tracking_store_registry.register("file", _get_file_store)
-_tracking_store_registry.register("databricks", _get_databricks_rest_store)
-_tracking_store_registry.register(_DATABRICKS_UNITY_CATALOG_SCHEME, _get_databricks_uc_rest_store)
 
-for scheme in ["http", "https"]:
-    _tracking_store_registry.register(scheme, _get_rest_store)
 
-for scheme in DATABASE_ENGINES:
-    _tracking_store_registry.register(scheme, _get_sqlalchemy_store)
+def _register_tracking_stores():
+    global _tracking_store_registry
+    _tracking_store_registry.register("", _get_file_store)
+    _tracking_store_registry.register("file", _get_file_store)
+    _tracking_store_registry.register("databricks", _get_databricks_rest_store)
+    _tracking_store_registry.register(
+        _DATABRICKS_UNITY_CATALOG_SCHEME, _get_databricks_uc_rest_store
+    )
+
+    for scheme in ["http", "https"]:
+        _tracking_store_registry.register(scheme, _get_rest_store)
+
+    for scheme in DATABASE_ENGINES:
+        _tracking_store_registry.register(scheme, _get_sqlalchemy_store)
+
+    _tracking_store_registry.register_entrypoints()
+
 
-_tracking_store_registry.register_entrypoints()
+_register_tracking_stores()
 
 
 def _get_store(store_uri=None, artifact_uri=None):


Test patch: