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

Issue:
Increase prefect client request timeout and allow timeout to be configurable
I'm getting an issue where the prefect client is registering a flow that is taking a bit more than 15 seconds to register.  The registration command is failing with the following error:

```
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.prefect.io', port=443): Max retries exceeded with url: /graphql (Caused by ReadTimeoutError("HTTPSConnectionPool(host='api.prefect.io', port=443): Read timed out. (read timeout=15)"))
```

I traced the source of the 15 second timeout to here:

https://github.com/PrefectHQ/prefect/blob/babc7631582b43dce9f41d584719dcc2ed6279c9/src/prefect/client/client.py#L343-L350

After bumping this timeout up manually in the prefect library source, the error went away.  Would be great if we could increase this to say 60? And possibly allow for it to be configurable?



Discussion:

Resolving patch:
diff --git a/src/prefect/client/client.py b/src/prefect/client/client.py
--- a/src/prefect/client/client.py
+++ b/src/prefect/client/client.py
@@ -341,11 +341,25 @@ def _send_request(
             start_time = time.time()
 
         if method == "GET":
-            response = session.get(url, headers=headers, params=params, timeout=15)
+            response = session.get(
+                url,
+                headers=headers,
+                params=params,
+                timeout=prefect.context.config.cloud.request_timeout,
+            )
         elif method == "POST":
-            response = session.post(url, headers=headers, json=params, timeout=15)
+            response = session.post(
+                url,
+                headers=headers,
+                json=params,
+                timeout=prefect.context.config.cloud.request_timeout,
+            )
         elif method == "DELETE":
-            response = session.delete(url, headers=headers, timeout=15)
+            response = session.delete(
+                url,
+                headers=headers,
+                timeout=prefect.context.config.cloud.request_timeout,
+            )
         else:
             raise ValueError("Invalid method: {}".format(method))
 


Test patch:
Repository: PrefectHQ/prefect

Issue:
WindowsShellTask or Windows support for ShellTask
Our current `ShellTask` implementation is not Windows compatible.  We should _either_:

- make it windows compatible
- create a new shell task specifically for windows machines


Discussion:
Related: https://github.com/PrefectHQ/prefect/issues/3375

Resolving patch:
diff --git a/src/prefect/tasks/shell.py b/src/prefect/tasks/shell.py
--- a/src/prefect/tasks/shell.py
+++ b/src/prefect/tasks/shell.py
@@ -1,6 +1,7 @@
 import os
 import tempfile
 import logging
+import sys
 from subprocess import PIPE, STDOUT, Popen
 from typing import Any, List, Union, Optional
 
@@ -126,11 +127,17 @@ def run(
         with tempfile.NamedTemporaryFile(prefix="prefect-") as tmp:
             if helper_script:
                 tmp.write(helper_script.encode())
-                tmp.write("\n".encode())
+                tmp.write(os.linesep.encode())
             tmp.write(command.encode())
             tmp.flush()
             with Popen(
-                [self.shell, tmp.name], stdout=PIPE, stderr=STDOUT, env=current_env
+                [self.shell, tmp.name],
+                stdout=PIPE,
+                stderr=STDOUT,
+                env=current_env,
+                # Windows does not use the PATH during subprocess creation
+                # by default so we will use `shell` mode to do so
+                shell=sys.platform == "win32",
             ) as sub_process:
                 line = None
                 lines = []


Test patch:
diff --git a/tests/tasks/test_shell.py b/tests/tasks/test_shell.py
--- a/tests/tasks/test_shell.py
+++ b/tests/tasks/test_shell.py
@@ -10,10 +10,6 @@
 from prefect.tasks.shell import ShellTask
 from prefect.utilities.debug import raise_on_exception
 
-pytestmark = pytest.mark.skipif(
-    sys.platform == "win32", reason="ShellTask currently not supported on Windows"
-)
-
 
 def test_shell_initializes_and_runs_basic_cmd():
     with Flow(name="test") as f:
@@ -235,7 +231,7 @@ def test_shell_task_handles_multiline_commands():
             cat $file
         done
         """.format(
-            tempdir
+            tempdir.replace("\\", "\\\\")
         )
         with open(tempdir + "/testfile.txt", "w") as f:
             f.write("this is a test")
Repository: PrefectHQ/prefect

Issue:
Docs Issue
Hello!

I've found an issue here:`prefect.tasks.prefect.flow_run.create_flow_run(flow_id=None, flow_name=None, project_name="", parameters=None, context=None, labels=None, run_name=None, run_config=None, scheduled_start_time=None)`

Page reference: https://docs.prefect.io/api/latest/tasks/prefect.html

Instead of title we're showing full input path
![Screen Shot 2021-08-05 at 4 27 38 PM](https://user-images.githubusercontent.com/2325367/128416614-a98b1597-cc42-4f77-9adc-03e8e577c297.png)



Discussion:
@znicholasbrown I do not have the powers to tackle the docs generator. If you have time, that'd be nice. Otherwise, I think this is very low priority.
To make sure I understand the issue correctly, is the expected output that classes/methods don't have the full signature like this?
![Screen Shot 2021-08-06 at 1 57 42 PM](https://user-images.githubusercontent.com/27291717/128552604-fdace2de-46a9-4d3c-9654-8d8ea00d135e.png)

The `@task` annotated tasks I added for flow runs are "classes" because they're decorated into one but the class name is parsed and displayed the full function signature

Resolving patch:
diff --git a/docs/generate_docs.py b/docs/generate_docs.py
--- a/docs/generate_docs.py
+++ b/docs/generate_docs.py
@@ -334,13 +334,14 @@ def format_subheader(obj, level=1, in_table=False):
     if inspect.isclass(obj):
         header = "## {}\n".format(obj.__name__)
     elif not in_table:
-        header = "##" + "#" * level
+        header = "##" + ("#" * level) + " {}\n".format(obj.__name__)
     else:
         header = "|"
     is_class = '<p class="prefect-sig">class </p>' if inspect.isclass(obj) else ""
     class_name = f'<p class="prefect-class">{create_absolute_path(obj)}</p>'
     div_class = "class-sig" if is_class else "method-sig"
-    div_tag = f"<div class='{div_class}' id='{slugify(create_absolute_path(obj))}'>"
+    block_id = slugify(create_absolute_path(obj)) or obj.__name__
+    div_tag = f"<div class='{div_class}' id='{'method' + block_id if block_id[0] is '-' else block_id}'>"
 
     call_sig = f" {header} {div_tag}{is_class}{class_name}({class_sig}){get_source(obj)}</div>\n\n"
     return call_sig


Test patch:
Repository: PrefectHQ/prefect

Issue:
Allow subclasses of DaskExecutor to receive worker events
## Current behavior

Currently the DaskScheduler has a [`_watch_dask_events()`](https://github.com/PrefectHQ/prefect/blob/0dfbe5b3d176a6f72ee998c349747b34328618af/src/prefect/executors/dask.py#L241) method. It just logs a message when a worker is added or removed.

## Proposed behavior

It would be handy for subclasses of the `DaskScheduler` to be able to handle these worker added/removed messages itself, without needing to re-implement the worker status subscriptions (there is a fair bit of code around closing the communication channel and handling an apparent Dask bug).

## Example

Imagine you where running a Dask cluster on Kubernetes and you wanted to implement something that would tail worker logs using the k8s Python client. You could override the `on_scheduler_message` callback to implement this quite easily.

```python
class MyDaskScheduler(DaskScheduler):
    async def on_scheduler_message(self, op, message):
        if op == "add":
            tail_kubernetes_logs(message['worker'])
```


Discussion:

Resolving patch:
diff --git a/src/prefect/executors/dask.py b/src/prefect/executors/dask.py
--- a/src/prefect/executors/dask.py
+++ b/src/prefect/executors/dask.py
@@ -238,6 +238,20 @@ def start(self) -> Iterator[None]:
         finally:
             self.client = None
 
+    async def on_worker_status_changed(self, op: str, message: dict) -> None:
+        """
+        This method is triggered when a worker is added or removed from the cluster.
+
+        Args:
+            - op (str): Either "add" or "remove"
+            - message (dict): Information about the event that the scheduler has sent
+        """
+        if op == "add":
+            for worker in message.get("workers", ()):
+                self.logger.debug("Worker %s added", worker)
+        elif op == "remove":
+            self.logger.debug("Worker %s removed", message)
+
     async def _watch_dask_events(self) -> None:
         scheduler_comm = None
         comm = None
@@ -260,11 +274,7 @@ async def _watch_dask_events(self) -> None:
                 except OSError:
                     break
                 for op, msg in msgs:
-                    if op == "add":
-                        for worker in msg.get("workers", ()):
-                            self.logger.debug("Worker %s added", worker)
-                    elif op == "remove":
-                        self.logger.debug("Worker %s removed", msg)
+                    await self.on_worker_status_changed(op, msg)
         except asyncio.CancelledError:
             pass
         except Exception:


Test patch:
Repository: PrefectHQ/prefect

Issue:
Marshmallow Deprecation Warning
## Opened from the [Prefect Public Slack Community](https://prefect.io/slack)

**elliot**: Hey folks is anyone else getting a deprecation warning on marshmallow? Something like:

```
...
/home/rof/.pyenv/versions/3.9.1/lib/python3.9/site-packages/marshmallow/fields.py:198
/home/rof/.pyenv/versions/3.9.1/lib/python3.9/site-packages/marshmallow/fields.py:198: RemovedInMarshmallow4Warning: Passing field metadata as a keyword arg is deprecated. Use the explicit `metadata=...` argument instead.
...
```

Tried to update to the latest version of prefect and still no joy!

**holm.noah**: Yes, I suppose some changes in the usage still needs to be performed

**kevin701**: Hi <@U01A5UMH7HT>! I’ll bring this up to the team.

**elliot**: Awesome thanks :+1:

**kevin701**: Do you have a simple flow to reproduce this and what is your Prefect version?

**kevin701**: Can you try with Python 3.8 as well because 3.9 is experimental?

**holm.noah**: Hey Kevin, I’ve seen this on Python 3.8 when using `prefect.utilities.debug.is_serializable` from pytest.

**kevin701**: Perfect thanks for the info.

**kevin701**: <@ULVA73B9P> open “Marshmallow Deprecation Warning”

Original thread can be found [here](https://prefect-community.slack.com/archives/CL09KU1K7/p1621242234189600?thread_ts=1621242234.189600&cid=CL09KU1K7).




Discussion:

Resolving patch:
diff --git a/src/prefect/serialization/schedule.py b/src/prefect/serialization/schedule.py
--- a/src/prefect/serialization/schedule.py
+++ b/src/prefect/serialization/schedule.py
@@ -153,7 +153,7 @@ class Meta:
     start_date = DateTimeTZ(allow_none=True)
     end_date = DateTimeTZ(allow_none=True)
     parameter_defaults = fields.Dict(
-        key=fields.Str(), values=JSONCompatible(), allow_none=True
+        keys=fields.Str(), values=JSONCompatible(), allow_none=True
     )
     labels = fields.List(fields.Str(), allow_none=True)
 


Test patch:
Repository: PrefectHQ/prefect

Issue:
Add toggle to disable ASCII logo display at startup
## Opened from the [Prefect Public Slack Community](https://prefect.io/slack)

**pat**: This is a pretty minor problem as these things go, but it would be great if there was a way to disable the ASCII logo in Prefect Agent and Prefect Server, since it pollutes our server logs in DataDog. I can go hack the code, in Prefect, but it seems inelegant to have to re-apply such code after every version upgrade. Thanks!

**kevin701**: I actually don’t think there is a way but we can open a feature request for this

**kevin701**: <@ULVA73B9P> open “Feature Request: flag to disable ASCII logo”

Original thread can be found [here](https://prefect-community.slack.com/archives/C014Z8DPDSR/p1648654740787619?thread_ts=1648654740.787619&cid=C014Z8DPDSR).




Discussion:
@madkinsz can I take this up. Any guidance would be awesome
Sure, we have a `--hide-welcome` flag for the agent in v2. I'd welcome the same flag on any of the CLI commands here to hide the ASCII art and any other messages unrelated to the services like "Welcome to Prefect".

Thanks!

Resolving patch:
diff --git a/src/prefect/cli/server.py b/src/prefect/cli/server.py
--- a/src/prefect/cli/server.py
+++ b/src/prefect/cli/server.py
@@ -508,6 +508,12 @@ def config_cmd(
     is_flag=True,
     hidden=True,
 )
+@click.option(
+    "--hide-welcome",
+    help="Pass this flag to hide the ASCII welcome message",
+    is_flag=True,
+    hidden=True,
+)
 def start(
     version,
     ui_version,
@@ -530,6 +536,7 @@ def start(
     no_server_port,
     use_volume,
     volume_path,
+    hide_welcome,
 ):
     """
     This command spins up all infrastructure and services for the Prefect Core server
@@ -576,6 +583,7 @@ def start(
     \b
         --detach, -d                Detached mode. Runs Server containers in the background
         --skip-pull                 Flag to skip pulling new images (if available)
+        --hide-welcome              Flag to hide the ASCII welcome message
     """
     # set external postgres flag if the user has provided `--postgres-url`
     if postgres_url is not None:
@@ -647,7 +655,8 @@ def start(
                     # Create a default tenant if no tenant exists
                     if not client.get_available_tenants():
                         client.create_tenant(name="default")
-                    print(ascii_welcome(ui_port=str(ui_port)))
+                    if not hide_welcome:
+                        print(ascii_welcome(ui_port=str(ui_port)))
                 except Exception:
                     time.sleep(0.5)
                     pass


Test patch:
Repository: PrefectHQ/prefect

Issue:
Git storage still requires repo even if provided full clone URL
## Description
<!-- A clear description of the bug -->
#4870 introduced support for custom URLs in `Git` storage. However, the `repo` parameter is still required, so user needs to pass a placeholder value for it even if choosing to use `git_clone_url_secret_name`. This however results in a warning:

```
Git storage initialized with a `git_clone_url_secret_name`. The value of this Secret will be used to clone the repository, ignoring `repo`, `repo_host`, `git_token_secret_name`,  `git_token_username`, `use_ssh`, and `format_access_token`
```



Discussion:
Thanks for the report @Trymzet - should be an easy fix.
Seems like this is broken again, this time due to a `ValidationError` upon registering the flow:
```python
ValueError: Flow could not be deserialized successfully. Error was: ValidationError({'storage': {'repo': ['Field may not be null.']}})
```
It seems like the `GitSchema` class is the culprit, making `repo`, as well as `repo_host` required again, even when passing `git_clone_url_secret_name`.
Any update on this? I have 100% of my flows currently running off Git storage, and I get this warning message on every single flow run. I am only using the `git_clone_url_secret_name` property, yet `repo` is still required, otherwise can't register flow.
Same thing @ccueto36 , we get this annoying warning on all of our 300+ flows :D however we're still running on prefect 0.15.11 so it may have been fixed already?

Resolving patch:
diff --git a/src/prefect/serialization/storage.py b/src/prefect/serialization/storage.py
--- a/src/prefect/serialization/storage.py
+++ b/src/prefect/serialization/storage.py
@@ -157,7 +157,7 @@ class Meta:
         object_class = Git
 
     flow_path = fields.String(allow_none=False)
-    repo = fields.String(allow_none=False)
+    repo = fields.String(allow_none=True)
     repo_host = fields.String(allow_none=False)
     flow_name = fields.String(allow_none=True)
     git_token_secret_name = fields.String(allow_none=True)


Test patch:
Repository: PrefectHQ/prefect

Issue:
Typo in /src/prefect/tasks/sftp/__init__.py

[init.py](https://github.com/PrefectHQ/prefect/blob/master/src/prefect/tasks/sftp/__init__.py)
Mistakenly imported several  times `SftpDownload` instead  of pair : `SftpDownload` and `SftpUpload`


Discussion:

Resolving patch:
diff --git a/src/prefect/tasks/sftp/__init__.py b/src/prefect/tasks/sftp/__init__.py
--- a/src/prefect/tasks/sftp/__init__.py
+++ b/src/prefect/tasks/sftp/__init__.py
@@ -2,7 +2,7 @@
 Tasks for interacting with any SFTP server.
 """
 try:
-    from prefect.tasks.sftp.sftp import SftpDownload, SftpDownload
+    from prefect.tasks.sftp.sftp import SftpDownload, SftpUpload
 except ImportError as err:
     raise ImportError(
         'prefect.tasks.sftp` requires Prefect to be installed with the "sftp" extra.'


Test patch:
Repository: PrefectHQ/prefect

Issue:
Databricks GitSource needs to be passed upon .run invocation but won't work if passed at task construction
## Description
Because I have been sloppy, I forgot to add a parameter to the annotation here https://github.com/PrefectHQ/prefect/blob/f3c8b8150897997372339a4690a2de055fd40717/src/prefect/tasks/databricks/databricks_submitjob.py#L1002 which result in the attribute being defaulted to None unless specified in other ways.




## Expected Behavior
If you set a Git Source at constructor time, this should just work





Discussion:

Resolving patch:
diff --git a/src/prefect/tasks/databricks/databricks_submitjob.py b/src/prefect/tasks/databricks/databricks_submitjob.py
--- a/src/prefect/tasks/databricks/databricks_submitjob.py
+++ b/src/prefect/tasks/databricks/databricks_submitjob.py
@@ -1000,6 +1000,7 @@ def convert_dict_to_kwargs(input: Dict[str, Any]) -> Dict[str, Any]:
         "polling_period_seconds",
         "databricks_retry_limit",
         "databricks_retry_delay",
+        "git_source",
     )
     def run(
         self,


Test patch:
Repository: PrefectHQ/prefect

Issue:
Add the ability to update a flow run's tag field using the "OrionClient.update_flow_run" method
### Prefect Version

2.x

### Describe the proposed behavior

The `OrionClient.update_flow_run`  method is missing the ability to update a flow run's tags. 

### Describe the current behavior

You do not have a tag parameter thus you cannot update said field

### Example Use

_No response_

### Additional context

_No response_


Discussion:

Resolving patch:
diff --git a/src/prefect/client.py b/src/prefect/client.py
--- a/src/prefect/client.py
+++ b/src/prefect/client.py
@@ -615,9 +615,10 @@ async def create_flow_run(
     async def update_flow_run(
         self,
         flow_run_id: UUID,
-        flow_version: str = None,
-        parameters: dict = None,
-        name: str = None,
+        flow_version: Optional[str] = None,
+        parameters: Optional[dict] = None,
+        name: Optional[str] = None,
+        tags: Optional[Iterable[str]] = None,
     ) -> None:
         """
         Update a flow run's details.
@@ -638,6 +639,8 @@ async def update_flow_run(
             params["parameters"] = parameters
         if name is not None:
             params["name"] = name
+        if tags is not None:
+            params["tags"] = tags
 
         flow_run_data = schemas.actions.FlowRunUpdate(**params)
 


Test patch:
diff --git a/tests/test_client.py b/tests/test_client.py
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -14,7 +14,7 @@
 
 import prefect.context
 import prefect.exceptions
-from prefect import flow
+from prefect import flow, tags
 from prefect.client import OrionClient, PrefectHttpxClient, get_client
 from prefect.orion import schemas
 from prefect.orion.api.server import ORION_API_VERSION, create_app
@@ -879,12 +879,35 @@ def foo():
 
     # Fields updated when set
     await orion_client.update_flow_run(
-        flow_run.id, flow_version="foo", parameters={"foo": "bar"}, name="test"
+        flow_run.id,
+        flow_version="foo",
+        parameters={"foo": "bar"},
+        name="test",
+        tags=["hello", "world"],
     )
     updated_flow_run = await orion_client.read_flow_run(flow_run.id)
     assert updated_flow_run.flow_version == "foo"
     assert updated_flow_run.parameters == {"foo": "bar"}
     assert updated_flow_run.name == "test"
+    assert updated_flow_run.tags == ["hello", "world"]
+
+
+async def test_update_flow_run_overrides_tags(orion_client):
+    @flow(name="test_update_flow_run_tags__flow")
+    def hello(name):
+        return f"Hello {name}"
+
+    with tags("goodbye", "cruel", "world"):
+        state = hello("Marvin", return_state=True)
+
+    flow_run = await orion_client.read_flow_run(state.state_details.flow_run_id)
+
+    await orion_client.update_flow_run(
+        flow_run.id,
+        tags=["hello", "world"],
+    )
+    updated_flow_run = await orion_client.read_flow_run(flow_run.id)
+    assert updated_flow_run.tags == ["hello", "world"]
 
 
 async def test_create_then_read_task_run(orion_client):
Repository: PrefectHQ/prefect

Issue:
Add type hints to state predicates
### First check

- [X] I added a descriptive title to this issue.
- [X] I used the GitHub search to find a similar request and didn't find it.
- [X] I searched the Prefect documentation for this feature.

### Prefect Version

2.x

### Describe the proposed behavior

Add type hints
- Downstream users won't get mypy errors

### Describe the current behavior

No type hints
- Downstream users get mypy errors

### Example Use

_No response_

### Additional context

_No response_


Discussion:

Resolving patch:
diff --git a/src/prefect/orion/schemas/states.py b/src/prefect/orion/schemas/states.py
--- a/src/prefect/orion/schemas/states.py
+++ b/src/prefect/orion/schemas/states.py
@@ -191,28 +191,28 @@ def default_scheduled_start_time(cls, values):
                 state_details.scheduled_time = pendulum.now("utc")
         return values
 
-    def is_scheduled(self):
+    def is_scheduled(self) -> bool:
         return self.type == StateType.SCHEDULED
 
-    def is_pending(self):
+    def is_pending(self) -> bool:
         return self.type == StateType.PENDING
 
-    def is_running(self):
+    def is_running(self) -> bool:
         return self.type == StateType.RUNNING
 
-    def is_completed(self):
+    def is_completed(self) -> bool:
         return self.type == StateType.COMPLETED
 
-    def is_failed(self):
+    def is_failed(self) -> bool:
         return self.type == StateType.FAILED
 
-    def is_crashed(self):
+    def is_crashed(self) -> bool:
         return self.type == StateType.CRASHED
 
-    def is_cancelled(self):
+    def is_cancelled(self) -> bool:
         return self.type == StateType.CANCELLED
 
-    def is_final(self):
+    def is_final(self) -> bool:
         return self.type in TERMINAL_STATES
 
     def copy(self, *, update: dict = None, reset_fields: bool = False, **kwargs):


Test patch: