Repository: Parsl/parsl

Issue:
Always use a fresh `ignore_for_cache`
A bug is causing the tests to fail in #1182, the error can be found [here](https://travis-ci.com/github/Parsl/parsl/jobs/323140049):
```
DEBUG    parsl.dataflow.memoization:memoization.py:159 Ignoring these kwargs for checkpointing: ['stdout']
DEBUG    parsl.dataflow.memoization:memoization.py:161 Ignoring kwarg stdout
DEBUG    parsl.dataflow.dflow:dflow.py:427 Got an exception launching task
Traceback (most recent call last):
  File "/home/travis/build/Parsl/parsl/parsl/dataflow/dflow.py", line 418, in launch_if_ready
    task_id, task_record['func'], *new_args, **kwargs)
  File "/home/travis/build/Parsl/parsl/parsl/dataflow/dflow.py", line 484, in launch_task
    memo_fu = self.memoizer.check_memo(task_id, self.tasks[task_id])
  File "/home/travis/build/Parsl/parsl/parsl/dataflow/memoization.py", line 199, in check_memo
    hashsum = self.make_hash(task)
  File "/home/travis/build/Parsl/parsl/parsl/dataflow/memoization.py", line 162, in make_hash
    del filtered_kw[k]
KeyError: 'stdout'
```

But note that the failure happens in `test_memoize.py` when the new test was added in `test_stdout.py`. I think this is due to us passing around a mutable default value `ignore_for_cache=[]` in various places; when we add `stdout` and `stderr` to `ignore_for_cache` when `stdout=parsl.AUTO_LOGNAME` is passed in the app signature, that gets propagated later unexpectedly.



Discussion:

Resolving patch:
diff --git a/parsl/app/app.py b/parsl/app/app.py
--- a/parsl/app/app.py
+++ b/parsl/app/app.py
@@ -19,7 +19,7 @@ class AppBase(metaclass=ABCMeta):
 
     """
 
-    def __init__(self, func, data_flow_kernel=None, executors='all', cache=False, ignore_for_cache=[]):
+    def __init__(self, func, data_flow_kernel=None, executors='all', cache=False, ignore_for_cache=None):
         """Construct the App object.
 
         Args:
@@ -75,7 +75,7 @@ def __call__(self, *args, **kwargs):
         pass
 
 
-def python_app(function=None, data_flow_kernel=None, cache=False, executors='all', ignore_for_cache=[]):
+def python_app(function=None, data_flow_kernel=None, cache=False, executors='all', ignore_for_cache=None):
     """Decorator function for making python apps.
 
     Parameters
@@ -108,7 +108,7 @@ def wrapper(f):
     return decorator
 
 
-def bash_app(function=None, data_flow_kernel=None, cache=False, executors='all', ignore_for_cache=[]):
+def bash_app(function=None, data_flow_kernel=None, cache=False, executors='all', ignore_for_cache=None):
     """Decorator function for making bash apps.
 
     Parameters
diff --git a/parsl/app/bash.py b/parsl/app/bash.py
--- a/parsl/app/bash.py
+++ b/parsl/app/bash.py
@@ -110,7 +110,7 @@ def open_std_fd(fdname):
 
 class BashApp(AppBase):
 
-    def __init__(self, func, data_flow_kernel=None, cache=False, executors='all', ignore_for_cache=[]):
+    def __init__(self, func, data_flow_kernel=None, cache=False, executors='all', ignore_for_cache=None):
         super().__init__(func, data_flow_kernel=data_flow_kernel, executors=executors, cache=cache, ignore_for_cache=ignore_for_cache)
         self.kwargs = {}
 
diff --git a/parsl/dataflow/dflow.py b/parsl/dataflow/dflow.py
--- a/parsl/dataflow/dflow.py
+++ b/parsl/dataflow/dflow.py
@@ -663,7 +663,7 @@ def sanitize_and_wrap(self, task_id, args, kwargs):
 
         return new_args, kwargs, dep_failures
 
-    def submit(self, func, app_args, executors='all', fn_hash=None, cache=False, ignore_for_cache=[], app_kwargs={}):
+    def submit(self, func, app_args, executors='all', fn_hash=None, cache=False, ignore_for_cache=None, app_kwargs={}):
         """Add task to the dataflow system.
 
         If the app task has the executors attributes not set (default=='all')
@@ -694,6 +694,9 @@ def submit(self, func, app_args, executors='all', fn_hash=None, cache=False, ign
 
         """
 
+        if ignore_for_cache is None:
+            ignore_for_cache = []
+
         if self.cleanup_called:
             raise ValueError("Cannot submit to a DFK that has been cleaned up")
 


Test patch: