merge_machine/api.py
def upload(proj):
    '''
    Uploads files to a normalization project. (NB: cannot upload directly to 
    a link type project). 
                                               
    Also creates the mini version of the project
    
    GET:
        - project_type: must be "normalize"
        - project_id: ID of the normalization project
        
    POST:
        
      file: (csv file) A csv to upload to the chosen normalization project
                  NB: the "filename" property will be used to name the file
      json:
        - module_params:
            - make_mini: (default True) Set to False to NOT create a mini version of the file
            - sample_size
            - randomize
    '''
    assert proj.metadata['project_type'] == 'normalize'
    _, module_params = _parse_request()   
    if module_params is None:
        module_params = {}
    make_mini = module_params.get('make_mini', True) # TODO: can remove ?
    
    # Upload data        
    def custom_stream_factory(total_content_length, filename, content_type, content_length=None):
        tmpfile = tempfile.NamedTemporaryFile('wb+', prefix='flaskapp')
        app.logger.info("start receiving file ... filename => " + str(tmpfile.name))
        return tmpfile
    
    _, _, files = werkzeug.formparser.parse_form_data(flask.request.environ, stream_factory=custom_stream_factory)
    
    
    # Upload data
    file_name = files['file'].filename
    stream = files['file'].stream
    
    _, run_info = proj.upload_init_data(stream, file_name)
    
    # Make mini
    if make_mini:
        proj.load_data('INIT', run_info['file_name'])
        proj.make_mini(module_params)
        
        # Write transformations and log # TODO: not clean
        if proj.metadata['has_mini']:
            proj.write_data()
        else:
            proj._write_metadata()
    
    return jsonify(run_info=run_info, project_id=proj.project_id)

    Uploads files to a normalization project. (NB: cannot upload directly to 
    a link type project). 
                                               
    Also creates the mini version of the project
    
    GET:
        - project_type: must be "normalize"
        - project_id: ID of the normalization project
        
    POST:
        
      file: (csv file) A csv to upload to the chosen normalization project
                  NB: the "filename" property will be used to name the file
      json:
        - module_params:
            - make_mini: (default True) Set to False to NOT create a mini version of the file
            - sample_size
            - randomize
    
Uploads files to a normalization project. (NB: cannot upload directly to
a link type project).

Also creates the mini version of the project

must be "normalize"
project_id: ID of the normalization project



(csv file) A csv to upload to the chosen normalization project
NB: the "filename" property will be used to name the file
json:
module_params:
make_mini: (default True) Set to False to NOT create a mini version of the file
sample_size
randomize
Uploads files to a normalization project . ( NB : cannot upload directly to a link type project ) . Also creates the mini version of the project must be " normalize " project_id : ID of the normalization project ( csv file ) A csv to upload to the chosen normalization project NB : the " filename " property will be used to name the file json : module_params : make_mini : ( default True ) Set to False to NOT create a mini version of the file sample_size randomize
def upload(proj):
    assert proj.metadata['project_type'] == 'normalize'
    _, module_params = _parse_request()   
    if module_params is None:
        module_params = {}
    make_mini = module_params.get('make_mini', True) 
    def custom_stream_factory(total_content_length, filename, content_type, content_length=None):
        tmpfile = tempfile.NamedTemporaryFile('wb+', prefix='flaskapp')
        app.logger.info("start receiving file ... filename => " + str(tmpfile.name))
        return tmpfile
    _, _, files = werkzeug.formparser.parse_form_data(flask.request.environ, stream_factory=custom_stream_factory)
    file_name = files['file'].filename
    stream = files['file'].stream
    _, run_info = proj.upload_init_data(stream, file_name)
    if make_mini:
        proj.load_data('INIT', run_info['file_name'])
        proj.make_mini(module_params)
        if proj.metadata['has_mini']:
            proj.write_data()
        else:
            proj._write_metadata()
    return jsonify(run_info=run_info, project_id=proj.project_id)
def upload ( proj ) : assert proj . metadata [ 'project_type' ] == 'normalize' _ , module_params = _parse_request ( ) if module_params is None : module_params = { } make_mini = module_params . get ( 'make_mini' , True ) def custom_stream_factory ( total_content_length , filename , content_type , content_length = None ) : tmpfile = tempfile . NamedTemporaryFile ( 'wb+' , prefix = 'flaskapp' ) app . logger . info ( "start receiving file ... filename => " + str ( tmpfile . name ) ) return tmpfile _ , _ , files = werkzeug . formparser . parse_form_data ( flask . request . environ , stream_factory = custom_stream_factory ) file_name = files [ 'file' ] . filename stream = files [ 'file' ] . stream _ , run_info = proj . upload_init_data ( stream , file_name ) if make_mini : proj . load_data ( 'INIT' , run_info [ 'file_name' ] ) proj . make_mini ( module_params ) if proj . metadata [ 'has_mini' ] : proj . write_data ( ) else : proj . _write_metadata ( ) return jsonify ( run_info = run_info , project_id = proj . project_id )
Uploads files to a normalization project.
Uploads files to a normalization project .
'''
    Uploads files to a normalization project. (NB: cannot upload directly to 
    a link type project). 
                                               
    Also creates the mini version of the project
    
    GET:
        - project_type: must be "normalize"
        - project_id: ID of the normalization project
        
    POST:
        
      file: (csv file) A csv to upload to the chosen normalization project
                  NB: the "filename" property will be used to name the file
      json:
        - module_params:
            - make_mini: (default True) Set to False to NOT create a mini version of the file
            - sample_size
            - randomize
    ''' # TODO: can remove ? # Upload data         # Upload data # Make mini # Write transformations and log # TODO: not clean
proj