Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat python_app input/output default arguments like other magic keywords, and like bash_app #3489

Merged
merged 8 commits into from
Jul 2, 2024
4 changes: 4 additions & 0 deletions parsl/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def __init__(self, func: Callable,
self.kwargs['walltime'] = params['walltime'].default
if 'parsl_resource_specification' in params:
self.kwargs['parsl_resource_specification'] = params['parsl_resource_specification'].default
if 'outputs' in params:
self.kwargs['outputs'] = params['outputs'].default
if 'inputs' in params:
self.kwargs['inputs'] = params['inputs'].default

@abstractmethod
def __call__(self, *args: Any, **kwargs: Any) -> AppFuture:
Expand Down
25 changes: 25 additions & 0 deletions parsl/tests/test_bash_apps/test_inputs_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pytest

from parsl import AUTO_LOGNAME, Config, bash_app, python_app
from parsl.executors import ThreadPoolExecutor


def local_config():
return Config(executors=[ThreadPoolExecutor()])


@pytest.mark.local
def test_default_inputs():
@python_app
def identity(inp):
return inp

@bash_app
def sum_inputs(inputs=[identity(1), identity(2)], stdout=AUTO_LOGNAME):
calc = sum(inputs)
return f"echo {calc}"

fut = sum_inputs()
fut.result()
with open(fut.stdout, 'r') as f:
assert int(f.read()) == 3
22 changes: 22 additions & 0 deletions parsl/tests/test_python_apps/test_inputs_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest

import parsl
from parsl import python_app
from parsl.executors.threads import ThreadPoolExecutor


def local_config():
return parsl.Config(executors=[ThreadPoolExecutor()])


@pytest.mark.local
def test_default_inputs():
@python_app
def identity(inp):
return inp

@python_app
def add_inputs(inputs=[identity(1), identity(2)]):
return sum(inputs)

assert add_inputs().result() == 3
Loading