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

Issue:
[BUG] Pyfunc artifact paths created on Windows use Windows path separators.
### Willingness to contribute
The MLflow Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix
for this bug to the MLflow code base?

- [ ] Yes. I can contribute a fix for this bug independently.
- [x] Yes. I would be willing to contribute a fix for this bug with guidance from the MLflow community.
- [ ] No. I cannot contribute a bug fix at this time.

### System information
- **Have I written custom code (as opposed to using a stock example script provided in MLflow)**: No
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: Windows 10
- **MLflow installed from (source or binary)**: Binary
- **MLflow version (run ``mlflow --version``)**: 1.8.0
- **Python version**: 3.6
- **Exact command to reproduce**:
N/A


### Describe the problem
Creating pyfunc model on windows using the `artifacts` arguments results in an MLModel file with windows separators in the paths: 

```
flavors:
  python_function:
    artifacts:
      artifact:
        path: artifacts\some_artifact
        uri: some_artifact
    cloudpickle_version: 1.3.0
    env: conda.yaml
    loader_module: mlflow.pyfunc.model
    python_model: python_model.pkl
    python_version: 3.6.10
utc_time_created: '2020-04-28 15:59:25.211458'
```

The problem with this is portability. E.g. running a docker container fails miserably. 

The fix is probably to always use forward slashes for this. 

### Code to reproduce issue
```python
import mlflow.pyfunc

class PythonModelWrapper(mlflow.pyfunc.PythonModel):
    pass

artifact_path='some_artifact'
with open(artifact_path, 'w') as f:
    f.write('example')

artifacts = {
    'artifact' : artifact_path
}

mlflow_pyfunc_model_path = "mlflow_pyfunc"
mlflow.pyfunc.save_model(
        path=mlflow_pyfunc_model_path, python_model=PythonModelWrapper(), artifacts=artifacts)
```




Discussion:
It would be great to fix this and also to enable pyfunc flavor tests on windows!

Resolving patch:
diff --git a/mlflow/pyfunc/model.py b/mlflow/pyfunc/model.py
--- a/mlflow/pyfunc/model.py
+++ b/mlflow/pyfunc/model.py
@@ -4,6 +4,7 @@
 """
 
 import os
+import posixpath
 import shutil
 import yaml
 from abc import ABCMeta, abstractmethod
@@ -156,7 +157,7 @@ def _save_model_with_class_artifacts_params(path, python_model, artifacts=None,
                 tmp_artifact_path = _download_artifact_from_uri(
                     artifact_uri=artifact_uri, output_path=tmp_artifacts_dir.path())
                 tmp_artifacts_config[artifact_name] = tmp_artifact_path
-                saved_artifact_subpath = os.path.join(
+                saved_artifact_subpath = posixpath.join(
                     saved_artifacts_dir_subpath,
                     os.path.relpath(path=tmp_artifact_path, start=tmp_artifacts_dir.path()))
                 saved_artifacts_config[artifact_name] = {


Test patch:
Repository: mlflow/mlflow

Issue:
[SETUP-BUG] ResolvePackageNotFound - python=3.5.2
Thank you for submitting an issue. Please refer to our [issue policy](https://www.github.com/mlflow/mlflow/blob/master/ISSUE_POLICY.md)
for information on what types of issues we address.
  
Please fill in this template and do not delete it unless you are sure your issue is outside its scope.

### System information
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: Ubuntu 16.04
- **MLflow installed from (source or binary)**:  binary (pip install mlflow)
- **MLflow version (run ``mlflow --version``)**: 1.2.0
- **Python version**: 3.5.2
- **Exact command to reproduce**: mlflow models build-docker -m /path/to/model -n "my-model" 

### Describe the problem
mlflow models build-docker -m /path/to/model -n "my-model"

### Other info / logs
Warning: you have pip-installed dependencies in your environment file, but you do not list pip itself as one of your condadependencies.  Conda may not use the correct pip to install your packages, and they may end up in the wrong place.  Pleaseadd an explicit pip dependency.  I'm adding one for you, but still nagging you.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... failed

ResolvePackageNotFound:
  - python=3.5.2

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/miniconda/lib/python3.7/site-packages/mlflow/models/container/__init__.py", line 102, in _install_pyfunc_deps
    raise Exception("Failed to create model environment.")
Exception: Failed to create model environment.
creating and activating custom environment
The command '/bin/sh -c python -c                 'from mlflow.models.container import _install_pyfunc_deps; _install_pyfunc_deps("/opt/ml/model", install_mlflow=False)'' returned a non-zero code: 1



Discussion:
Python 3.5.2 is no longer available on the conda-forge repo
It seems like databricks clusters (if you built it on Databricks) run python 3.5.2
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has not been interacted with for 60 days since it was marked as stale! As such, the issue is now closed. If you have this issue or more information, please re-open the issue!


Resolving patch:
diff --git a/mlflow/utils/environment.py b/mlflow/utils/environment.py
--- a/mlflow/utils/environment.py
+++ b/mlflow/utils/environment.py
@@ -6,6 +6,7 @@
 name: mlflow-env
 channels:
   - defaults
+  - conda-forge
 """
 
 


