anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: funcx-faas/funcx
Issue: init_blocks needs to be 0 for kubernetes provider

When `init_blocks` is not set to 0 with kubernetes providers, funcx-endpoint raises the following exception:

```020-09-01 20:28:46.249 interchange:300 [INFO]  Scaling ...
2020-09-01 20:28:46.249 interchange:254 [ERROR]  Caught exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/funcx_endpoint/executors/high_throughput/interchange.py", line 252, in __init__
    self.load_config()
  File "/usr/local/lib/python3.6/site-packages/funcx_endpoint/executors/high_throughput/interchange.py", line 301, in load_config
    self.scale_out(self.config.provider.init_blocks)
  File "/usr/local/lib/python3.6/site-packages/funcx_endpoint/executors/high_throughput/interchange.py", line 802, in scale_out
    internal_block = self.config.provider.submit(launch_cmd, 1)
TypeError: submit() missing 1 required positional argument: 'task_type'
```

It should either raise a more informative exception to the user or ignore `init_blocks` for k8s.

Changed files:
funcx_endpoint/funcx_endpoint/providers/kubernetes/kube.py

diff --git a/funcx_endpoint/funcx_endpoint/providers/kubernetes/kube.py b/funcx_endpoint/funcx_endpoint/providers/kubernetes/kube.py
index 2d2766bb..adf5296a 100644
--- a/funcx_endpoint/funcx_endpoint/providers/kubernetes/kube.py
+++ b/funcx_endpoint/funcx_endpoint/providers/kubernetes/kube.py
@@ -30,7 +30,7 @@ class KubernetesProvider(ExecutionProvider, RepresentationMixin):
     nodes_per_block : int
         Nodes to provision per block.
     init_blocks : int
-        Number of blocks to provision at the start of the run. Default is 1.
+        Number of blocks to provision at the start of the run. Default is 0.
     min_blocks : int
         Minimum number of blocks to maintain.
     max_blocks : int
@@ -77,7 +77,7 @@ class KubernetesProvider(ExecutionProvider, RepresentationMixin):
                  image: str,
                  namespace: str = 'default',
                  nodes_per_block: int = 1,
-                 init_blocks: int = 4,
+                 init_blocks: int = 0,
                  min_blocks: int = 0,
                  max_blocks: int = 10,
                  max_cpu: float = 2,
Repository: funcx-faas/funcx
Issue: Exceptions when task is pending is vague and unhandleable

**Describe the bug**
Using the funcx client's `client.get_result(<task_uuid>)` returns a naked `Exception` with a message in it when the task is pending. Due to this exception not being typed better, it is very difficult to programmatically handle this. 

**To Reproduce**
Steps to reproduce the behavior, for e.g:
1. Run a slow function
2. Do `funcx_client.get_result(<task_uuid_of_slow_function>)`
3. Get the `Exception('waiting-for-ep')` exception
4. Be annoyed because a try block cannot differentiate this from an arbitrary exception

**Expected behavior**
The client should raise a clearly typed exception, say, `funcx.sdk.errors.TaskPending` or `TaskNotComplete`


Changed files:
funcx_sdk/funcx/sdk/client.py, funcx_sdk/funcx/utils/errors.py

diff --git a/funcx_sdk/funcx/sdk/client.py b/funcx_sdk/funcx/sdk/client.py
index ab24608b..03b6f6a1 100644
--- a/funcx_sdk/funcx/sdk/client.py
+++ b/funcx_sdk/funcx/sdk/client.py
@@ -14,7 +14,7 @@ from funcx.serialize import FuncXSerializer
 # from funcx.sdk.utils.futures import FuncXFuture
 from funcx.sdk.error_handling_client import FuncXErrorHandlingClient
 from funcx.sdk.utils.batch import Batch
-from funcx.utils.errors import FailureResponse, VersionMismatch, SerializationError
+from funcx.utils.errors import FailureResponse, VersionMismatch, SerializationError, TaskPending
 from funcx.utils.handle_service_response import handle_response_errors
 
 try:
