Skip to content

Commit fb98173

Browse files
committed
Merge branch 'feature/taskout' into 'develop'
add output_location when creating task See merge request core/sevenbridges-python!100
2 parents e028642 + e91a747 commit fb98173

3 files changed

Lines changed: 50 additions & 1 deletion

File tree

docs/quickstart.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,8 @@ the ``batch_by`` criteria.
14091409

14101410
``execution_settings`` - Execution settings for the task.
14111411

1412+
``output_location`` - Location where task outputs will be stored.
1413+
14121414
``execution_status`` - Task execution status.
14131415

14141416
``price`` - Task cost.

sevenbridges/models/task.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Task(Resource):
6969
inputs = CompoundField(Input, read_only=False)
7070
outputs = CompoundField(Output, read_only=True)
7171
execution_settings = DictField(read_only=True)
72+
output_location = DictField(read_only=True)
7273
use_interruptible_instances = BooleanField(read_only=False)
7374
origin = StringField(read_only=True, name='origin_id')
7475

@@ -141,7 +142,7 @@ def query(cls, project=None, status=None, batch=None,
141142
def create(cls, name, project, app, revision=None, batch_input=None,
142143
batch_by=None, inputs=None, description=None, run=False,
143144
disable_batch=False, interruptible=None,
144-
execution_settings=None, api=None):
145+
execution_settings=None, output_location=None, api=None):
145146

146147
"""
147148
Creates a task on server.
@@ -157,6 +158,8 @@ def create(cls, name, project, app, revision=None, batch_input=None,
157158
:param disable_batch: If True disables batching of a batch task.
158159
:param interruptible: If True interruptible instance will be used.
159160
:param execution_settings: Execution settings for the task.
161+
:param output_location: Dictionary that allows you to define the exact
162+
location where your task outputs will be stored.
160163
:param api: Api instance.
161164
:return: Task object.
162165
:raises: TaskValidationError if validation Fails.
@@ -199,6 +202,9 @@ def create(cls, name, project, app, revision=None, batch_input=None,
199202
if execution_settings:
200203
task_data.update({'execution_settings': execution_settings})
201204

205+
if output_location:
206+
task_data.update({'output_location': output_location})
207+
202208
if run:
203209
params.update({'action': 'run'})
204210

tests/test_tasks.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,47 @@ def test_create_task(api, given, verifier, run):
107107
verifier.task.task_created()
108108

109109

110+
@pytest.mark.parametrize("run", [True, False])
111+
def test_create_task_with_output_location(api, given, verifier, run):
112+
# preconditions
113+
owner = generator.user_name()
114+
project_short_name = generator.slug()
115+
project_id = f'{owner}/{project_short_name}'
116+
given.project.exists(id=project_id)
117+
given.file.files_exist_for_project(project_id, 10)
118+
app_id = f'{owner}/{project_short_name}/app-name'
119+
batch_by = {'type': 'item'}
120+
121+
project = api.projects.get(id=project_id)
122+
files = api.files.query(project=project)
123+
inputs = {
124+
'FastQC': files,
125+
'reads': False,
126+
'some_file': files[0],
127+
'record_input': {"string": "string_input", "file": files[0]}
128+
}
129+
output_location = {
130+
'main_location': '/Analysis/<task_id>_<task_name>/',
131+
'nodes_location': {'b64html': {
132+
'output_location': '/Analysis/<task_id>_<task_name>/'}
133+
}
134+
}
135+
136+
given.task.can_be_created(
137+
batch_by=batch_by, batch_input='FastQC', app=app_id, project=project.id
138+
)
139+
# action
140+
task = api.tasks.create(
141+
generator.name(), project, app_id, batch_input='FastQC',
142+
batch_by=batch_by, inputs=inputs, run=run,
143+
output_location=output_location
144+
)
145+
146+
# verification
147+
assert repr(task)
148+
verifier.task.task_created()
149+
150+
110151
@pytest.mark.parametrize("run", [True, False])
111152
def test_create_task_with_errors(api, given, verifier, run):
112153
# preconditions

0 commit comments

Comments
 (0)