Skip to content

Commit

Permalink
add zone assay shortcut collection creation (#1869)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Jan 29, 2024
1 parent 5483cd4 commit 3a812fd
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Changelog for the SODAR project. Loosely follows the
Unreleased
==========

Added
-----

- **Landingzones**
- Create assay plugin shortcut collections for zones (#1869)

Changed
-------

Expand Down
1 change: 1 addition & 0 deletions docs_manual/source/sodar_release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ v0.14.2 (WIP)

Release for minor updates, maintenance and bug fixes.

- Add assay plugin shortcut collection creation in landing zones
- Fix iRODS data request issues
- Fix LDAP TLS settings
- Minor updates and bug fixes
Expand Down
43 changes: 37 additions & 6 deletions landingzones/tests/test_views_taskflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
ZONE_BASE_COLLS = [MISC_FILES_COLL, RESULTS_COLL, TRACK_HUBS_COLL]
ZONE_PLUGIN_COLLS = ['0815-N1-DNA1', '0815-T1-DNA1']
ZONE_ALL_COLLS = ZONE_BASE_COLLS + ZONE_PLUGIN_COLLS
RAW_DATA_COLL = 'RawData'
MAX_QUANT_COLL = 'MaxQuantResults'


class LandingZoneTaskflowMixin:
Expand Down Expand Up @@ -239,8 +241,7 @@ def test_create_zone_colls(self):
'configuration': '',
}
with self.login(self.user):
response = self.client.post(self.url, values)
self.assertRedirects(response, self.redirect_url)
self.client.post(self.url, values)

self.assert_zone_count(1)
zone = LandingZone.objects.first()
Expand Down Expand Up @@ -287,8 +288,7 @@ def test_create_zone_colls_plugin(self):
'configuration': '',
}
with self.login(self.user):
response = self.client.post(self.url, values)
self.assertRedirects(response, self.redirect_url)
self.client.post(self.url, values)

self.assert_zone_count(1)
zone = LandingZone.objects.first()
Expand All @@ -304,6 +304,38 @@ def test_create_zone_colls_plugin(self):
self.assert_irods_access(
self.user.username, os.path.join(zone_path, c), IRODS_ACCESS_OWN
)
# These should not be created for this plugin
for c in [MAX_QUANT_COLL, RAW_DATA_COLL]:
self.assert_irods_coll(zone, c, False)

def test_create_zone_colls_plugin_shortcuts(self):
"""Test landingzones creation with shortcut collections in plugin"""
self.assertEqual(LandingZone.objects.count(), 0)
# Set pep_ms plugin
self.assay.measurement_type = {'name': 'protein expression profiling'}
self.assay.technology_type = {'name': 'mass spectrometry'}
self.assay.save()
# NOTE: update_cache() not implemented in this plugin

values = {
'assay': str(self.assay.sodar_uuid),
'title_suffix': ZONE_SUFFIX,
'description': ZONE_DESC,
'create_colls': True,
'restrict_colls': False,
'configuration': '',
}
with self.login(self.user):
self.client.post(self.url, values)

self.assert_zone_count(1)
zone = LandingZone.objects.first()
self.assert_zone_status(zone, ZONE_STATUS_ACTIVE)
zone_colls = ZONE_BASE_COLLS + [RAW_DATA_COLL, MAX_QUANT_COLL]
for c in zone_colls:
self.assert_irods_coll(zone, c, True)
for c in ZONE_PLUGIN_COLLS:
self.assert_irods_coll(zone, c, False)

# TODO: Test without sodarcache (see issue #1157)

Expand Down Expand Up @@ -332,8 +364,7 @@ def test_create_zone_colls_plugin_restrict(self):
'configuration': '',
}
with self.login(self.user):
response = self.client.post(self.url, values)
self.assertRedirects(response, self.redirect_url)
self.client.post(self.url, values)

self.assert_zone_count(1)
zone = LandingZone.objects.first()
Expand Down
17 changes: 14 additions & 3 deletions landingzones/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def submit_create(
colls = []
if create_colls:
logger.debug('Creating default landing zone collections..')
assay_path = irods_backend.get_path(zone.assay)
colls = [RESULTS_COLL, MISC_FILES_COLL, TRACK_HUBS_COLL]
plugin = zone.assay.get_plugin()
# First try the cache
Expand All @@ -199,14 +200,24 @@ def submit_create(
project=zone.project,
)
if cache_obj and cache_obj.data:
assay_path = irods_backend.get_path(zone.assay)
colls += [
p.replace(assay_path + '/', '')
for p in cache_obj.data['paths'].keys()
]
logger.debug('Retrieved collections from cache')
elif plugin:
pass # TODO: Build tables, get rows directly from plugin?
# TODO: If no cache, build tables and get rows directly from plugin?
# Add shortcut paths
if plugin:
shortcuts = plugin.get_shortcuts(zone.assay) or []
for s in shortcuts:
path = s.get('path')
if path:
path = path.replace(assay_path + '/', '')
if path and path not in colls:
colls.append(path)
logger.debug(
'Added shorctut collection "{}"'.format(s.get('id'))
)

logger.debug('Collections to be created: {}'.format(', '.join(colls)))
flow_name = 'landing_zone_create'
Expand Down

0 comments on commit 3a812fd

Please sign in to comment.