Skip to content

Commit

Permalink
Scottx611x/workflow launching and monitoring (#1949)
Browse files Browse the repository at this point in the history
* Add galaxy_workflow_task_group_id field to AnalysisStatus

* Add field `galaxy_import_state` to AnalysisStatus

* Update docstring

* Organize analysis_manager.tasks

* Add some constants to Tool model

* Add methods to Tool model

* Update docstring

* Add test coverage

* Add decorators to designate methods for specific Tool types

* Update tests

* Fix Test

* Add test coverage for `_get_nesting_string`

* Organizing these methods in a prior commit made for a difficult to read diff, and isn't crucial

* Remove redundant decorator

* Remove redundant tests

* Remove unutilized function

* Designate `_launch_workflow` to only work for workflow-based tools

* Add test for update_galaxy_data

* Add test coverage for `_invoke_tool_based_galaxy_workflow`

* Rename method and adhere to style guide

* Fix naming

* Consolidate migrations

* Just use a placeholder method for now

* DRY

* Add appropriate error msg and fail task

* Fix typo

* Update docdtring

* Fix test

* Add test coverage for `_check_galaxy_history_state`

* Polymorphic approach for Tools since Tools were becoming too heavily saturated with Workflow-based Tool specific methods

* Add test coverage for `_run_tool_based_galaxy_file_import`

* Consolidate migrations

* Add `galaxy_connection` property and more class methods to WorkflowTool

* Add `set_galaxy_workflow_task_group_id` to AnalysisStatus

* Utilize `set_galaxy_workflow_task_group_id()`

* Update test mock arg order, add test coverage for `_run_tool_based_galaxy_workflow`

* Add test coverage

* Fix test

* Add api test to check that polymorphism behaves appropriately

* DRY

* Fix Tests

* Fix ordering of arguments

* Method renaming and Docstring updates

* Rename method to: `import_library_dataset_to_history`

* We already have access to the analysis through Tool here

* Add abstract `launch()` to Tool and test it

* Refactor `_get_nesting_string` into another step: `_flatten_file_relationships_nesting`

* Pull out parameters common to both Tools and ToolDefinitions and use splat syntax

* Set this value upon a Tool's creation

* DRY and style fix

* Add test coverage for `_flatten_file_relationships_nesting()`

* Update `_get_file_relationships_galaxy` to access value at new location
  • Loading branch information
scottx611x committed Aug 1, 2017
1 parent 49ce577 commit 0b88aa4
Show file tree
Hide file tree
Showing 12 changed files with 1,185 additions and 273 deletions.
27 changes: 27 additions & 0 deletions refinery/analysis_manager/migrations/0003_auto_20170726_1601.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import django_extensions.db.fields


class Migration(migrations.Migration):

dependencies = [
('analysis_manager', '0002_analysisstatus_galaxy_import_progress'),
]

operations = [
migrations.AddField(
model_name='analysisstatus',
name='galaxy_import_state',
field=models.CharField(blank=True, max_length=10, choices=[(b'SUCCESS', b'OK'), (b'FAILURE', b'Error'), (b'PROGRESS', b'Running'), (b'PENDING', b'Unknown')]),
preserve_default=True,
),
migrations.AddField(
model_name='analysisstatus',
name='galaxy_workflow_task_group_id',
field=django_extensions.db.fields.UUIDField(max_length=36, null=True, editable=False, blank=True),
preserve_default=True,
),
]
33 changes: 31 additions & 2 deletions refinery/analysis_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class AnalysisStatus(models.Model):
auto=False)
galaxy_import_task_group_id = UUIDField(blank=True, null=True, auto=False)
galaxy_export_task_group_id = UUIDField(blank=True, null=True, auto=False)
galaxy_workflow_task_group_id = UUIDField(blank=True,
null=True,
auto=False)
#: state of Galaxy file imports
galaxy_import_state = CharField(max_length=10, blank=True,
choices=GALAXY_HISTORY_STATES)
#: state of Galaxy history
galaxy_history_state = CharField(max_length=10, blank=True,
choices=GALAXY_HISTORY_STATES)
Expand All @@ -42,22 +48,37 @@ def __unicode__(self):
return self.analysis.name

def set_galaxy_history_state(self, state):
"""
Set the `galaxy_history_state` of an analysis
:param state: a valid GALAXY_HISTORY_STATE
"""
if state in dict(self.GALAXY_HISTORY_STATES).keys():
self.galaxy_history_state = state
self.save()
else:
raise ValueError("Invalid Galaxy history state given")

def set_galaxy_import_state(self, state):
"""
Set the `galaxy_import_state` of an analysis
:param state: a valid GALAXY_HISTORY_STATE
"""
if state in dict(self.GALAXY_HISTORY_STATES).keys():
self.galaxy_import_state = state
self.save()
else:
raise ValueError("Invalid Galaxy history state given")

def refinery_import_state(self):
return get_task_group_state(self.refinery_import_task_group_id)

def galaxy_file_import_state(self):
return get_task_group_state(self.galaxy_import_task_group_id)

def tool_based_galaxy_file_import_state(self):
if self.galaxy_history_state and self.galaxy_import_progress != 0:
if self.galaxy_import_state and self.galaxy_import_progress != 0:
galaxy_file_import_state = [{
'state': self.galaxy_history_state,
'state': self.galaxy_import_state,
'percent_done': self.galaxy_import_progress
}]
else:
Expand All @@ -77,6 +98,14 @@ def galaxy_analysis_state(self):
def galaxy_export_state(self):
return get_task_group_state(self.galaxy_export_task_group_id)

def set_galaxy_import_task_group_id(self, galaxy_import_task_group_id):
self.galaxy_import_task_group_id = galaxy_import_task_group_id
self.save()

def set_galaxy_workflow_task_group_id(self, galaxy_workflow_task_group_id):
self.galaxy_workflow_task_group_id = galaxy_workflow_task_group_id
self.save()


def get_task_group_state(task_group_id):
"""return a list containing states of all tasks given a task set ID"""
Expand Down

0 comments on commit 0b88aa4

Please sign in to comment.