Skip to content

Commit

Permalink
Merge pull request #94 from jhuapl-boss/cvdb-downsample-fix
Browse files Browse the repository at this point in the history
CVDB Downsample Fix
  • Loading branch information
sandyhider authored Sep 21, 2021
2 parents 4eab3f5 + a005d28 commit c2e26d2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
18 changes: 12 additions & 6 deletions django/bosscore/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,18 @@ def validate(self, data):
errors['default_time_sample'] = 'Ensure this value is less that the experiments num_time_samples {}.'\
.format(num_time_samples)

# Ensure storage_type is CloudVolume if cv_path is set.
if 'cv_path' in data and data['cv_path'] is not None and data['cv_path'] != '':
storage_type = data.get('storage_type', None)
if storage_type != Channel.StorageType.CLOUD_VOLUME:
errors['storage_type'] = f'Must be set to {Channel.StorageType.CLOUD_VOLUME}, if setting cv_path'

# Validate cloudvolume specific properties
is_cloudvol = data.get('storage_type') == Channel.StorageType.CLOUD_VOLUME

# Ensure storage_type is CloudVolume if cv_path is set
if (not is_cloudvol and data.get('cv_path') not in (None, '')):
errors['storage_type'] = f'Must be set to {Channel.StorageType.CLOUD_VOLUME}, if setting cv_path'

# Ensure channel is downsampled
if is_cloudvol and data.get('downsample_status') != 'DOWNSAMPLED':
errors['downsample_status'] = f'{Channel.StorageType.CLOUD_VOLUME} channels must be already downsampled.'


# Validate that base_resolution is less than the num_hierarchy_levels
# We no longer check this because we may delete some resolutions to
# reduce storage costs. When we do this, we change num_hierarchy_levels
Expand Down
6 changes: 6 additions & 0 deletions django/bosscore/views/views_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,12 @@ def post(self, request, collection, experiment, channel):
if use_cloudvol and (cv_path is None or cv_path == ''):
channel_data['cv_path'] = f'/{collection}/{experiment}/{channel}'

if use_cloudvol:
# DX NOTE: For now we assume that cloudvolume channels are downsampled. This means
# that the num_hierarchy_levels in the experiment should be limited to the available
# mip levels in the cloudvolume layer.
channel_data['downsample_status'] = 'DOWNSAMPLED'

# The source and related channels are names and need to be removed from the dict before serialization
source_channels = channel_data.pop('sources', [])
related_channels = channel_data.pop('related', [])
Expand Down
8 changes: 5 additions & 3 deletions django/mgmt/templates/channel.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ <h3 class="panel-title">Channel Properties</h3>
</div>
<div class="col-xs-7">
<div class="panel-body">
<a id="downsample-btn" type='button' class='btn btn-primary btn-sm action-button disabled' href='javascript:void(0);' onclick='start_downsample("{{ collection_name }}", "{{ experiment_name }}", "{{ channel_name }}")'><span class='glyphicon glyphicon-sort-by-attributes-alt' aria-hidden='true'></span> Start Downsample</a>
<a id="cancel-btn" type='button' class='btn btn-danger btn-sm action-button disabled' href='javascript:void(0);' onclick='cancel_downsample("{{collection_name }}", "{{ experiment_name }}", "{{ channel_name }}")'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span> Cancel Downsample</a>
{% if user.is_staff %}
{% if channel.storage_type == "spdb" %}
<a id="downsample-btn" type='button' class='btn btn-primary btn-sm action-button disabled' href='javascript:void(0);' onclick='start_downsample("{{ collection_name }}", "{{ experiment_name }}", "{{ channel_name }}")'><span class='glyphicon glyphicon-sort-by-attributes-alt' aria-hidden='true'></span> Start Downsample</a>
<a id="cancel-btn" type='button' class='btn btn-danger btn-sm action-button disabled' href='javascript:void(0);' onclick='cancel_downsample("{{collection_name }}", "{{ experiment_name }}", "{{ channel_name }}")'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span> Cancel Downsample</a>
{% if user.is_staff %}
<br/><br />
<a id="redownsample-btn" type='button' class='btn btn-primary btn-sm action-button' href='javascript:void(0);' onclick='start_redownsample("{{ collection_name }}", "{{ experiment_name }}", "{{ channel_name }}")'><span class='glyphicon glyphicon-sort-by-attributes-alt' aria-hidden='true'></span> Start Re-downsample</a>
{% endif %}
{% endif %}
</div>
</div>
Expand Down

0 comments on commit c2e26d2

Please sign in to comment.