def upload_file(): vm = vm_name(request) if not vm: return NOT_REGISTERED if not request.files or 'file' not in request.files: raise ValueError('There is no file submitted to the server.') if not request.form or 'dataset' not in request.form: raise ValueError('There is dataset submitted to the server.') if not request.form or 'run_name' not in request.form: raise ValueError('Run name not submitted.') if not request.form or 'run_description' not in request.form: raise ValueError('Run description not submitted.') data = request.files['file'].read() input_dataset = request.form['dataset'] run_name = request.form['run_name'] run_description = request.form['run_description'] if input_dataset not in ['scai-qrecc21-toy-dataset-2021-07-20', 'scai-qrecc21-toy-dataset-rewritten-2021-07-20', 'scai-qrecc21-toy-dataset-2021-05-15', 'scai-qrecc21-test-dataset-2021-05-15', 'scai-qrecc21-test-dataset-2021-07-20', 'scai-qrecc21-test-dataset-rewritten-2021-07-20']: raise ValueError('Unknown dataset: ' + str(input_dataset)) build_run(data, vm, datetime.datetime.now(), input_dataset, run_name, run_description) ret = redirect('/task/scai-qrecc/user/' + str(vm) + '/', code=303) ret.autocorrect_location_header = False return ret
def jade(files=None, obj=None, out=None, path=None, pretty=False, client=False, no_debug=False, watch=False): """ Compiles jade templates :param files: List of files or dict to pass to get_files for all files to run against :param obj: javascript options object :param out: output the compiled html to <dir> :param path: filename used to resolve includes :param pretty: compile pretty html output :param client: compile function for client-side runtime.js :param no_debug: compile without debugging (smaller functions) :param watch: watch files for changes and automatically re-render """ logger.debug("Running jade function. Files: " + str(files)) if files is None: raise Exception("Must run jade with files") if isinstance(files, dict): # Some sane defaults for jade if not specified files['only_files'] = True if 'recursive' not in files: files['recursive'] = True if 'match' not in files: files['match'] = ['*jade', ] files = get_files(files) compile_paths = ' '.join(['"{}"'.format(f) for f in files]) if not getattr(env, 'dry_run', False): opts = [] if obj: opts.append('-O "{}"'.format(obj)) if out: opts.append('-o "{}"'.format(out)) if path: opts.append('-p "{}"'.format(path)) if pretty: opts.append('-P') if client: opts.append('-c') if no_debug: opts.append('-D') if watch: opts.append('-w') build_run("jade {} {}".format(' '.join(opts), compile_paths), async=watch, keep_alive=1 if watch else 0) logger.info("Successfully compiled {} jade files".format(len(files))) logger.debug("Files compiled: \n" + "\n".join(files))
def coffee(files=None, bare=False, lint=False, map=False, join=None, output=None, watch=False): """ Compiles coffeescript files :param files: List of files or dict to pass to get_files for all files to run against :param bare: output bare coffeescript :param lint: run through jslint :param map: generate source maps :param join: join together files to this output location (string path) :param output: directory to output files :param watch: True to watch the output and recompile on changes """ logger.debug("Running coffee function. Files: " + str(files)) if files is None: raise Exception("Must run coffee with files") if isinstance(files, dict): # Some sane defaults for coffeescript if not specified files['only_files'] = True if 'recursive' not in files: files['recursive'] = True if 'match' not in files: files['match'] = ['*coffee', ] files = get_files(files) compile_paths = ' '.join(['"{}"'.format(f) for f in files]) if not getattr(env, 'dry_run', False): opts = [] if bare: opts.append('-b') if join: opts.append('-j "{}"'.format(join)) if lint: opts.append('-l') if map: opts.append('-m') if watch: opts.append('-w') if output: opts.append('-o "{}"'.format(output)) build_run("coffee {} -c {}".format(' '.join(opts), compile_paths), async=watch, keep_alive=1 if watch else 0) logger.info("Successfully compiled {} coffeescript files".format(len(files))) logger.debug("Files compiled: \n" + "\n".join(files))