def execute_task(task): if is_up_to_date(task): print(get_name(task) + ' - up to date.') else: for action in task['actions']: print(action) run(action)
def install(file, dir, mode): f = getDest(file, dir) print("install: " + f) run('install -d ' + dest + prefix + dir) run('install -m ' + ` mode ` + ' ' + file + ' ' + dest + prefix + dir + '/') installed.write(f + "\n")
def compile_translations(): for f_name in glob.glob('po/*.po'): lang = f_name.replace("po/", "").replace(".po", "") lang = lang.replace("\\", "/") build_path = "build/locale/" + lang + "/LC_MESSAGES/" target = build_path + "birdfont.mo" run("mkdir -p " + build_path) f_name = f_name.replace("\\", "/") run("msgfmt --output=%s %s" % (target, f_name))
def compile_translations (): for f_name in glob.glob('po/*.po'): lang = f_name.replace ("po/", "").replace (".po", "") lang = lang.replace ("\\", "/") build_path = "build/locale/" + lang + "/LC_MESSAGES/" target = build_path + "birdfont.mo" run ("mkdir -p " + build_path); f_name = f_name.replace ("\\", "/") run ("msgfmt --output=%s %s" % (target, f_name));
def eval(args): dirs = [f.path for f in os.scandir(args.models_path) if f.is_dir()] for dir in dirs: if os.path.exists(os.path.join(dir, "conf.ini")) and os.path.exists( os.path.join(dir, "model.pth")): conf_path = os.path.join(dir, "conf.ini") config = configparser.ConfigParser() config.read(conf_path) # defaults = {} # defaults.update(dict(config.items("main"))) defaults = { key: cast_value(value) for key, value in dict(config.items("main")).items() } defaults["num_episodes_train"] = 0 defaults["device_id"] = 0 defaults["K_epochs"] = defaults["k_epochs"] defaults["old_policy_path"] = defaults["policy_path"] defaults["policy_path"] = os.path.join(dir, "model.pth") if args.num_diversity is not None: defaults["num_diversity"] = args.num_diversity if args.num_episodes_test is not None: defaults["num_episodes_test"] = args.num_episodes_test if args.test_metrics is not None: defaults["test_metrics"] = args.test_metrics if "test_modes" in defaults.keys() and args.test_modes is not None: defaults["test_modes"] = args.test_modes if "eval_modes" in defaults.keys() and args.eval_modes is not None: defaults["eval_modes"] = args.eval_modes if "temp_factor" in defaults.keys(): if "inv_schedule_step" in defaults.keys(): if defaults["inv_schedule_step"] == 0: if defaults["temp_factor"] < 1: defaults["temperature"] = defaults["temp_min"] elif defaults["temp_factor"] > 1: defaults["temperature"] = defaults["temp_max"] else: if defaults["temp_factor"] > 1: defaults["temperature"] = defaults["temp_min"] elif defaults["temp_factor"] < 1: defaults["temperature"] = defaults["temp_max"] else: if defaults["temp_factor"] < 1: defaults["temperature"] = defaults["temp_min"] elif defaults["temp_factor"] > 1: defaults["temperature"] = defaults["temp_max"] conf_parser = get_run_parser() conf_parser.set_defaults(**defaults) # args_list=list(np.array(list(defaults.items())).ravel()) run_args = conf_parser.parse_known_args() print(run_args) run(run_args[0])
def objective(params): generic_args = {} params = {**params, **generic_args} for key, value in params.items(): setattr(args, key, value) print(args) agent = run(args) rewards = agent.train_metrics["reward"].metric_history loss = -np.mean(rewards[-agent.log_interval:]) # run() return { 'loss': loss, 'status': STATUS_OK, 'eval_time': time.time(), **params }
def install (file, dir, mode): f = getDest (file, dir) print ("install: " + f) run ('install -d ' + dest + prefix + dir) run ('install -m ' + str(mode) + ' ' + file + ' ' + dest + prefix + dir + '/') installed.write (f + "\n")
def build_tests(): tests = all_tests() + ["fuzz"] run ("mkdir -p build/bin"); run ("mkdir -p build/tests"); for test in tests: run ("valac --ccode --pkg=posix --pkg=xmlbird --vapidir=./build " + "--directory=./build tests/" + test + ".vala tests/Test.vala"); run ("""gcc -fPIC -c \ -I ./build/xmlbird \ $(pkg-config --cflags glib-2.0) \ $(pkg-config --cflags gobject-2.0) \ -I ./build -L./build/bin -lxmlbird \ build/tests/""" + test + """.c \ build/tests/Test.c"""); run ("mv *.o build/tests/"); run ("""gcc build/tests/""" + test + """.o build/tests/Test.o \ $(pkg-config --libs glib-2.0) \ $(pkg-config --libs gobject-2.0) \ -L./build/bin -lxmlbird \ -o ./build/bin/""" + test);
if not options.threshold: for pofile in glob.glob('po/*.po'): completed = completeness (pofile) print (pofile + " " + str (completed) + "%") elif options.compiled: for pofile in glob.glob('po/*.po'): completed = completeness (pofile) podir = pofile.replace ("po/", "") podir = podir.replace (".po", "") podir = podir.replace ("\\", "/") if completed >= float (options.threshold): print ("Releasing " + podir) else: print ("Removing incomplete translation " + podir) run ("mkdir -p build/incomplete") run ("mv build/locale/" + podir + " build/incomplete/") elif options.incomplete: for pofile in glob.glob('po/*.po'): completed = completeness (pofile) if completed >= float (options.threshold): print ("Releasing " + pofile) else: print ("Moving incomplete translation " + pofile + " to po/incomplete/") run ("mkdir -p po/incomplete") run ("mv " + pofile + " po/incomplete/") else: for pofile in glob.glob('po/*.po'): completed = completeness (pofile) if completed >= float (options.threshold): print (pofile)
config.directory = timestamped_dir config.mesh = stl_file config.part_separation = True config.save() Configuration.config = config # run starter = utils.open_mesh() scale_factor = np.ceil( 1.1 * config.printer_extents / starter.bounding_box_oriented.primitive.extents).max() config.scale_factor = scale_factor starter = utils.open_mesh() # split into separate components if config.part_separation and starter.body_count > 1: starter = utils.separate_starter(starter) try: logger.info( f"running pychop on {name}, scale_factor: {scale_factor}") run.run(starter) # catch failure and move the timestamped directory to 'failed' except Exception as e: dump_error(timestamped_dir) n_failed += 1 failed_directory = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', 'failed', date_string)) shutil.move(timestamped_dir, failed_directory) logging.info( f"{N_ITERATIONS} attempts: {(N_ITERATIONS - n_failed) / N_ITERATIONS} success rate" )
def install_root(file, dir, mode): f = getDestRoot(file, dir) print("install: " + f) run('install -d ' + dest + dir) run('install -m ' + str(mode) + ' ' + file + ' ' + dest + dir + '/')
def build_tests(): tests = all_tests() + ["fuzz"] run("mkdir -p build/bin") run("mkdir -p build/tests") for test in tests: run(VALAC + " --ccode --pkg=posix --pkg=xmlbird --vapidir=./build " + "--directory=./build tests/" + test + ".vala tests/Test.vala") run("""gcc -fPIC -c \ -I ./build/xmlbird \ $(pkg-config --cflags glib-2.0) \ $(pkg-config --cflags gobject-2.0) \ -I ./build -L./build/bin -lxmlbird \ build/tests/""" + test + """.c \ build/tests/Test.c""") run("mv *.o build/tests/") run("""gcc build/tests/""" + test + """.o build/tests/Test.o \ $(pkg-config --libs glib-2.0) \ $(pkg-config --libs gobject-2.0) \ -L./build/bin -lxmlbird \ -o ./build/bin/""" + test)
from scripts.run import run run()
def install_root (file, dir, mode): f = getDestRoot (file, dir) print ("install: " + f) run ('install -d ' + dest + dir) run ('install -m ' + str(mode) + ' ' + file + ' ' + dest + dir + '/')
def link(dir, file, linkname): f = getDest(linkname, dir) print("install link: " + f) run('cd ' + dest + prefix + dir + ' && ln -sf ' + file + ' ' + linkname) installed.write(f + "\n")
def link (dir, file, linkname): f = getDest (linkname, dir) print ("install link: " + f) run ('cd ' + dest + prefix + dir + ' && ln -sf ' + file + ' ' + linkname) installed.write (f + "\n")
from scripts import parser, run import os import sys from scripts.config import config if len(sys.argv) > 1: file = sys.argv[-1] else: if os.name == 'nt' and config.get("Console", "use_fileopen_dialog") == 'yes': from tkinter.filedialog import askopenfilename from tkinter import Tk window = Tk() window.withdraw() file = askopenfilename() else: file = input("Enter file name: ") run.run(*parser.parse(file)) input("Press ENTER to exit...")