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

Issue:
Deprecate/Remove `CallDefault`
## 🧰 Task

In `napari/utils/misc.py`, `CallDefault` seem to not be used since #2266. We should investigate adding a deprecation message and thinking about removal if this is not used anywhere else.



Discussion:

Resolving patch:
diff --git a/napari/utils/misc.py b/napari/utils/misc.py
--- a/napari/utils/misc.py
+++ b/napari/utils/misc.py
@@ -398,6 +398,13 @@ def abspath_or_url(relpath: T, *, must_exist: bool = False) -> T:
 
 
 class CallDefault(inspect.Parameter):
+    warnings.warn(
+        trans._(
+            '`CallDefault` in napari v0.5.0 and will be removed in v0.6.0.',
+        ),
+        category=DeprecationWarning,
+    )
+
     def __str__(self) -> str:
         """wrap defaults"""
         kind = self.kind


Test patch:
Repository: napari/napari

Issue:
`File -> Open Folder...` doesn't allow me to select a folder (Mac-OS)
### 🐛 Bug Report

On `main`, if I try to open a folder using the `File` menu option, `File -> Open Folder...`, the built-in Mac-OS dialog doesn't let me select a folder i.e. when I click `Open` in the bottom right-hand corner with a folder selected, it just shows me the contents of the folder (as though I'd double-clicked it) rather than selecting it and reading it. This doesn't happen on `0.4.19.post1`. Drag 'n' drop still works fine on main.

### 💡 Steps to Reproduce

1. Check out 0.4.19.post1
2. Open a folder using `File -> Open Folder...`. 
3. The folder opens normally.
4. Check out main
5. Open a folder using `File -> Open Folder...`.
6. You can't.

### 💡 Expected Behavior

I expected the folder to open as usual.

### 🌎 Environment

```
napari: 0.5.0a2.dev712+ge29593cf
Platform: macOS-10.16-x86_64-i386-64bit
System: MacOS 14.5
Python: 3.10.14 (main, Mar 21 2024, 11:24:58) [Clang 14.0.6 ]
Qt: 5.15.11
PyQt5: 5.15.10
NumPy: 1.26.4
SciPy: 1.13.0
Dask: 2024.4.0
VisPy: 0.14.2
magicgui: 0.8.2
superqt: 0.6.3
in-n-out: 0.2.0
app-model: 0.2.6
npe2: 0.7.5

OpenGL:
- GL version: 2.1 INTEL-22.5.11
- MAX_TEXTURE_SIZE: 16384
- GL_MAX_3D_TEXTURE_SIZE: 2048

Screens:
- screen 1: resolution 1440x900, scale 2.0

Optional:
- numba: 0.59.1
- triangle: 20230923

Settings path:
- /Users/ddoncilapop/Library/Application Support/napari/napari-dev_4bf01cd15eaead7335b2c3834bd2061f518e1da7/settings.yaml
```

### 💡 Additional Context

_No response_


Discussion:
Fix incoming.

