diff --git a/django/bosscore/serializers.py b/django/bosscore/serializers.py index c89b7c9d..6be5b933 100644 --- a/django/bosscore/serializers.py +++ b/django/bosscore/serializers.py @@ -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 diff --git a/django/bosscore/views/views_resource.py b/django/bosscore/views/views_resource.py index 1cfe44c8..bb277ecd 100644 --- a/django/bosscore/views/views_resource.py +++ b/django/bosscore/views/views_resource.py @@ -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', []) diff --git a/django/mgmt/templates/channel.html b/django/mgmt/templates/channel.html index f969afb7..948e7748 100644 --- a/django/mgmt/templates/channel.html +++ b/django/mgmt/templates/channel.html @@ -36,11 +36,13 @@

Channel Properties

- Start Downsample - Cancel Downsample - {% if user.is_staff %} + {% if channel.storage_type == "spdb" %} + Start Downsample + Cancel Downsample + {% if user.is_staff %}

Start Re-downsample + {% endif %} {% endif %}