@@ -249,7 +249,7 @@ class FuncXClient(FuncXErrorHandlingClient):
         """
         task = self.get_task(task_id)
         if task['pending'] is True:
-            raise Exception(task['status'])
+            raise TaskPending(task['status'])
         else:
             if 'result' in task:
                 return task['result']
diff --git a/funcx_sdk/funcx/utils/errors.py b/funcx_sdk/funcx/utils/errors.py
index 77a3857d..75967ed2 100644
--- a/funcx_sdk/funcx/utils/errors.py
+++ b/funcx_sdk/funcx/utils/errors.py
@@ -111,3 +111,14 @@ class InvalidScopeException(FuncxError):
 
     def __repr__(self):
         return "Invalid Scope: {}".format(self.message)
+
+
+class TaskPending(FuncxError):
+    """Task is pending and no result is available yet
+    """
+
+    def __init__(self, reason):
+        self.reason = reason
+
+    def __repr__(self):
+        return "Task is pending due to {self.reason}"
Repository: funcx-faas/funcx
Issue: funcx endpoint shows disconnected due to process name check

**Describe the bug**
On macos, the name of an endpoint process is the python version, rather than `funcx-endpoint`. This means we cannot use process name check to confirm that the process pid number is in fact the endpoint.

**Expected behavior**
A working endpoint should be listed as 'Running', not 'Disconnected


Changed files:
funcx_endpoint/funcx_endpoint/endpoint/endpoint_manager.py

diff --git a/funcx_endpoint/funcx_endpoint/endpoint/endpoint_manager.py b/funcx_endpoint/funcx_endpoint/endpoint/endpoint_manager.py
index b022ffea..da91e4b8 100644
--- a/funcx_endpoint/funcx_endpoint/endpoint/endpoint_manager.py
+++ b/funcx_endpoint/funcx_endpoint/endpoint/endpoint_manager.py
@@ -412,18 +412,17 @@ class EndpointManager:
                 "active": False
             }
 
-        older_pid = int(open(filepath, 'r').read().strip())
+        pid = int(open(filepath, 'r').read().strip())
 
         active = False
         try:
-            proc = psutil.Process(older_pid)
-            if proc.name() == match_name:
-                # this is the only case where the endpoint is active.
-                # If the process name does not match or no process exists,
-                # it means the endpoint has been terminated without proper cleanup
-                active = True
+            psutil.Process(pid)
         except psutil.NoSuchProcess:
             pass
+        else:
+            # this is the only case where the endpoint is active. If no process exists,
+            # it means the endpoint has been terminated without proper cleanup
+            active = True
 
         return {
             "exists": True,
Repository: moonstream-to/api
Issue: No more hung rollbacks!

We are seeing too many production errors on Moonstream crawlers and API that look like this:

```
sqlalchemy.exc.PendingRollbackError: Can't reconnect until invalid transaction is rolled back. (Background on this error at: https://sqlalche.me/e/14/8s2b)
```

([SQLAlchemy documentation on error details](https://docs.sqlalchemy.org/en/14/errors.html#error-8s2b))

We should go through the code, `git grep ".commit("` and make sure that we are correctly handling exceptions and rolling back transactions *everywhere*.

Changed files:
crawlers/mooncrawl/mooncrawl/moonworm_crawler/continuous_crawler.py

diff --git a/crawlers/mooncrawl/mooncrawl/moonworm_crawler/continuous_crawler.py b/crawlers/mooncrawl/mooncrawl/moonworm_crawler/continuous_crawler.py
index fd99c93e..85eeade5 100644
--- a/crawlers/mooncrawl/mooncrawl/moonworm_crawler/continuous_crawler.py
+++ b/crawlers/mooncrawl/mooncrawl/moonworm_crawler/continuous_crawler.py
@@ -252,6 +252,7 @@ def continuous_crawler(
                 start_block = end_block + 1
                 failed_count = 0
             except Exception as e:
+                db_session.rollback()
                 logger.error(f"Internal error: {e}")
                 logger.exception(e)
                 failed_count += 1