Test patch:
Repository: mlflow/mlflow

Issue:
[DOC-FIX] - projects.run() - Missing docstring entries - 'parameters' and 'docker_args'
### Willingness to contribute
The MLflow Community encourages documentation fix contributions. Would you or another member of your organization be willing to contribute a fix for this documentation issue to the MLflow code base?

- [] Yes. I can contribute a documentation fix independently.
- [x ] Yes. I would be willing to contribute a document fix with guidance from the MLflow community.
- [ ] No. I cannot contribute a documentation fix at this time.

### URL(s) with the issue:
https://github.com/jkthompson/mlflow/blob/edb5585233f18f9f4e306901e1b5cf6bc013260f/mlflow/projects/__init__.py#L221-L222

### Description of proposal (what needs changing):
Documentation for `parameters` and `docker_args` are missing.  Propose to copy/paste from CLI help messages.  https://github.com/jkthompson/mlflow/blob/edb5585233f18f9f4e306901e1b5cf6bc013260f/mlflow/cli.py#L49-L55


Discussion:
Makes sense to me. Please feel free to create a PR. Thanks!

Resolving patch:
diff --git a/mlflow/projects/__init__.py b/mlflow/projects/__init__.py
--- a/mlflow/projects/__init__.py
+++ b/mlflow/projects/__init__.py
@@ -219,6 +219,8 @@ def run(uri, entry_point="main", version=None, parameters=None,
                         using "python" to run ``.py`` files and the default shell (specified by
                         environment variable ``$SHELL``) to run ``.sh`` files.
     :param version: For Git-based projects, either a commit hash or a branch name.
+    :param parameters: Parameters (dictionary) for the entry point command.
+    :param docker_args: Arguments (dictionary) for the docker command.
     :param experiment_name: Name of experiment under which to launch the run.
     :param experiment_id: ID of experiment under which to launch the run.
     :param backend: Execution backend for the run: MLflow provides built-in support for "local",


Test patch:
Repository: mlflow/mlflow

Issue:
[FR]Allow different MLFLOW_TRACKING_URI inside Kubernetes
_As a Kubernetes workflow developer I want to submit jobs to kubernetes running in Docker Desktop that use the Tracker UI directly from my desktop command line so I can easily develop Kubernetes projects_ 

## Problem
Inside of the cluster, the URI for the tracking UI is `http://host.docker.internal:5000` outside of kubernetes the URI should be `http://localhost:5000`. When I submit a job, the MLflow CLI wants to send some updates to the tracker ui from my desktop and then once the job starts inside the cluster it wants to connect to the ui from inside.

## Proposed Solution
In a fork of MLFlow 1.2.0 I simply added a new environment variable, `K8S_MLFLOW_TRACKING_URI`. If this is set, it is the value that is passed into the job running inside the cluster. If it is not set then the usual behavior carries on where the same `MLFLOW_TRACKING_URI` is used inside and outside.

## Motivation
This seems like it would be a common development configuration. It's possible to get around this with some DNS hacking, or running the UI inside the cluster, but that is currently not as easy as it should be. This seems like a simple fix that doesn't add a lot of extra configuration complexity

## Next Steps
If this solution makes sense I'll package up my change and unit tests in a PR



Discussion:
@BenGalewsky Sorry for the delay here. This is definitely a tough problem; I think an extra environment variable presents a pretty simple workaround. Can you package up this change as a PR? 

cc @smurching @tomasatdatabricks @mparkhe who may have better ideas here

Resolving patch:
diff --git a/mlflow/projects/kubernetes.py b/mlflow/projects/kubernetes.py
--- a/mlflow/projects/kubernetes.py
+++ b/mlflow/projects/kubernetes.py
@@ -1,6 +1,7 @@
 import logging
 import docker
 import time
+import os
 from threading import RLock
 from datetime import datetime
 
@@ -33,6 +34,8 @@ def _get_kubernetes_job_definition(project_name, image_tag, image_digest,
     timestamp = datetime.now().strftime('%Y-%m-%d-%H-%M-%S-%f')
     job_name = "{}-{}".format(project_name, timestamp)
     _logger.info("=== Creating Job %s ===", job_name)
+    if os.environ.get('KUBE_MLFLOW_TRACKING_URI') is not None:
+        env_vars['MLFLOW_TRACKING_URI'] = os.environ['KUBE_MLFLOW_TRACKING_URI']
     environment_variables = [{'name': k, 'value': v} for k, v in env_vars.items()]
     job_template['metadata']['name'] = job_name
     job_template['spec']['template']['spec']['containers'][0]['name'] = project_name


Test patch:
Repository: mlflow/mlflow

Issue:
Unpin sqlalchemy
Hi,

Currently mlflow pins sqlalchemy to `<= 1.3.13`. I wanted to use this package on a projects that requires a more updated version of sqlalchemy.
Would it be possible to unpit sqlalchemy or to change the constraint to disallow specific version of it? (like `!=1.3.14` etc?)

Thanks


Discussion:
@CaselIT Thanks for filing this.

you can try this:

https://stackoverflow.com/a/12759996/6943581

> pip has a --no-dependencies switch. You should use that.


Thanks for the suggestion, but I would then manually have to track all the other mlflow dependencies, so it becomes hard to maintain. I'll do that for the moment.


Or you can try:

```
pip install mlflow
pip install -U sqlalchemy
```

you'll get a warning though.
Would a PR be accepted to unpin it? I gather that the problem was 1.3.14?
See https://github.com/mlflow/mlflow/pull/2587
#2587 is outdated, 1.3.16+ no longer use pep517.
@CaselIT you're right. In 1.3.16, sqlalchemy started uploading wheels: https://pypi.org/project/SQLAlchemy/1.3.16/#files
@smurching Should we unpin `sqlalchemy` (We need to verify that a newer version of `sqlalchemy` doesn't cause errors in Databricks though)?
Yes, also pep517 was disabled here https://github.com/sqlalchemy/sqlalchemy/commit/fcb22fa8e26eaf7f0c1a99b8b20275a3557a240f

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -54,7 +54,7 @@ def package_files(directory):
         # Pin sqlparse for: https://github.com/mlflow/mlflow/issues/3433
         "sqlparse>=0.3.1",
         # Required to run the MLflow server against SQL-backed storage
-        "sqlalchemy<=1.3.13",
+        "sqlalchemy",
         "gorilla",
         "prometheus-flask-exporter",
     ],


Test patch:
Repository: mlflow/mlflow

Issue:
[BUG] keras 2.4.X autolog - AttributeError: module 'keras.callbacks' has no attribute 'callbacks'

### Willingness to contribute
- [x] Yes. I would be willing to contribute a fix for this bug with guidance from the MLflow community.


### System information
- **Have I written custom code (as opposed to using a stock example script provided in MLflow)**:  no - just using the [tests/keras_autolog.py](https://github.com/mlflow/mlflow/blob/master/tests/keras_autolog/test_keras_autolog.py)
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: Linux OpenSuSE 15.1
- **MLflow installed from (source or binary)**:  from dev with upgrade of `tensorflow` and `keras`
- **MLflow version (run ``mlflow --version``)**: 1.11.0
- **Python version**: 3.6.11 (also checked on 3.7)
- **Exact command to reproduce**:  
>pytest tests/keras_autolog --large --ignore-flavors --ignore=tests/examples

### Describe the problem
When running with:
>tensorflow 2.3.1
>keras 2.4.3   

the keras_autolog() fails with an error 
> AttributeError: module 'keras.callbacks' has no attribute 'callbacks'

### Code to reproduce issue
> pytest tests/keras_autolog --large --ignore-flavors --ignore=tests/examples

### Other info / logs

A work around can be done by [commenting out the if statement in keras.py](https://github.com/mlflow/mlflow/blob/master/mlflow/keras.py#L610:L613)  ,  this allows for most test to pass.

### What component(s), interfaces, languages, and integrations does this bug affect?
Components 
- [x] `area/artifacts`: Artifact stores and artifact logging
- [X] `area/projects`: MLproject format, project running backends
- [X] `area/tracking`: Tracking Service, tracking client APIs, autologging





Discussion:
@sephib Thanks for reporthing this. Looks like we need to fix the if condition.

```python
        if (LooseVersion(keras.__version__) < LooseVersion("2.3.0") or
            LooseVersion(keras.__version__) >= LooseVersion("2.4.0")):
            es_callback = keras.callbacks.EarlyStopping
        else:
            es_callback = keras.callbacks.callbacks.EarlyStopping
```

Please let me know if you want me to submit a PR
@sephib That would be very helpful! Thank you!

Resolving patch:
diff --git a/mlflow/keras.py b/mlflow/keras.py
--- a/mlflow/keras.py
+++ b/mlflow/keras.py
@@ -607,7 +607,9 @@ def _implements_predict_batch_hooks(self):
             return False
 
     def _early_stop_check(callbacks):
-        if LooseVersion(keras.__version__) < LooseVersion("2.3.0"):
+        if LooseVersion(keras.__version__) < LooseVersion("2.3.0") or LooseVersion(
+            keras.__version__
+        ) >= LooseVersion("2.4.0"):
             es_callback = keras.callbacks.EarlyStopping
         else:
             es_callback = keras.callbacks.callbacks.EarlyStopping


Test patch:
Repository: mlflow/mlflow

Issue:
mlflow.pytorch.get_default_conda_env() requires torchvision to be installed
Using mlflow.pytorch.log_model() or mlflow.pytorch.get_default_conda_env() directly, requires torchvision to be installed as its imported to check the version.

However I think mlflow.pytorch.log_model() should work as well if torchvision is not installed,


Discussion:

Resolving patch:
diff --git a/mlflow/pytorch/__init__.py b/mlflow/pytorch/__init__.py
--- a/mlflow/pytorch/__init__.py
+++ b/mlflow/pytorch/__init__.py
@@ -68,7 +68,6 @@ def get_default_pip_requirements():
             _get_pinned_requirement,
             [
                 "torch",
-                "torchvision",
                 # We include CloudPickle in the default environment because
                 # it's required by the default pickle module used by `save_model()`
                 # and `log_model()`: `mlflow.pytorch.pickle_module`.
@@ -103,7 +102,6 @@ def get_default_conda_env():
                    'channels': ['conda-forge'],
                    'dependencies': ['python=3.7.5',
                                     {'pip': ['torch==1.5.1',
-                                             'torchvision==0.6.1',
                                              'mlflow',
                                              'cloudpickle==1.6.0']}]}
     """


Test patch:
Repository: mlflow/mlflow

Issue:
[DOC-FIX] Change type hint for method get_latest_versions to List[ModelVersion]
Thank you for submitting an issue. Please refer to our [issue policy](https://www.github.com/mlflow/mlflow/blob/master/ISSUE_POLICY.md) for information on what types of issues we address.

**Please fill in this documentation issue template to ensure a timely and thorough response.**

### Willingness to contribute
The MLflow Community encourages documentation fix contributions. Would you or another member of your organization be willing to contribute a fix for this documentation issue to the MLflow code base?

- [x] Yes. I can contribute a documentation fix independently.
- [ ] Yes. I would be willing to contribute a document fix with guidance from the MLflow community.
- [ ] No. I cannot contribute a documentation fix at this time.

### URL(s) with the issue:

Please provide a link to the documentation entry in question.
https://mlflow.org/docs/latest/python_api/mlflow.tracking.html#mlflow.tracking.MlflowClient.get_latest_versions

### Description of proposal (what needs changing):
In code return type of method get_latest_versions is singular value of class ModelVersion, but in the documentation and code the method returns list of ModelVersion class object.   

Need to change the type hint of return type to List[ModelVersion].


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
@@ -1980,7 +1980,7 @@ def print_model_info(rm):
         """
         return self._get_registry_client().get_registered_model(name)
 
-    def get_latest_versions(self, name: str, stages: List[str] = None) -> ModelVersion:
+    def get_latest_versions(self, name: str, stages: List[str] = None) -> List[ModelVersion]:
         """
         Latest version models for each requests stage. If no ``stages`` provided, returns the
         latest version for each stage.


Test patch:
Repository: mlflow/mlflow

Issue:
Add `MlflowException.invalid_parameter_value`
## Motivation

We frequently construct an `MlflowException` instance with `error_code=INVALID_PARAMETER_VALUE`:


```python
import mlflow.exceptions from MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE

raise MlflowException(
    "error message",
    error_code=INVALID_PARAMETER_VALUE,
)
```

If we had a class method `invalid_parameter_value`:

```python
class MlflowException(...):
    @classmethod
    def invalid_parameter_value(cls, message, **kwargs):
        return cls(message, error_code=INVALID_PARAMETER_VALUE, **kwargs)
```

we could simplify the code above to:

```python
import mlflow.exceptions from MlflowException

raise MlflowException.invalid_parameter_value("error message")
```

which is shorter and has fewer import statements.

## Notes

- We don't need to replace existing `MlflowException("error message",error_code=INVALID_PARAMETER_VALUE)` for now (we may in the future).


Discussion:
May I take this one?

Resolving patch:
diff --git a/mlflow/exceptions.py b/mlflow/exceptions.py
--- a/mlflow/exceptions.py
+++ b/mlflow/exceptions.py
@@ -62,6 +62,18 @@ def serialize_as_json(self):
     def get_http_status_code(self):
         return ERROR_CODE_TO_HTTP_STATUS.get(self.error_code, 500)
 
+    @classmethod
+    def invalid_parameter_value(cls, message, **kwargs):
+        """
+        Constructs an `MlflowException` object with the `INVALID_PARAMETER_VALUE` error code.
+
+        :param message: The message describing the error that occured. This will be included in the
+                        exception's serialized JSON representation.
+        :param kwargs: Additional key-value pairs to include in the serialized JSON representation
+                       of the MlflowException.
+        """
+        return cls(message, error_code=INVALID_PARAMETER_VALUE, **kwargs)
+
 
 class RestException(MlflowException):
     """Exception thrown on non 200-level responses from the REST API"""


Test patch:
diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py
--- a/tests/test_exceptions.py
+++ b/tests/test_exceptions.py
@@ -42,6 +42,10 @@ def test_get_http_status_code(self):
             == 400
         )
 
+    def test_invalid_parameter_value(self):
+        mlflow_exception = MlflowException.invalid_parameter_value("test")
+        assert mlflow_exception.error_code == "INVALID_PARAMETER_VALUE"
+
 
 def test_rest_exception():
     mlflow_exception = MlflowException("test", error_code=RESOURCE_ALREADY_EXISTS)
Repository: mlflow/mlflow

Issue:
Fix: Removed get_experiment_by_name as not required
## What changes are proposed in this pull request?

Fixes #5808

URL(s) with the issue:
https://mlflow.org/docs/latest/_modules/mlflow/tracking/fluent.html#set_experiment
https://github.com/mlflow/mlflow/blob/master/mlflow/tracking/fluent.py

Change documentation / code example from
```
import mlflow
# Set an experiment name, which must be unique and case sensitive.
mlflow.set_experiment("Social NLP Experiments")
# Get Experiment Details
experiment = mlflow.get_experiment_by_name("Social NLP Experiments")
print("Experiment_id: {}".format(experiment.experiment_id))
print("Artifact Location: {}".format(experiment.artifact_location))
print("Tags: {}".format(experiment.tags))
print("Lifecycle_stage: {}".format(experiment.lifecycle_stage))
```
to 
```
import mlflow
# Set an experiment name, which must be unique and case-sensitive.
experiment = mlflow.set_experiment("Social NLP Experiments")
# Get Experiment Details
print("Experiment_id: {}".format(experiment.experiment_id))
print("Artifact Location: {}".format(experiment.artifact_location))
print("Tags: {}".format(experiment.tags))
print("Lifecycle_stage: {}".format(experiment.lifecycle_stage))
```



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
@@ -80,11 +80,10 @@ def set_experiment(experiment_name: str = None, experiment_id: str = None) -> Ex
 
         import mlflow
 
-        # Set an experiment name, which must be unique and case sensitive.
-        mlflow.set_experiment("Social NLP Experiments")
+        # Set an experiment name, which must be unique and case-sensitive.
+        experiment = mlflow.set_experiment("Social NLP Experiments")
 
         # Get Experiment Details
-        experiment = mlflow.get_experiment_by_name("Social NLP Experiments")
         print("Experiment_id: {}".format(experiment.experiment_id))
         print("Artifact Location: {}".format(experiment.artifact_location))
         print("Tags: {}".format(experiment.tags))


Test patch: