def validate_input_files(self, files): """Validates the given file parameters to make sure they are valid with respect to the job interface. :param files: List of file inputs :type files: [:class:`job.seed.types.SeedInputFiles`] :returns: A list of warnings discovered during validation. :rtype: list[:class:`job.configuration.data.job_data.ValidationWarning`] :raises :class:`job.configuration.data.exceptions.InvalidConnection`: If there is a configuration problem. """ warnings = [] for file in files: if file.name not in self.files: if file.required: raise InvalidConnection('Data input %s is required and was not provided' % file.name) continue conn_file = self.files[file.name] conn_multiple = conn_file[0] conn_media_types = conn_file[1] conn_optional = conn_file[2] if conn_optional: if file.required: raise InvalidConnection('Data input %s is required and data from connection is optional' % file.name) if not file.multiple and conn_multiple: raise InvalidConnection('Data input %s only accepts a single file' % file.name) for conn_media_type in conn_media_types: if not file.is_media_type_allowed(conn_media_type): warn = ValidationWarning('media_type', 'Invalid media type for data input: %s -> %s' % (file.name, conn_media_type)) warnings.append(warn) return warnings
def validate_input_files(self, files): '''Validates the given file parameters to make sure they are valid with respect to the job interface. :param files: Dict of file parameter names mapped to a tuple with three items: whether the parameter is required (True), if the parameter is for multiple files (True), and the description of the expected file meta-data :type files: dict of str -> tuple(bool, bool, :class:`job.configuration.interface.scale_file.ScaleFileDescription`) :returns: A list of warnings discovered during validation. :rtype: list[:class:`job.configuration.data.job_data.ValidationWarning`] :raises :class:`job.configuration.data.exceptions.InvalidConnection`: If there is a configuration problem. ''' warnings = [] for name in files: required = files[name][0] multiple = files[name][1] file_desc = files[name][2] if name not in self.files: if required: raise InvalidConnection( u'Data input %s is required and was not provided' % name) continue conn_file = self.files[name] conn_multiple = conn_file[0] conn_media_types = conn_file[1] conn_optional = conn_file[2] if conn_optional: if required: raise InvalidConnection( u'Data input %s is required and data from connection is optional' % name) if not multiple and conn_multiple: raise InvalidConnection( u'Data input %s only accepts a single file' % name) for conn_media_type in conn_media_types: if not file_desc.is_media_type_allowed(conn_media_type): warn = ValidationWarning( 'media_type', 'Invalid media type for data input: %s -> %s' % (name, conn_media_type)) warnings.append(warn) return warnings
def validate_properties(self, property_names): """Validates the given property names to make sure all properties exist if they are required. :param files: List of file inputs :type files: [:class:`job.seed.types.SeedInputFiles`] :returns: A list of warnings discovered during validation. :rtype: list[:class:`job.configuration.data.job_data.ValidationWarning`] :raises :class:`job.configuration.data.exceptions.InvalidConnection`: If there is a configuration problem. """ warnings = [] for prop in property_names: if prop.name not in self.properties and prop.required: raise InvalidConnection( 'Property %s is required and was not provided' % prop.name) return warnings
def validate_properties(self, property_names): """Validates the given property names to make sure all properties exist if they are required. :param property_names: Dict of property names mapped to a bool indicating if they are required :type property_names: dict of str -> bool :returns: A list of warnings discovered during validation. :rtype: list[:class:`job.configuration.data.job_data.ValidationWarning`] :raises :class:`job.configuration.data.exceptions.InvalidConnection`: If there is a configuration problem. """ warnings = [] for name in property_names: if name not in self.properties and property_names[name]: raise InvalidConnection('Property %s is required and was not provided' % name) return warnings
def validate_connection(self, job_conn): """Validates the given job connection to ensure that the connection will provide sufficient data to run a job with this interface :param job_conn: The job data :type job_conn: :class:`job.configuration.data.job_connection.JobConnection` :returns: A list of warnings discovered during validation. :rtype: list[:class:`job.configuration.data.job_data.ValidationWarning`] :raises :class:`job.configuration.data.exceptions.InvalidConnection`: If there is a configuration problem. """ warnings = [] warnings.extend(job_conn.validate_input_files(self._input_file_validation_dict)) warnings.extend(job_conn.validate_properties(self._property_validation_dict)) # Make sure connection has a workspace if the interface has any output files if self._output_file_validation_list and not job_conn.has_workspace(): raise InvalidConnection('No workspace provided for output files') return warnings
def validate_trigger_for_job(self, job_interface): raise InvalidConnection('Error!')