How to use the girder.models.model_base.ValidationException function in girder

To help you get started, we’ve selected a few girder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github girder / covalic / covalic / models / phase.py View on Github external
def validate(self, doc):
        if not doc.get('name'):
            raise ValidationException('Phase name must not be empty.',
                                      field='name')

        if not isinstance(doc.get('challengeId'), ObjectId):
            raise ValidationException('Must have a challenge ID for the phase.',
                                      field='challengeId')

        if doc.get('startDate'):
            doc['startDate'] = validateDate(doc['startDate'], 'startDate')
        if doc.get('endDate'):
            doc['endDate'] = validateDate(doc['endDate'], 'endDate')

        # Check that dates are in a sensible order
        if doc.get('startDate') and doc.get('endDate'):
            if doc['startDate'] >= doc['endDate']:
                raise ValidationException('Invalid start and end dates.',
                                          field='startDate')

        # Ensure dockerArgs is a proper JSON list. If not, convert it to one.
        if doc.get('scoreTask', {}).get('dockerArgs'):
            args = doc['scoreTask']['dockerArgs']
github girder / girder / girder / utility / plugin_utilities.py View on Github external
def addDeps(plugin):
        if plugin not in allPlugins:
            message = 'Required plugin %s does not exist.' % plugin
            if ignoreMissing:
                logprint.error(message)
                return
            else:
                raise ValidationException(message)

        deps = set()
        for key in keys:
            deps |= allPlugins[plugin][key]
        dag[plugin] = deps

        for dep in deps:
            if dep in visited:
                return
            visited.add(dep)
            addDeps(dep)
github DigitalSlideArchive / digital_slide_archive / server / models / slide.py View on Github external
def validate(self, doc, **kwargs):
        if not doc.get('parentCollection') == 'folder':
            raise ValidationException(
                'A Slide model must be a child of a folder'
            )
        super(Slide, self).validate(doc, **kwargs)
        case = self.model('case', 'digital_slide_archive').load(
            doc['parentId'], force=True)
        if not case or self.getTCGAType(case) != 'case':
            raise ValidationException(
                'A Slide model must be a child of a case'
            )
        return doc
github Kitware / cumulus / girder / cumulus / cumulus_plugin / models / aws.py View on Github external
client = None
        # First validate the credentials
        try:
            client = get_ec2_client(doc)
            client.describe_account_attributes()
        except ClientError as ce:
            code = parse('Error.Code').find(ce.response)
            if code:
                code = code[0].value
            else:
                raise

            if code == ClientErrorCode.AuthFailure:
                raise ValidationException('Invalid AWS credentials')
        except EndpointConnectionError as ece:
            raise ValidationException(ece.message)

        # Now validate the region
        self._validate_region(client, doc)

        # Only do the rest of the validation if this is a new profile (not
        # a key update )
        if '_id' not in doc:
            # Now validate the zone
            self._validate_zone(client, doc)

        return doc
github girder / girder / plugins / jobs / server / models / job.py View on Github external
def _validateStatus(self, status):
        if not JobStatus.isValid(status):
            raise ValidationException(
                'Invalid job status %s.' % status, field='status')
github girder / covalic / covalic / models / challenge.py View on Github external
if '_id' in doc:
            q['_id'] = {'$ne': doc['_id']}
        duplicate = self.findOne(q, fields=['_id'])
        if duplicate is not None:
            raise ValidationException('A challenge with that name already '
                                      'exists.', 'name')

        if doc.get('startDate'):
            doc['startDate'] = validateDate(doc['startDate'], 'startDate')
        if doc.get('endDate'):
            doc['endDate'] = validateDate(doc['endDate'], 'endDate')

        # Check that dates are in a sensible order
        if doc.get('startDate') and doc.get('endDate'):
            if doc['startDate'] >= doc['endDate']:
                raise ValidationException('Invalid start and end dates.',
                                          field='startDate')

        return doc
github Kitware / cumulus / girder / cumulus / cumulus_plugin / models / cluster.py View on Github external
def validate(self, cluster):
        if not cluster['name']:
            raise ValidationException('Name must not be empty.', 'name')

        if not cluster['type']:
            raise ValidationException('Type must not be empty.', 'type')

        scheduler_type = parse('config.scheduler.type').find(cluster)
        if scheduler_type:
            scheduler_type = scheduler_type[0].value
        else:
            scheduler_type = QueueType.SGE
            config = cluster.setdefault('config', {})
            scheduler = config.setdefault('scheduler', {})
            scheduler['type'] = scheduler_type

        if not queue.is_valid_type(scheduler_type):
            raise ValidationException('Unsupported scheduler.', 'type')
github DigitalSlideArchive / digital_slide_archive / server / models / image.py View on Github external
raise ValidationException(
                'An image item must be a "large_image"'
            )
        slide = self.model('slide', 'digital_slide_archive').load(
            doc['folderId'], force=True)
        if not slide or self.getTCGAType(slide) != 'slide':
            raise ValidationException(
                'An image must be a child of a slide'
            )
        tcga = self.getTCGA(doc)
        if not self.case_re.match(tcga.get('case', '')):
            raise ValidationException(
                'Invalid case name in TCGA metadata'
            )
        if not self.barcode_re.match(tcga.get('barcode', '')):
            raise ValidationException(
                'Invalid barcode in TCGA metadata'
            )
        if not self.uuid_re.match(tcga.get('uuid', '')):
            raise ValidationException(
                'Invalid uuid in TCGA metadata'
            )

        return doc
github Kitware / flow / server / __init__.py View on Github external
if key == FlowPluginSettings.FULL_ACCESS_USERS:
        if not isinstance(val, (list, tuple)):
            raise ValidationException('Full access users must be a JSON list.')
        event.preventDefault()
    elif key == FlowPluginSettings.FULL_ACCESS_GROUPS:
        if not isinstance(val, (list, tuple)):
            raise ValidationException('Full access groups must be a JSON list.')
        event.preventDefault()
    elif key == FlowPluginSettings.REQUIRE_AUTH:
        if not isinstance(val, bool):
            raise ValidationException(
                'Require auth setting must be true or false.')
        event.preventDefault()
    elif key == FlowPluginSettings.SAFE_FOLDERS:
        if not isinstance(val, (list, tuple)):
            raise ValidationException('Safe folders must be a JSON list.')
        event.preventDefault()