Resolving patch:
diff --git a/napari/_qt/_qapp_model/qactions/_file.py b/napari/_qt/_qapp_model/qactions/_file.py
--- a/napari/_qt/_qapp_model/qactions/_file.py
+++ b/napari/_qt/_qapp_model/qactions/_file.py
@@ -68,7 +68,7 @@ def _close_app(window: Window):
     Action(
         id='napari.window.file.open_folder_dialog',
         title=trans._('Open Folder...'),
-        callback=QtViewer._open_files_dialog,
+        callback=QtViewer._open_folder_dialog,
         menus=[{'id': MenuId.MENUBAR_FILE, 'group': MenuGroup.NAVIGATION}],
         keybindings=[
             {'primary': KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyO}


Test patch:
Repository: mlflow/mlflow

Issue:
UUID dependency breaks python 3 under AWS linux
### 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)**: Amazon linux deep learning AMI 12.0 (like CentOS)
- **MLflow installed from (source or binary)**: source (PyPI)
- **MLflow version (run ``mlflow --version``)**: mlflow, version 0.5.0
- **Python version**: Python 3.6.6
- **npm version (if running the dev UI): N/A
- **Exact command to reproduce**: python -c "import mlflow"

### Describe the problem
```pip install mlflow``` also installs uuid==1.30 (which breaks under python3)

The default "uuid" library is included in the python standard library. On the AWS instance, the installed version shadows the default, and includes syntax which is only valid in python2. 
On the computer I'm connecting to the instance from, the same script does not produce any errors, but ```uuid.__file__``` points to a standard library version and not the packaged 1.30

### Source code / logs
Full reproduction from a newly created instance:
```
source activate tensorflow_p36
virtualenv env --system-site-packages --python=$(which python) env
source env/bin/activate
pip install mlflow
python -c "import mlflow"
```
```
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/ec2-user/scratch/env/lib/python3.6/site-packages/mlflow/__init__.py", line 33, in <module>
    import mlflow.projects as projects  # noqa
  File "/home/ec2-user/scratch/env/lib/python3.6/site-packages/mlflow/projects/__init__.py", line 17, in <module>
    import mlflow.tracking as tracking
  File "/home/ec2-user/scratch/env/lib/python3.6/site-packages/mlflow/tracking/__init__.py", line 7, in <module>
    from mlflow.tracking.service import MLflowService, get_service
  File "/home/ec2-user/scratch/env/lib/python3.6/site-packages/mlflow/tracking/service.py", line 13, in <module>
    from mlflow.tracking.utils import _get_store
  File "/home/ec2-user/scratch/env/lib/python3.6/site-packages/mlflow/tracking/utils.py", line 8, in <module>
    from mlflow.store.file_store import FileStore
  File "/home/ec2-user/scratch/env/lib/python3.6/site-packages/mlflow/store/file_store.py", line 3, in <module>
    import uuid
  File "/home/ec2-user/scratch/env/lib/python3.6/site-packages/uuid.py", line 138
    if not 0 <= time_low < 1<<32L:
                                ^
SyntaxError: invalid syntax
```


Discussion:
My current workaround is to run ```pip uninstall uuid``` after installing mlflow
Same issue here when we tried to use this with JupyterHub, workaround as discribed by @antonpaquin 

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -31,7 +31,6 @@ def package_files(directory):
         'databricks-cli>=0.8.0',
         'requests>=2.17.3',
         'six>=1.10.0',
-        'uuid',
         'gunicorn',
         'Flask',
         'numpy',


Test patch:
Repository: mlflow/mlflow

Issue:
Missing doc string for `run_name`
There is missing doc string in public API for `mlflow.create_run` method

https://github.com/mlflow/mlflow/blob/f4869beec5cd2220d1bf01861d80f7145a8601bf/mlflow/tracking/fluent.py#L45-L70


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
@@ -57,7 +57,7 @@ def start_run(run_uuid=None, experiment_id=None, source_name=None, source_versio
                      (the run's ``source_version``, ``source_type``, etc. are not changed).
     :param experiment_id: Used only when ``run_uuid`` is unspecified. ID of the experiment under
                           which to create the current run. If unspecified, the run is created under
-                          a new experiment with a randomly generated name.
+                          default experiment.
     :param source_name: Name of the source file or URI of the project to be associated with the run.
                         Defaults to the current file if none provided.
     :param source_version: Optional Git commit hash to associate with the run.
@@ -65,6 +65,7 @@ def start_run(run_uuid=None, experiment_id=None, source_name=None, source_versio
     :param source_type: Integer enum value describing the type of the run
                         ("local", "project", etc.). Defaults to
                         ``mlflow.entities.SourceType.LOCAL``.
+    :param run_name: Used only when ``run_uuid`` is unspecified. Desired name of new run created.
     :return: :py:class:`mlflow.ActiveRun` object that acts as a context manager wrapping
              the run's state.
     """


Test patch:
Repository: mlflow/mlflow

Issue:
mlflow command line tool inconsistency for mlflow sklearn serve with other serving commands
### System information
- **MLflow version (run ``mlflow --version``)**: 0.5.2

### Describe the problem
`mlflow sklearn serve` has the model path as the last parameter while all others (e.g. `mlflow sklearn serve`) require -m as an option to specify the model path. It is worth considering whether we make `mlflow sklearn serve` consistent with the other APIs.


Discussion:

Resolving patch:
diff --git a/mlflow/sklearn.py b/mlflow/sklearn.py
--- a/mlflow/sklearn.py
+++ b/mlflow/sklearn.py
@@ -20,6 +20,7 @@
 import pandas
 import sklearn
 
+from mlflow.utils import cli_args
 from mlflow.utils.file_utils import TempDir
 from mlflow import pyfunc
 from mlflow.models import Model
@@ -112,7 +113,7 @@ def commands():
 
 
 @commands.command("serve")
-@click.argument("model_path")
+@cli_args.MODEL_PATH
 @click.option("--run_id", "-r", metavar="RUN_ID", help="Run ID to look for the model in.")
 @click.option("--port", "-p", default=5000, help="Server port. [default: 5000]")
 @click.option("--host", default="127.0.0.1",


Test patch:
Repository: mlflow/mlflow

Issue:
AttributeError: 'RestStore' object has no attribute 'get_experiment_by_name'
### System information
- **Have I written custom code (as opposed to using a stock example script provided in MLflow)**:
I am trying to implement simple tracking server using mlflow.
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**:Ubuntu 16.04
- **MLflow installed from (source or binary)**: using pip
- **MLflow version (run ``mlflow --version``)**:0.6.0
- **Python version**: 3.6.5
- **npm version (if running the dev UI):
- **Exact command to reproduce**:
```
import mlflow

mlflow.set_tracking_uri('http://my-mlflow-server:port')
client = mlflow.tracking.MlflowClient()
expr = client.get_experiment_by_name('test')

```
### Describe the problem
As you can see in the above code I'm trying to get the experiment object (similar to example in the documentation)  but the client object is RestStore and it is not has this function.
thank you 



Discussion:
Getting the same issue when calling set_experiment()

Traceback (most recent call last):
  File "train.py", line 26, in <module>
    mlflow.set_experiment("wine-quality-test3")
  File "/nfs/site/disks/ibi_tools/workarea/dmarkhas/python/.venv/lib/python3.6/site-packages/mlflow/tracking/fluent.py", line 41, in set_experiment
    experiment = client.get_experiment_by_name(experiment_name)
  File "/nfs/site/disks/ibi_tools/workarea/dmarkhas/python/.venv/lib/python3.6/site-packages/mlflow/tracking/client.py", line 89, in get_experiment_by_name
    return self.store.get_experiment_by_name(name)
AttributeError: 'RestStore' object has no attribute 'get_experiment_by_name'

This only happens when using a remote tracking server (and as a result, using RestStore).


Resolving patch:
diff --git a/mlflow/store/rest_store.py b/mlflow/store/rest_store.py
--- a/mlflow/store/rest_store.py
+++ b/mlflow/store/rest_store.py
@@ -107,6 +107,12 @@ def get_experiment(self, experiment_id):
         response_proto = self._call_endpoint(GetExperiment, req_body)
         return Experiment.from_proto(response_proto.experiment)
 
+    def get_experiment_by_name(self, name):
+        for experiment in self.list_experiments(ViewType.ALL):
+            if experiment.name == name:
+                return experiment
+        return None
+
     def delete_experiment(self, experiment_id):
         req_body = message_to_json(DeleteExperiment(experiment_id=experiment_id))
         self._call_endpoint(DeleteExperiment, req_body)


Test patch:
Repository: mlflow/mlflow

Issue:
Tensorflow example is corresponding to old version
### 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)**: Linux Ubuntu 16.04
- **MLflow installed from (source or binary)**: binary
- **MLflow version (run ``mlflow --version``)**:Tried master and 0.7
- **Python version**:  3.7.1 
- **npm version (if running the dev UI):
- **Exact command to reproduce**: Run the example for tensorflow

### Describe the problem
train_predict.py present in mlflow/examples/tensorflow is corresponding to the old branch (0.7) and the code in master is not working with it. Kindly update the example. The method 'log_saved_model' is not present on the file master/mlflow/tensorflow.py instead it is replaced with log_model. The new method has additional parameter which is missing in example. 

### Source code / logs
Already part of source



Discussion:

Resolving patch:
diff --git a/examples/tensorflow/train_predict.py b/examples/tensorflow/train_predict.py
--- a/examples/tensorflow/train_predict.py
+++ b/examples/tensorflow/train_predict.py
@@ -3,12 +3,14 @@
 from __future__ import print_function
 
 import mlflow
-from mlflow import tensorflow, tracking, pyfunc
+from mlflow import tracking, pyfunc
 import numpy as np
 import pandas as pd
 import shutil
 import tempfile
 import tensorflow as tf
+from tensorflow.python.saved_model import tag_constants
+import mlflow.tensorflow
 
 
 def main(argv):
@@ -36,9 +38,12 @@ def main(argv):
         try:
             saved_estimator_path = regressor.export_savedmodel(temp, receiver_fn).decode("utf-8")
             # Logging the saved model
-            tensorflow.log_saved_model(saved_model_dir=saved_estimator_path, signature_def_key="predict", artifact_path="model")
+            mlflow.tensorflow.log_model(tf_saved_model_dir=saved_estimator_path,
+                                        tf_meta_graph_tags = [tag_constants.SERVING],
+                                        tf_signature_def_key="predict",
+                                        artifact_path="model")
             # Reloading the model
-            pyfunc_model = pyfunc.load_pyfunc(saved_estimator_path)
+            pyfunc_model = pyfunc.load_pyfunc(mlflow.get_artifact_uri('model'))
             df = pd.DataFrame(data=x_test, columns=["features"] * x_train.shape[1])
             # Predicting on the loaded Python Function
             predict_df = pyfunc_model.predict(df)


Test patch:
Repository: mlflow/mlflow

Issue:
SqlAlchemyStore is created on every request
### 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)**: Ubuntu 16.04
- **MLflow installed from (source or binary)**:  binary
- **MLflow version (run ``mlflow --version``)**: 0.9.1
- **Python version**: 2.7
- **npm version (if running the dev UI):
- **Exact command to reproduce**: `mlflow server --backend-store-uri mysql://user:password@localhost:3306`

### Describe the problem
When we switched to mysql, web UI became really slow. REST API requests started to take 2+ seconds. Looking at the code here:
https://github.com/mlflow/mlflow/blob/master/mlflow/server/handlers.py#L35
it looks like we're creating a new SqlAlchemyStore on every request and not saving it to a global `_store`, like we do with the FileStore. On my machine every new SqlAlchemyStore takes 1.8 seconds, which I think is the reason for the slowdown.


Discussion:
Hi @ashtuchkin, thanks for the catch. It's definitely not the intended behavior to create a new SQLAlchemyStore on each request in the OSS server - would be happy to review & merge a PR that fixes this (basically just replace https://github.com/mlflow/mlflow/blob/master/mlflow/server/handlers.py#L35 with `_store = SqlAlchemyStore(store_dir, artifact_root)`)

Resolving patch:
diff --git a/mlflow/server/handlers.py b/mlflow/server/handlers.py
--- a/mlflow/server/handlers.py
+++ b/mlflow/server/handlers.py
@@ -32,7 +32,7 @@ def _get_store():
         artifact_root = os.environ.get(ARTIFACT_ROOT_ENV_VAR, None)
         if _is_database_uri(store_dir):
             from mlflow.store.sqlalchemy_store import SqlAlchemyStore
-            return SqlAlchemyStore(store_dir, artifact_root)
+            _store = SqlAlchemyStore(store_dir, artifact_root)
         elif _is_local_uri(store_dir):
             from mlflow.store.file_store import FileStore
             _store = FileStore(store_dir, artifact_root)


Test patch:
Repository: mlflow/mlflow

Issue:
Unable to specify destination path when download_artifacts with MlflowClient
### The problem
When downloading artifacts with download_artifacts on MlflowClient there is no argument that can specify what is the destination path where the artifacts should be downloaded to. 

I will open a PR that fixes it.

### Source code
**mlflow/tracking/client.py**

    def download_artifacts(self, run_id, path):
        """
        Download an artifact file or directory from a run to a local directory if applicable,
        and return a local path for it.

        :param run_id: The run to download artifacts from.
        :param path: Relative source path to the desired artifact.
        :return: Local path of desired artifact.
        """
        run = self.get_run(run_id)
        artifact_root = run.info.artifact_uri
        artifact_repo = get_artifact_repository(artifact_root, self.store)
        return artifact_repo.download_artifacts(path)



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
@@ -234,19 +234,24 @@ def list_artifacts(self, run_id, path=None):
         artifact_repo = get_artifact_repository(artifact_root)
         return artifact_repo.list_artifacts(path)
 
-    def download_artifacts(self, run_id, path):
+    def download_artifacts(self, run_id, path, dst_path=None):
         """
         Download an artifact file or directory from a run to a local directory if applicable,
         and return a local path for it.
 
         :param run_id: The run to download artifacts from.
         :param path: Relative source path to the desired artifact.
+        :param dst_path: Absolute path of the local filesystem destination directory to which to
+                         download the specified artifacts. This directory must already exist.
+                         If unspecified, the artifacts will either be downloaded to a new
+                         uniquely-named directory on the local filesystem or will be returned
+                         directly in the case of the LocalArtifactRepository.
         :return: Local path of desired artifact.
         """
         run = self.get_run(run_id)
         artifact_root = run.info.artifact_uri
         artifact_repo = get_artifact_repository(artifact_root)
-        return artifact_repo.download_artifacts(path)
+        return artifact_repo.download_artifacts(path, dst_path)
 
     def set_terminated(self, run_id, status=None, end_time=None):
         """Set a run's status to terminated.


Test patch:
Repository: mlflow/mlflow

Issue:
[BUG] multistep_workflow "best-effort detection of 'already run'" fails to detect run_info has FINISHED status
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. For help with debugging your code, please refer to [Stack Overflow](https://stackoverflow.com/questions/tagged/mlflow).

Please fill in this template and do not delete it unless you are sure your issue is outside its scope.

### 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)**: Linux Ubuntu 16.04
- **MLflow installed from (source or binary)**: pip install mlflow
- **MLflow version (run ``mlflow --version``)**: mlflow, version 1.3.0
- **Python version**: Python 3.5.6 :: Anaconda, Inc.
- **npm version, if running the dev UI**:
- **Exact command to reproduce**: 
```from mlflow.entities import RunStatus; type(RunStatus.ACTIVE) == int```

### Describe the problem
Describe the problem clearly here. Include descriptions of the expected behavior and the actual behavior.

The check on the run_info.status is finished fails because run_info.status is of type `str` equal to `FINISHED` but `mlflow.entities.RunStatus` is actually of `int` type.

### Code to reproduce issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.

1. `mlflow run https://github.com/mlflow/mlflow#examples/multistep_workflow -e load_raw_data`
2. Allow to complete and verify it is actually FINISHED
3. `mlflow run https://github.com/mlflow/mlflow#examples/multistep_workflow`
4. Notice the print statement saying
> Run matched, but is not FINISHED, so skipping (run_id=91cab91e68cf4f45b3c88781fc7000fb, status=FINISHED)


### Other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks,
please include the full traceback. Large logs and files should be attached.



Discussion:

Resolving patch:
diff --git a/examples/multistep_workflow/main.py b/examples/multistep_workflow/main.py
--- a/examples/multistep_workflow/main.py
+++ b/examples/multistep_workflow/main.py
@@ -40,7 +40,7 @@ def _already_ran(entry_point_name, parameters, git_commit, experiment_id=None):
         if match_failed:
             continue
 
-        if run_info.status != RunStatus.FINISHED:
+        if run_info.to_proto().status != RunStatus.FINISHED:
             eprint(("Run matched, but is not FINISHED, so skipping "
                     "(run_id=%s, status=%s)") % (run_info.run_id, run_info.status))
             continue


Test patch:
Repository: mlflow/mlflow

Issue:
[BUG] Type check on code_paths parameter when saving model
### System information
Google Colab

### Describe the problem

When saving a PyTorch model using `mlflow.pytorch.save_model`, no type checking is performed on the `code_paths` parameter. Specifically, it is not considered that this parameter could accidentally be passed as a string, leading to the following (funny) outcome.

Consider the code at [line 252](https://github.com/mlflow/mlflow/blob/e70d287bcf75ac26d22db287861029ac1a5fa3d1/mlflow/pytorch/__init__.py#L252): 
```python
    if code_paths is not None:
        code_dir_subpath = "code"
        for code_path in code_paths:
            _copy_file_or_tree(src=code_path, dst=path, dst_dir=code_dir_subpath)
```
If someone were to hypothetically pass an absolute path as the parameter to code_paths (for example, `/content/myfolder/mymodelcode`), then the string is iterated through, starting with `/`. This accidentally copies the entire file system into the output directory.

~~I definitely didn't accidentally do this.~~

### Possible Fix

```python
    if code_paths is not None:
        if not isinstance(code_paths, list):
            raise TypeError(f'Argument code_paths should be a list, not {type(code_paths)}')
        code_dir_subpath = "code"
        for code_path in code_paths:
            _copy_file_or_tree(src=code_path, dst=path, dst_dir=code_dir_subpath)
```

The documentation is plenty clear about this ("code_paths – A **list** of local filesystem paths"), but given the possible outcome, it might be helpful regardless.


Discussion:
@jacobdanovitch thanks for pointing this out. The side effect here is definitely unfortunate. Can you file a PR with the fix you specified in the issue? Alternatively, we could modify the behavior to treat a string as a single-element list - I think that sounds like a pretty good approach.

Resolving patch:
diff --git a/mlflow/pytorch/__init__.py b/mlflow/pytorch/__init__.py
--- a/mlflow/pytorch/__init__.py
+++ b/mlflow/pytorch/__init__.py
@@ -250,6 +250,8 @@ def save_model(pytorch_model, path, conda_env=None, mlflow_model=Model(), code_p
         yaml.safe_dump(conda_env, stream=f, default_flow_style=False)
 
     if code_paths is not None:
+        if not isinstance(code_paths, list):
+            raise TypeError('Code_paths should be a list, not {type(code_paths)}')
         code_dir_subpath = "code"
         for code_path in code_paths:
             _copy_file_or_tree(src=code_path, dst=path, dst_dir=code_dir_subpath)


Test patch: