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

Scottx611x/td api #1646

Merged
merged 269 commits into from
Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
269 commits
Select commit Hold shift + click to select a range
d7283b8
Cleanup some more tests
scottx611x Oct 21, 2016
c09101a
Add id to aid testing
scottx611x Oct 21, 2016
c38f042
Add id to aid testing
scottx611x Oct 21, 2016
59bb514
Cleanup login method
scottx611x Oct 21, 2016
facf9cb
Abstract out reused login moethod
scottx611x Oct 21, 2016
1222f9c
Utilize relative import
scottx611x Oct 21, 2016
87101a8
Merge branch 'develop' of https://github.com/parklab/refinery-platfor…
scottx611x Oct 21, 2016
41a51c8
PEP8
scottx611x Oct 22, 2016
1fbca66
only run acceptance tests if we detect a build for a PR
scottx611x Nov 1, 2016
28279fb
Always run our acceptance tests
scottx611x Nov 2, 2016
d73351b
Add acceptance tests for user registration and login
scottx611x Nov 2, 2016
be166d8
Don't use separate shell script (for now)
scottx611x Nov 2, 2016
ab0ac77
Remove `cd` comands
scottx611x Nov 3, 2016
363c8f6
Refactor selenium utility functions
scottx611x Nov 3, 2016
3c39ee5
Add script to run acceptance tests on vagrant or travis
scottx611x Nov 16, 2016
6287456
Lower `DEFAULT_WAIT` Now that we aren't relying on SauceLabs VMs
scottx611x Nov 16, 2016
bcce1d9
Cleanup setting of breakpoints, and refactor `cleanup_on_error` decor…
scottx611x Nov 16, 2016
daca73f
Remove unnecessary env var, and re-add `global` as to ensure a single…
scottx611x Nov 16, 2016
aff4cf6
Sauce_connect isn't needed
scottx611x Nov 16, 2016
d1d36fa
pip caching seems stable
scottx611x Nov 16, 2016
8a8dbae
PEP8
scottx611x Nov 16, 2016
28deb1d
Fail shell script if any step doesn't work properly
scottx611x Nov 16, 2016
6419461
GeckoDriver expects a more recent version of Firefox
scottx611x Nov 16, 2016
2e080fb
Remove Comments
scottx611x Nov 17, 2016
c8d0d16
Update Default wait time
scottx611x Nov 17, 2016
c3b3ba8
Bump pytest-selenium version
scottx611x Nov 17, 2016
f5b1de1
Update Comment
scottx611x Nov 17, 2016
bc77da6
Utilize `wait_until_id_clickable`
scottx611x Nov 17, 2016
27a82db
Add tests for global analysis popover
scottx611x Nov 17, 2016
8eb8879
Add tests for Datasets panel
scottx611x Nov 17, 2016
d3edcfc
Update comment
scottx611x Nov 17, 2016
e6b954e
Add a status to all generated Analyses
scottx611x Nov 17, 2016
e90af1f
Update stats test to check for actual object counts
scottx611x Nov 17, 2016
15d2f18
Merge remote-tracking branch 'origin/develop' into scottx611x/accepta…
scottx611x Dec 7, 2016
f4590cb
include gecko driver in our build process for ease of local selenium-…
scottx611x Dec 14, 2016
8971349
Refactor old acceptance test implementation in favor of simplicity an…
scottx611x Dec 14, 2016
2aacd03
Make virtual display bigger
scottx611x Dec 16, 2016
51d955c
Update selenium testing utils
scottx611x Dec 16, 2016
5d1f4c8
Update assert body text method
scottx611x Dec 16, 2016
c979136
Update selenium tests
scottx611x Dec 16, 2016
ea8cdec
Update `wait_until_id_visible()`
scottx611x Dec 16, 2016
07251e7
bump Factory-Boy requirement
scottx611x Dec 19, 2016
bf02ed2
Update travis as mentioned issue has been closed
scottx611x Dec 19, 2016
f1ae2d7
Clean up gecko driver Puppet install
scottx611x Dec 19, 2016
8336ef5
Update docstrings
scottx611x Dec 19, 2016
6f28f41
Remove unnecessary tests
scottx611x Dec 19, 2016
23d37a1
more geckodriver install cleanup
scottx611x Dec 19, 2016
f177930
Change Default wait
scottx611x Dec 19, 2016
fa9f485
update wait_until_id_visible()
scottx611x Dec 19, 2016
9e1c4a8
pull out duplicated code into ui-deletion helper method
scottx611x Dec 19, 2016
3242119
Update acceptance tests
scottx611x Dec 19, 2016
2647818
Minor changes due to abstraction of deletion code
scottx611x Dec 19, 2016
3b6ad6b
Fix typo
scottx611x Dec 19, 2016
1623937
Merge branch 'develop' into scottx611x/acceptance_testing
scottx611x Dec 19, 2016
4f8cfd7
guest user creation isn't needed here anymore
scottx611x Dec 19, 2016
a7c4b75
Merge branch 'scottx611x/acceptance_testing' of https://github.com/pa…
scottx611x Dec 19, 2016
c3fca54
Merge branch scottx611x/django_1.7_upgrade into scottx611x/acceptance…
scottx611x Dec 20, 2016
48707a3
Flip the order of some installed apps due to Django 1.7 ContentType l…
scottx611x Dec 20, 2016
cfd104b
Decorate function as to not test 3rd party code's functionality
scottx611x Dec 20, 2016
db33295
Utilize StaticLiveServerTestCase
scottx611x Dec 20, 2016
6cdccda
Update delete_from_ui() helper
scottx611x Dec 20, 2016
d4fd011
Refactor decorator name to be more verbose
scottx611x Dec 20, 2016
006e551
Don't need to take a screenshot here
scottx611x Dec 20, 2016
0c727cc
Merge branch 'develop' of https://github.com/parklab/refinery-platfor…
scottx611x Jan 5, 2017
913455e
Add xvfb and python3 to travis
scottx611x Jan 6, 2017
2de1b66
add pyvirtualdisplay req
scottx611x Jan 6, 2017
87023b0
Rename geckodriver class to selenium
scottx611x Jan 6, 2017
0af9971
Update order
scottx611x Jan 6, 2017
d6e1b7a
Update order of INSTALLED_APPS for testing purposes
scottx611x Jan 6, 2017
421abdd
Update logging levels
scottx611x Jan 6, 2017
8fce240
Update TEST_RUNNER per Django system-check suggestion
scottx611x Jan 6, 2017
bcae244
Update tests
scottx611x Jan 9, 2017
b6e20c8
Fix `get_or_create()`
scottx611x Jan 9, 2017
a7ff7b1
Access actual object returned from `get_or_create()` tuple
scottx611x Jan 9, 2017
b34d0b6
Update logger statement
scottx611x Jan 9, 2017
84676cf
Do not need to specify `live server` here since it has a default value
scottx611x Jan 9, 2017
b858c70
Update string formatting to work properly
scottx611x Jan 9, 2017
9b018e0
Update isa/pre-isa archive deletion to produce less unnecessary errors
scottx611x Jan 9, 2017
a8c7f9d
Update Tests
scottx611x Jan 9, 2017
69649f7
Manually save public group to sync db between threads (Specific to us…
scottx611x Jan 9, 2017
a2cdebd
Update `DEFAULT_WAIT`
scottx611x Jan 9, 2017
36c820a
Share Datasets upon factory_boy creation
scottx611x Jan 9, 2017
06d8332
Create public group for APIV2 test case
scottx611x Jan 9, 2017
2baf249
Added group creation to the wrong TestCase
scottx611x Jan 9, 2017
15ea435
Remove `django-nose` in favor of Django's new: `DiscoverTestRunner`
scottx611x Jan 11, 2017
5fd9852
Merge remote-tracking branch 'origin/develop' into scottx611x/accepta…
scottx611x Jan 11, 2017
8f82bbd
This file shouldn't exist anymore. Probably wasn't caught in the merg…
scottx611x Jan 11, 2017
a3ca888
Include ontology fixture content inside of a Data migration (#1581)
scottx611x Jan 11, 2017
1de07b3
Update puppet-archive version
scottx611x Jan 11, 2017
118f62a
Utilize `puppet-archive` and clean up neo4j.pp
scottx611x Jan 11, 2017
cb65e95
Cleanup selenium manifest
scottx611x Jan 11, 2017
b3bac64
Factor out solr class from init.pp
scottx611x Jan 11, 2017
90c3d56
don't need to chmod here
scottx611x Jan 11, 2017
2875042
Merge remote-tracking branch 'origin/scottx611x/puppet_refactoring' i…
scottx611x Jan 12, 2017
7d511c8
We are now using StaticLiveServerTestCase
scottx611x Jan 12, 2017
8929648
"Users of the `puppet-archive`module are responsible for archive pack…
scottx611x Jan 12, 2017
5491437
Remove unused var
scottx611x Jan 12, 2017
0263c69
Point to new archive download location
scottx611x Jan 12, 2017
9c0fbba
Fix string formatting error
scottx611x Jan 12, 2017
dbc0f4a
Add `TEST_RUNNER` setting to base.py so that someone testing on `prod…
scottx611x Jan 12, 2017
1449939
update order of `INSTALLED_APPS` addresses: #1353
scottx611x Jan 12, 2017
5650d80
Refactor all tests that interact with the ORM to inherit from `Transa…
scottx611x Jan 12, 2017
3da2ff7
DEFAULT_WAIT Shouldn't be that long
scottx611x Jan 12, 2017
fde1752
Manually save `public group` as to persist data between test and web …
scottx611x Jan 12, 2017
58107fd
Update comment
scottx611x Jan 12, 2017
3093562
Don't need to optimize sole's index in tests
scottx611x Jan 12, 2017
b0421f7
Inherit from TransactionTestCase here
scottx611x Jan 12, 2017
94ea941
`20` was actually a good fail-safe if things get slow for one reason …
scottx611x Jan 12, 2017
afff031
Merge remote-tracking branch 'origin/develop' into scottx611x/accepta…
scottx611x Jan 17, 2017
cbbfbb9
switch order of INSTALLED APPS
scottx611x Jan 17, 2017
c73105e
Cleanup selenium test cases
scottx611x Jan 17, 2017
cfbce11
Merge remote-tracking branch 'origin/develop' into scottx611x/accepta…
scottx611x Jan 27, 2017
bdfa736
Merge remote-tracking branch 'origin/develop' into scottx611x/accepta…
scottx611x Jan 27, 2017
3291651
Remove other `unittest` usages and unnecessary tests
scottx611x Jan 27, 2017
dc9bef1
Override setUp() in a cleaner manner
scottx611x Jan 27, 2017
1996b8f
Add a travis fold
scottx611x Feb 13, 2017
a09ee70
Merge remote-tracking branch 'origin/develop' into scottx611x/accepta…
scottx611x Feb 13, 2017
852f5d9
Clean up FileStoreitem and InvestigationLink error handling
scottx611x Feb 13, 2017
549862a
Clean up error handling for isa & pre-isa archives
scottx611x Feb 13, 2017
7c7d30c
Update comments
scottx611x Feb 13, 2017
da1f038
Cleanup factory_boy factories and utils
scottx611x Feb 13, 2017
e3e644c
This is already a default value
scottx611x Feb 13, 2017
7738c53
DRY
scottx611x Feb 13, 2017
7c5cd7e
Update existing DataMigrations to a more easily manageable format
scottx611x Feb 13, 2017
7bc45f1
More robust Data migrations
scottx611x Feb 14, 2017
106d43b
Remove `pk`
scottx611x Feb 14, 2017
dd7ffa9
Merge remote-tracking branch 'origin/develop' into scottx611x/td_api
scottx611x Feb 14, 2017
cfaad38
Bump DRF version to latest that supports Django 1.7
scottx611x Feb 16, 2017
740f2ee
Add `tools` app
scottx611x Feb 16, 2017
a6e3ecb
Add models
scottx611x Feb 16, 2017
f9c206b
Configure admin ui for new models
scottx611x Feb 16, 2017
40f181e
Add migration
scottx611x Feb 16, 2017
b903e46
Add `tools/definitions/` endpoint
scottx611x Feb 16, 2017
4db9a18
Wrap deletion operations in transactions
scottx611x Feb 17, 2017
3037a04
Merge remote-tracking branch 'origin/scottx611x/safer_object_deletion…
scottx611x Feb 17, 2017
efa40da
Merge remote-tracking branch 'origin/scottx611x/acceptance_testing' i…
scottx611x Feb 17, 2017
8436ee4
Add tools app
scottx611x Feb 17, 2017
3433517
Add factories and utils method to create dummy ToolDefinitions for Te…
scottx611x Feb 17, 2017
3aef070
We don't need `django.setup()` here unless script is being run as a s…
scottx611x Feb 17, 2017
ae9f73b
RunPython is already encapsulated in a transaction
scottx611x Feb 21, 2017
3eabca3
refactor `get_isa_archive()` & `get_pre_isa_archive()`
scottx611x Feb 21, 2017
2e3b0eb
Analysis.status isn't necessary for testing
scottx611x Feb 21, 2017
a4737c4
Add Error Handling to `SeleniumTestBase.setUp()`
scottx611x Feb 21, 2017
3772af3
Allow for proper rendering of self-referential Many-to-Many rels.
scottx611x Feb 21, 2017
85de57a
Update models & serializers
scottx611x Feb 21, 2017
bcf09b0
Add basic ToolDefinition API test case
scottx611x Feb 21, 2017
b31256b
Update Models and Migrations file
scottx611x Feb 22, 2017
e0e3fd9
Add creation of LIST:LIST:PAIR ToolDef to utils script
scottx611x Feb 22, 2017
8c8818c
Update Serializer for more easily readble API Responses
scottx611x Feb 22, 2017
204ced5
Update Tests
scottx611x Feb 22, 2017
cbc2c2b
Add MGMT command to genereate Smaple ToolDefinitions
scottx611x Feb 23, 2017
f52ef0e
Demand users be authenticated to access DRF api endpoints
scottx611x Feb 23, 2017
8264aca
Add more tests for ToolDef API
scottx611x Feb 23, 2017
acdfe17
Refactor DRF API related tests due to newly required Authentication
scottx611x Feb 23, 2017
75d039c
Remove unused `nesting_type` field
scottx611x Feb 23, 2017
e5d883c
Add comment
scottx611x Feb 23, 2017
9035f0d
Add AdminFieldPopulator class
scottx611x Feb 23, 2017
36194b4
Update MGMT command
scottx611x Feb 23, 2017
b211363
Add `TEST_NON_SERIALIZED_APPS` setting due to pre Django 1.9 bug
scottx611x Feb 24, 2017
f01770d
Don't need to share datasets pubilcly in acceptance tests
scottx611x Feb 24, 2017
020ab4c
Utilize `serialized_rollback` to ensure migration data persists in St…
scottx611x Feb 24, 2017
0f2f533
Merge branch 'develop' into scottx611x/acceptance_testing
scottx611x Feb 24, 2017
4be4659
Refactor isa/pre_isa archive fetching into one method
scottx611x Feb 27, 2017
8cd7d1b
Merge branch 'scottx611x/acceptance_testing' of https://github.com/re…
scottx611x Feb 27, 2017
ee5f751
Remove other unnecessary instances of `tearDown()`
scottx611x Feb 27, 2017
77ae8eb
Update method signature
scottx611x Feb 27, 2017
6ba02ad
Update comment
scottx611x Feb 27, 2017
673827a
Fix Test
scottx611x Feb 27, 2017
9fa0a9c
Revert "Fix Test"
scottx611x Feb 27, 2017
356da7e
Don't bundle (pre)isa_archive fetching functionality & Utilize existi…
scottx611x Feb 27, 2017
6ffb5b6
Handle potential AttributeErrors that could occcur
scottx611x Feb 27, 2017
4ebcf91
Rename `tools` to `tool_manager`
scottx611x Feb 27, 2017
15ae348
Merge remote-tracking branch 'origin/scottx611x/acceptance_testing' i…
scottx611x Feb 27, 2017
ff2f90f
Favor APITestCase to ensure initial DB state persists throughout tests
scottx611x Feb 27, 2017
67db7f9
Provide request auth in test for newly secured endpoints
scottx611x Feb 27, 2017
43d1932
Remove transaction context manager
scottx611x Feb 28, 2017
cbe6d0f
Refactor method name
scottx611x Feb 28, 2017
9ed6fa6
Keeping Python 3 in mind
scottx611x Feb 28, 2017
4c32710
Rename field for clarity
scottx611x Feb 28, 2017
288114d
Add comments
scottx611x Feb 28, 2017
b84846c
Fix serializer for newly added fieldname
scottx611x Feb 28, 2017
3c1ad77
django.setup() not necessary (unless running as a standalone script)
scottx611x Feb 28, 2017
069813b
Change `nested_elements` -> `file_relationship` per Model field rename
scottx611x Feb 28, 2017
39b31dc
Reflect lack of POSTing in comment
scottx611x Feb 28, 2017
2d9f960
Fix import ordering
scottx611x Feb 28, 2017
dbf6bd1
Merge remote-tracking branch 'origin/develop' into scottx611x/td_api
scottx611x Feb 28, 2017
ced8135
Merge branch 'develop' into scottx611x/td_api
scottx611x Feb 28, 2017
b6d7da9
Remove MGMT command since its only needed for a short period of time
scottx611x Feb 28, 2017
0d652f2
Migrations due to GalaxyParameter child class
scottx611x Feb 28, 2017
6bf9171
Add useful comment
scottx611x Feb 28, 2017
24b75cf
Remove already default values
scottx611x Feb 28, 2017
2906380
Revert from usage of Generic DRF api perm classes
scottx611x Feb 28, 2017
0bb914e
Change sample data generation to reflect new schema
scottx611x Feb 28, 2017
150ee06
Ensure that Users accessing ToolDefinitions are authenticated
scottx611x Feb 28, 2017
e7e1d86
Rename GalaxyToolParameter to GalaxyParameter
scottx611x Feb 28, 2017
8caef8b
Squash migrations
scottx611x Feb 28, 2017
00b8c02
Old isa_archive deletion tests were of better form
scottx611x Feb 28, 2017
10ab388
Quoted references only necessary for manual avoidance of circ. imports
scottx611x Feb 28, 2017
98e853a
We could have a tool without any Parameters
scottx611x Feb 28, 2017
5683d1c
Cleanup imports
scottx611x Feb 28, 2017
ffbb95a
Remove unutilized APIClient
scottx611x Feb 28, 2017
655e186
Fix ordering of imports
scottx611x Feb 28, 2017
13d7544
Fix migration
scottx611x Feb 28, 2017
daeda15
Remove unnesscessary user creation
scottx611x Feb 28, 2017
ec4d9e8
Remove TearDown
scottx611x Mar 1, 2017
b34d0ff
Remove constraint on ToolDefinition description & rename is_editable …
scottx611x Mar 2, 2017
1e68ebe
Add `galaxy_workflow_step` field and squash migrations
scottx611x Mar 2, 2017
cd5f6a1
Scottx611x/td api url routing (#1622)
scottx611x Mar 3, 2017
e42a70c
Merge remote-tracking branch 'origin/develop' into scottx611x/td_api
scottx611x Mar 16, 2017
606b684
Add the ability to generate basic ToolDefinitons from properly annota…
scottx611x Mar 20, 2017
1ae885a
Merge remote-tracking branch 'origin/develop' into scottx611x/td_api
scottx611x Mar 21, 2017
ca47321
Update Galaxy Parameter Model to include a single field
scottx611x Mar 21, 2017
dd8624f
Update ToolDefinition schema
scottx611x Mar 21, 2017
711b4c3
Separate Parameter and GalaxyParameter schemas
scottx611x Mar 21, 2017
a309026
Add new sample data utilizing Parameters
scottx611x Mar 21, 2017
97992e6
Add tests to check for good and bad parameters in Annotation data
scottx611x Mar 21, 2017
47857b4
Avoid code reuse by extending from other schema
scottx611x Mar 22, 2017
b6842e6
Update test-data and tests to utilize Parameters
scottx611x Mar 22, 2017
f7d1c6b
Add proper deletion of a ToolDefinitions related objects + tests
scottx611x Mar 22, 2017
baa1448
Update Parameter schema
scottx611x Mar 23, 2017
115867d
Update GalaxyParameter schema
scottx611x Mar 23, 2017
f9fbcb2
Add schema to aid in validating Workflows individual step's annotations
scottx611x Mar 23, 2017
70c902d
Add test-data and tests to validate Workflows step's annotations
scottx611x Mar 23, 2017
7bdf956
Rename `validate_workflow_annotation` to `validate_tool_annotation`
scottx611x Mar 23, 2017
b3f42ef
`clear()` is redundant if we are also performing `delete()` here
scottx611x Mar 23, 2017
de9cde5
Include parameter and output_file parsing from step annotations in MG…
scottx611x Mar 23, 2017
ceea62a
Update ParameterSerializer to include/disclude `galaxy_workflow_step`…
scottx611x Mar 23, 2017
bef5a2f
Add sample data and tests for a basic Visualization-based ToolDefinition
scottx611x Mar 23, 2017
4ec44f3
Fix typo and update comment
scottx611x Mar 23, 2017
fa065ed
Update comments
scottx611x Mar 23, 2017
2a6e5b4
Remove extra space
scottx611x Mar 23, 2017
379b72d
RuntimeError is actually being raised here
scottx611x Mar 23, 2017
fab910b
Rename method to create_tool_definition
scottx611x Mar 23, 2017
c470b49
Add API test to check for different Parameter Types
scottx611x Mar 23, 2017
197af3f
Merge remote-tracking branch 'origin/develop' into scottx611x/td_api
scottx611x Mar 23, 2017
98821e7
Merge remote-tracking branch 'origin/develop' into scottx611x/td_api
scottx611x Mar 23, 2017
c182855
Styling fixes
scottx611x Mar 23, 2017
8be855c
Fix comment
scottx611x Mar 23, 2017
c7a195b
Rename pre/post delete handlers
scottx611x Mar 27, 2017
960338c
Fix styling
scottx611x Mar 27, 2017
6e027d8
Fix more styling
scottx611x Mar 27, 2017
3c006ea
Remove newline characters
scottx611x Mar 27, 2017
e1d4f79
Factor out workflow fetching, and cleanup indentation.
scottx611x Mar 27, 2017
cb0d526
Add a sample galaxy `get_workflows()` response for testing purposes
scottx611x Mar 27, 2017
7bce4a6
Test management command functionality with proper `mock` usage
scottx611x Mar 27, 2017
69d5c65
Remove comment explaining "what"
scottx611x Mar 27, 2017
524734d
Revert "Remove comment explaining "what""
scottx611x Mar 27, 2017
2c82cde
Rename `test-data` to `test_data`
scottx611x Mar 27, 2017
b837dee
Utilize logger statements since not in a MGMT command anymore
scottx611x Mar 27, 2017
cdc401e
Handle RuntimeError
scottx611x Mar 27, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
216 changes: 92 additions & 124 deletions refinery/tool_manager/management/commands/generate_tool_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

from django.core.management.base import BaseCommand, CommandError

from bioblend.galaxy.client import ConnectionError

from core.models import WorkflowEngine
from tool_manager.models import ToolDefinition
from ...utils import (ANNOTATION_ERROR_MESSAGE,
create_tool_definition,
get_workflow_list,
validate_tool_annotation,
validate_workflow_step_annotation)

Expand All @@ -27,138 +25,108 @@ def handle(self, **options):
Workflows.
"""
sys.stdout.write("Generating ToolDefinitions\n")
workflow_engines = WorkflowEngine.objects.all()
sys.stdout.write("{} workflow engines found.\n".format(
workflow_engines.count())
)

for engine in workflow_engines:
sys.stdout.write(
"Generating ToolDefinitions from workflow engine {}\n"
.format(engine.name)
)
workflow_list = get_workflow_list()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_workflow_list() can raise RuntimeError exceptions that should be handled


# Validate workflow annotation data, and try to create a
# ToolDefinition if validation passes.

galaxy_connection = engine.instance.galaxy_connection()
for workflow in workflow_list:
workflow["tool_type"] = ToolDefinition.WORKFLOW
try:
workflow_list = galaxy_connection.workflows.get_workflows()
except ConnectionError as e:
workflow["annotation"] = json.loads(
workflow["annotation"]
)
except ValueError as e:
raise CommandError(
"Unable to retrieve workflows from '{}'. "
"Skipping ToolDefinition generation: {}".format(
engine.instance.base_url, e)
"Workflow: {}'s annotation is not "
"valid JSON: {}".format(workflow["name"], e)
)

# Validate workflow annotation data, and try to create a
# ToolDefinition if validation passes.
# Include `parameters` and `output_files` as keys in our
# workflow annotation
workflow["annotation"]["parameters"] = []
workflow["annotation"]["output_files"] = []

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make more sense to get the list of all the workflows from all the engines first to avoid an extra indentation level. It might also be helpful to factor out this functionality into a separate re-useable utility function.

for workflow in workflow_list:
workflow_data = galaxy_connection.workflows.show_workflow(
workflow["id"]
)
workflow_data["tool_type"] = ToolDefinition.WORKFLOW
try:
workflow_data["annotation"] = json.loads(
workflow_data["annotation"]
)
except ValueError as e:
raise CommandError(
"Workflow: {}'s annotation is not "
"valid JSON: {}".format(workflow_data["name"], e)
)

# Include `parameters` and `output_files` as keys in our
# workflow annotation
workflow_data["annotation"]["parameters"] = []
workflow_data["annotation"]["output_files"] = []
# Iterate through the workflow's step's annotations and
# append to the `parameters` and `output_files` lists from
# above so they are included in the validation of this
# workflow's annotation data
for step_index in workflow["steps"]:
step = workflow["steps"][step_index]

# Iterate through the workflow's step's annotations and
# append to the `parameters` and `output_files` lists from
# above so they are included in the validation of this
# workflow's annotation data
for step_index in workflow_data["steps"]:
step = workflow_data["steps"][step_index]
# Check if any annotation provided, and try to convert
# to python dict if so
if step["annotation"]:
try:
step_annotation = json.loads(step["annotation"])
except ValueError as e:
raise CommandError(
"Workflow: {}'s Step: {}'s annotation data"
" is not valid JSON: {}".format(
workflow_data["name"], step_index, e
)
if step["annotation"]:
try:
step_annotation = json.loads(step["annotation"])
except ValueError as e:
raise CommandError(
"Workflow: {}'s Step: {}'s annotation data"
" is not valid JSON: {}".format(
workflow["name"],
step_index,
e
)
try:
validate_workflow_step_annotation(
step_annotation
)
try:
validate_workflow_step_annotation(
step_annotation
)
except RuntimeError as e:
raise CommandError(
"{} {}".format(ANNOTATION_ERROR_MESSAGE, e)
)
except RuntimeError as e:
try:
parameters = step_annotation["parameters"]
except KeyError:
# `parameters` aren't required for each workflow step
pass

for parameter in parameters:
# Check User-defined parameters in
# annotation data against the available
# parameters of the Workflow step's
# `tool_inputs`
if parameter["name"] not in step["tool_inputs"]:
raise CommandError(
"{} {}".format(ANNOTATION_ERROR_MESSAGE, e)
"{} is not a valid parameter for {}".
format(
parameter["name"],
step["tool_id"]
)
try:
parameters = step_annotation["parameters"]
except KeyError:
# Since we've already validated the Workflow
# step's annotation, and a Step Annotation
# doesn't necessarily need to have
# `parameters` we can pass here without
# raising an exception
pass
else:
for parameter in parameters:
# Check User-defined parameters in
# annotation data against the available
# parameters of the Workflow step's
# `tool_inputs`
if (not parameter["name"] in
step["tool_inputs"]):
raise RuntimeError(
"{} is not a valid parameter for {}".
format(
parameter["name"],
step["tool_id"]
)
)
else:
parameter["galaxy_workflow_step"] = int(
step_index
)
workflow_data["annotation"]["parameters"]\
.append(parameter)
try:
output_files = step_annotation["output_files"]
except KeyError:
# Since we've already validated the Workflow
# step's annotation, and a Step Annotation
# doesn't necessarily need to have
# `output_files` we can pass here without
# raising an exception
pass
)
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed. Removing will help reduce indentation levels.

for output_file in output_files:
workflow_data["annotation"]["output_files"]\
.append(output_file)
try:
validate_tool_annotation(workflow_data)
except RuntimeError as e:
raise CommandError(e)
except Exception as e:
raise CommandError(
"Something unexpected happened: {}".format(e)
)
try:
create_tool_definition(workflow_data)
except Exception as e:
raise CommandError(
"Creation of ToolDefinition failed. Database "
"rolled back to its state before this "
"ToolDefinition's attempted creation: {}".format(e)
)
else:
sys.stdout.write(
"\nGenerated ToolDefinition for: {}\n".format(
workflow_data["name"]
parameter["galaxy_workflow_step"] = int(
step_index
)
workflow["annotation"]["parameters"]\
.append(parameter)
try:
output_files = step_annotation["output_files"]
except KeyError:
# `ouput_files` aren't required for each workflow step
pass

for output_file in output_files:
workflow["annotation"]["output_files"].append(
output_file
)
)
try:
validate_tool_annotation(workflow)
except RuntimeError as e:
raise CommandError(e)
except Exception as e:
raise CommandError(
"Something unexpected happened: {}".format(e)
)
try:
create_tool_definition(workflow)
except Exception as e:
raise CommandError(
"Creation of ToolDefinition failed. Database "
"rolled back to its state before this "
"ToolDefinition's attempted creation: {}".format(e)
)

sys.stdout.write("\nGenerated ToolDefinition for: {}\n".format(
workflow["name"]
))
7 changes: 4 additions & 3 deletions refinery/tool_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def __str__(self):


@receiver(pre_delete, sender=ToolDefinition)
def _tooldefinition_pre_delete(sender, instance, *args, **kwargs):
def delete_parameters_and_output_files(sender, instance, *args, **kwargs):
"""
Delete related parameter and output_file objects upon ToolDefinition
deletion
Expand All @@ -161,7 +161,7 @@ def _tooldefinition_pre_delete(sender, instance, *args, **kwargs):


@receiver(post_delete, sender=ToolDefinition)
def _tooldefinition_post_delete(sender, instance, *args, **kwargs):
def delete_file_relationship(sender, instance, *args, **kwargs):
"""
Delete related (topmost) FileRelationship object after ToolDefinition
deletion.
Expand All @@ -170,7 +170,8 @@ def _tooldefinition_post_delete(sender, instance, *args, **kwargs):


@receiver(pre_delete, sender=FileRelationship)
def _filerelationship_pre_delete(sender, instance, *args, **kwargs):
def delete_input_files_and_file_relationships(sender, instance, *args,
**kwargs):
"""
Delete all related nested file_relationships in a recursive manner.

Expand Down
2 changes: 1 addition & 1 deletion refinery/tool_manager/schemas/FileRelationship.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"file_relationship": {
"oneOf": [
{"$ref": "FileRelationship.json#"},
{"type": "object", "$ref": "FileRelationship.json#"},
{"type": "object", "additionalProperties": false, "properties": {}}
]
}
Expand Down
2 changes: 1 addition & 1 deletion refinery/tool_manager/schemas/OutputFile.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"description": {
"type": "string"
},
"file_type": {
"filetype": {
"type": "object",
"$ref": "FileType.json#"
}
Expand Down
10 changes: 7 additions & 3 deletions refinery/tool_manager/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class Meta:

class ParameterSerializer(serializers.ModelSerializer):
galaxy_workflow_step = serializers.SerializerMethodField(
method_name="_get_galaxy_workflow_step", required=False,
method_name="_get_galaxy_workflow_step",
required=False,
allow_null=False
)

Expand Down Expand Up @@ -49,8 +50,11 @@ class Meta:
class FileRelationshipSerializer(serializers.ModelSerializer):
# RecursiveField allows for the exposure of all self-referential nested
# ManyToMany relations in the serialized response data
file_relationship = RecursiveField(required=False, allow_null=True,
many=True)
file_relationship = RecursiveField(
required=False,
allow_null=True,
many=True
)
input_files = InputFileSerializer(many=True)

class Meta:
Expand Down