genesis/genesis.py
def upload(self, project_id, processor_name, **fields):
        """Upload files and data objects.

        :param project_id: ObjectId of Genesis project
        :type project_id: string
        :param processor_name: Processor object name
        :type processor_name: string
        :param fields: Processor field-value pairs
        :type fields: args
        :rtype: HTTP Response object

        """
        p = self.processors(processor_name=processor_name)

        if len(p) == 1:
            p = p[0]
        else:
            Exception('Invalid processor name {}'.format(processor_name))

        for field_name, field_val in fields.items():
            if field_name not in p['input_schema']:
                Exception("Field {} not in processor {} inputs".format(field_name, p['name']))

            if find_field(p['input_schema'], field_name)['type'].startswith('basic:file:'):
                if not os.path.isfile(field_val):
                    Exception("File {} not found".format(field_val))

        inputs = {}

        for field_name, field_val in fields.items():
            if find_field(p['input_schema'], field_name)['type'].startswith('basic:file:'):

                file_temp = self._upload_file(field_val)

                if not file_temp:
                    Exception("Upload failed for {}".format(field_val))

                inputs[field_name] = {
                    'file': field_val,
                    'file_temp': file_temp
                }
            else:
                inputs[field_name] = field_val

        d = {
            'status': 'uploading',
            'case_ids': [project_id],
            'processor_name': processor_name,
            'input': inputs,
        }

        return self.create(d)
def upload(self, project_id, processor_name, **fields):
        """Upload files and data objects.

        :param project_id: ObjectId of Genesis project
        :type project_id: string
        :param processor_name: Processor object name
        :type processor_name: string
        :param fields: Processor field-value pairs
        :type fields: args
        :rtype: HTTP Response object

        """
        p = self.processors(processor_name=processor_name)

        if len(p) == 1:
            p = p[0]
        else:
            Exception('Invalid processor name {}'.format(processor_name))

        for field_name, field_val in fields.items():
            if field_name not in p['input_schema']:
                Exception("Field {} not in processor {} inputs".format(field_name, p['name']))

            if find_field(p['input_schema'], field_name)['type'].startswith('basic:file:'):
                if not os.path.isfile(field_val):
                    Exception("File {} not found".format(field_val))

        inputs = {}

        for field_name, field_val in fields.items():
            if find_field(p['input_schema'], field_name)['type'].startswith('basic:file:'):

                file_temp = self._upload_file(field_val)

                if not file_temp:
                    Exception("Upload failed for {}".format(field_val))

                inputs[field_name] = {
                    'file': field_val,
                    'file_temp': file_temp
                }
            else:
                inputs[field_name] = field_val

        d = {
            'status': 'uploading',
            'case_ids': [project_id],
            'processor_name': processor_name,
            'input': inputs,
        }

        return self.create(d)
def upload ( self , project_id , processor_name , * * fields ) : p = self . processors ( processor_name = processor_name ) if len ( p ) == 1 : p = p [ 0 ] else : Exception ( 'Invalid processor name {}' . format ( processor_name ) ) for field_name , field_val in fields . items ( ) : if field_name not in p [ 'input_schema' ] : Exception ( "Field {} not in processor {} inputs" . format ( field_name , p [ 'name' ] ) ) if find_field ( p [ 'input_schema' ] , field_name ) [ 'type' ] . startswith ( 'basic:file:' ) : if not os . path . isfile ( field_val ) : Exception ( "File {} not found" . format ( field_val ) ) inputs = { } for field_name , field_val in fields . items ( ) : if find_field ( p [ 'input_schema' ] , field_name ) [ 'type' ] . startswith ( 'basic:file:' ) : file_temp = self . _upload_file ( field_val ) if not file_temp : Exception ( "Upload failed for {}" . format ( field_val ) ) inputs [ field_name ] = { 'file' : field_val , 'file_temp' : file_temp } else : inputs [ field_name ] = field_val d = { 'status' : 'uploading' , 'case_ids' : [ project_id ] , 'processor_name' : processor_name , 'input' : inputs , } return self . create ( d )
Upload files and data objects.

        :param project_id: ObjectId of Genesis project
        :type project_id: string
        :param processor_name: Processor object name
        :type processor_name: string
        :param fields: Processor field-value pairs
        :type fields: args
        :rtype: HTTP Response object
Upload files and data objects .