def test_successful(self): """Tests calling JobInterface.validate_connection() successfully.""" job_interface_dict = { 'command': 'simple-command', 'command_arguments': '', 'version': '1.0', 'input_data': [{ 'name': 'Input 1', 'type': 'property', }, { 'name': 'Input 2', 'type': 'file', 'media_types': ['text/plain'] }], 'output_data': [{ 'name': 'Output 1', 'type': 'file', }] } job_interface = JobInterface(job_interface_dict) job_conn = JobConnection() job_conn.add_property('Input 1') job_conn.add_input_file('Input 2', False, ['text/plain'], False, False) job_conn.add_workspace() # No exception is success job_interface.validate_connection(job_conn)
def test_successful(self): '''Tests calling JobInterface.validate_connection() successfully.''' job_interface_dict = { 'command': 'simple-command', 'command_arguments': '', 'version': '1.0', 'input_data': [{ 'name': 'Input 1', 'type': 'property', }, { 'name': 'Input 2', 'type': 'file', 'media_types': ['text/plain'], }], 'output_data': [{ 'name': 'Output 1', 'type': 'file', }] } job_interface = JobInterface(job_interface_dict) job_conn = JobConnection() job_conn.add_property('Input 1') job_conn.add_input_file('Input 2', False, ['text/plain'], False) job_conn.add_workspace() # No exception is success job_interface.validate_connection(job_conn)
def validate_trigger_for_job(self, job_interface): """See :meth:`job.triggers.configuration.trigger_rule.JobTriggerRuleConfiguration.validate_trigger_for_job` """ input_file_name = self.get_input_data_name() media_type = self.get_condition().get_media_type() media_types = [media_type] if media_type else None connection = JobConnection() connection.add_input_file(input_file_name, False, media_types, False, False) connection.add_workspace() return job_interface.validate_connection(connection)
def validate_trigger_for_job(self, job_interface): '''See :meth:`job.triggers.configuration.trigger_rule.JobTriggerRuleConfiguration.validate_trigger_for_job` ''' input_file_name = self.get_input_data_name() media_type = self.get_condition().get_media_type() media_types = [media_type] if media_type else None connection = JobConnection() connection.add_input_file(input_file_name, False, media_types, False, False) connection.add_workspace() return job_interface.validate_connection(connection)
def _validate_job_interface(self, job_dict, job_types_by_name): """Validates the input connections for the given job in the recipe definition :param job_dict: The job dictionary :type job_dict: dict :param job_types_by_name: Dict mapping all job names in the recipe to their job type models :type job_types_by_name: dict :returns: A list of warnings discovered during validation. :rtype: list[:class:`job.configuration.data.job_data.ValidationWarning`] :raises :class:`recipe.configuration.definition.exceptions.InvalidDefinition`: If there are any invalid job connections in the definition """ # Job connection will represent data to be passed to the job to validate job_conn = JobConnection() # Assume a workspace is provided, this will be verified when validating the recipe data job_conn.add_workspace() # Populate connection with data that will come from recipe inputs self._add_recipe_inputs_to_conn(job_conn, job_dict['recipe_inputs']) # Populate connection with data that will come from job dependencies warnings = [] for dependency_dict in job_dict['dependencies']: dependency_name = dependency_dict['name'] job_type = job_types_by_name[dependency_name] for conn_dict in dependency_dict['connections']: conn_input = conn_dict['input'] job_output = conn_dict['output'] job_type.get_job_interface().add_output_to_connection( job_output, job_conn, conn_input) job_type = job_types_by_name[job_dict['name']] try: warnings.extend( job_type.get_job_interface().validate_connection(job_conn)) except InvalidConnection as ex: raise InvalidDefinition(unicode(ex)) return warnings
def _validate_job_interface(self, job_dict, job_types_by_name): """Validates the input connections for the given job in the recipe definition :param job_dict: The job dictionary :type job_dict: dict :param job_types_by_name: Dict mapping all job names in the recipe to their job type models :type job_types_by_name: dict :returns: A list of warnings discovered during validation. :rtype: list[:class:`job.configuration.data.job_data.ValidationWarning`] :raises :class:`recipe.configuration.definition.exceptions.InvalidDefinition`: If there are any invalid job connections in the definition """ # Job connection will represent data to be passed to the job to validate job_conn = JobConnection() # Assume a workspace is provided, this will be verified when validating the recipe data job_conn.add_workspace() # Populate connection with data that will come from recipe inputs self._add_recipe_inputs_to_conn(job_conn, job_dict['recipe_inputs']) # Populate connection with data that will come from job dependencies warnings = [] for dependency_dict in job_dict['dependencies']: dependency_name = dependency_dict['name'] job_type = job_types_by_name[dependency_name] for conn_dict in dependency_dict['connections']: conn_input = conn_dict['input'] job_output = conn_dict['output'] job_type.get_job_interface().add_output_to_connection(job_output, job_conn, conn_input) job_type = job_types_by_name[job_dict['name']] try: warnings.extend(job_type.get_job_interface().validate_connection(job_conn)) except InvalidConnection as ex: raise InvalidDefinition(unicode(ex)) return warnings