예제 #1
0
def run(function_path, experiment_config_file, job_config_file, force):

    job_dir = os.path.dirname(job_config_file)
    experiment_config = load_json(os.path.join(experiment_config_file))
    state = load_json(job_config_file)

    with ChangeDir(job_dir):

        experiment = experiment_scheduler.save_experiment(
            name=experiment_config["experiment_name"],
            table_name=experiment_config["experiment_name"] + "_jobs",
            clusters=experiment_config["clusters"],
            duree="", mem="", env="", gpu="")

        table_name = experiment["table"]

        channel = Channel()

        state["jobman"] = dict(status=channel.START)
        state_to_hash = copy.copy(state)
        jobs = job_scheduler.load_jobs(table_name, hash_of=state_to_hash)
        state_to_hash["jobman"] = dict(status=channel.RUNNING)
        jobs += job_scheduler.load_jobs(table_name, hash_of=state_to_hash)
        if len(jobs) > 0:
            logger.warning("Job already registered, loading from database")
            state = jobs[0]

        if state["jobman"]["status"] != channel.START:
            if not force:
                raise RuntimeError("Job (%d) is not available" % state["id"])

            logging.warning("Job (%d) is not available. Forcing it to run" %
                            state["id"])

        state["jobman"]["status"] = channel.RUNNING

        state = job_scheduler.save_job(table_name, state)

        resolve(function_path_re.sub('', function_path)).jobman_main(state, channel)

        job_scheduler.save_job(experiment["table"], state)
예제 #2
0
def main(args):
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('-o', '--output', metavar='PATH', help='output file.')
    parser.add_argument('file', help='spec json file.')
    parser.add_argument('--bindir',
                        metavar='PATH',
                        default=find_exe.GetDefaultPath(),
                        help='directory to search for all executables.')
    parser.add_argument('--temp-dir',
                        metavar='PATH',
                        help='set the directory that temporary wasm/wat'
                        ' files are written.')
    parser.add_argument(
        '--no-error-cmdline',
        help='don\'t display the subprocess\'s commandline when'
        ' an error occurs',
        dest='error_cmdline',
        action='store_false')
    parser.add_argument('-p',
                        '--print-cmd',
                        help='print the commands that are run.',
                        action='store_true')
    parser.add_argument('--enable-exceptions', action='store_true')
    parser.add_argument('--enable-saturating-float-to-int',
                        action='store_true')
    parser.add_argument('--enable-threads', action='store_true')
    parser.add_argument('--enable-simd', action='store_true')
    parser.add_argument('--enable-sign-extension', action='store_true')
    parser.add_argument('--enable-multi-value', action='store_true')
    parser.add_argument('--enable-bulk-memory', action='store_true')
    parser.add_argument('--enable-tail-call', action='store_true')
    parser.add_argument('--enable-reference-types', action='store_true')
    options = parser.parse_args(args)

    wast2json = Executable(find_exe.GetWast2JsonExecutable(options.bindir),
                           error_cmdline=options.error_cmdline)
    wast2json.verbose = options.print_cmd
    wast2json.AppendOptionalArgs({
        '--enable-exceptions':
        options.enable_exceptions,
        '--enable-multi-value':
        options.enable_multi_value,
        '--enable-saturating-float-to-int':
        options.enable_saturating_float_to_int,
        '--enable-sign-extension':
        options.enable_sign_extension,
        '--enable-simd':
        options.enable_simd,
        '--enable-threads':
        options.enable_threads,
        '--enable-bulk-memory':
        options.enable_bulk_memory,
        '--enable-tail-call':
        options.enable_tail_call,
        '--enable-reference-types':
        options.enable_reference_types,
    })

    json_filename = options.file

    with utils.TempDirectory(options.temp_dir, 'gen-spec-wast-') as temp_dir:
        file_base, file_ext = os.path.splitext(json_filename)
        if file_ext == '.wast':
            wast_filename = options.file
            json_filename = ChangeDir(file_base + '.json', temp_dir)
            wast2json.RunWithArgs(wast_filename, '-o', json_filename)

        with open(json_filename) as json_file:
            json_dir = os.path.dirname(json_filename)
            spec_json = json.load(json_file)

        output = io.StringIO()
        WastWriter(json_dir, spec_json, output).Write()

    if options.output:
        out_file = open(options.output, 'w')
    else:
        out_file = sys.stdout

    try:
        out_file.write(output.getvalue())
    finally:
        out_file.close()

    return 0
예제 #3
0
 def _RunWat2Wasm(self, wat_path):
     wasm_path = ChangeDir(ChangeExt(wat_path, '.wasm'), self.temp_dir)
     self.wat2wasm.RunWithArgs(wat_path, '-o', wasm_path)
     return wasm_path
예제 #4
0
파일: gen-spec-js.py 프로젝트: soapdog/wabt
 def _RunWasm2Wast(self, wasm_path):
     wast_path = ChangeDir(ChangeExt(wasm_path, '.wast'), self.temp_dir)
     self.wasm2wast.RunWithArgs(wasm_path, '-o', wast_path)
     return wast_path