#!/usr/bin/env python # coding: utf-8 import o_p from call_cmd import call_cmd if __name__ == '__main__': from parse_options import parse_args dir_fpath, tar_fname = parse_args("local_dir", "tar_fname") if o_p.exists(tar_fname): res = o_p.remove_file(tar_fname) assert res # :REFACTOR: call_cmd("tar -cf %(tar_fname)s -C %(dir_fpath)s ." % locals())
from parse_options import parse_args, print_args class Trainer: def __init__(self, options): pass if __name__ == "__main__": options = parse_args("train") if options.args_verbose == True: print_args(options) gan_trainer = Trainer(options)
src = "last" if to_last else "previous" # :TRICKY: для переопределения сущ. ссылки нужно одновременно -f и -n ,- # артефакт *nix call_cmd("ln -s -f -n %s current" % src, cwd=dir_fpath) last_fpath = o_p.join(dir_fpath, "last") curr_fpath = o_p.join(dir_fpath, "current") if os.path.exists(last_fpath): curr_exists = False if os.path.exists(curr_fpath): assert os.path.islink(curr_fpath) curr_exists = True prev_fpath = o_p.join(dir_fpath, "previous") if os.path.exists(prev_fpath): shutil.rmtree(prev_fpath) shutil.move(last_fpath, prev_fpath) if curr_exists: set_current(False) os.mkdir(last_fpath) call_cmd("tar -xzf %(rpkg_tar_gz)s -C %(last_fpath)s" % locals()) set_current(True) if __name__ == '__main__': from parse_options import parse_args rpkg_tar_gz, dir_fpath = parse_args("rpkg.tar.gz", "local_dir") install(rpkg_tar_gz, dir_fpath)
from parse_options import parse_args, print_args class Inferencer: def __init__(self, options): pass if __name__ == "__main__": options = parse_args("inference") inferencer = Inferencer(options)
from parse_options import parse_args, print_args class Validation : def __init__(self, options): pass if __name__ == "__main__" : options = parse_args("validation") if options.args_verbose == True: print_args(options) gan_validation = Validation(options)
# :TRICKY: для переопределения сущ. ссылки нужно одновременно -f и -n ,- # артефакт *nix call_cmd("ln -s -f -n %s current" % src, cwd=dir_fpath) last_fpath = o_p.join(dir_fpath, "last") curr_fpath = o_p.join(dir_fpath, "current") if os.path.exists(last_fpath): curr_exists = False if os.path.exists(curr_fpath): assert os.path.islink(curr_fpath) curr_exists = True prev_fpath = o_p.join(dir_fpath, "previous") if os.path.exists(prev_fpath): shutil.rmtree(prev_fpath) shutil.move(last_fpath, prev_fpath) if curr_exists: set_current(False) os.mkdir(last_fpath) call_cmd("tar -xzf %(rpkg_tar_gz)s -C %(last_fpath)s" % locals()) set_current(True) if __name__ == '__main__': from parse_options import parse_args rpkg_tar_gz, dir_fpath = parse_args("rpkg.tar.gz", "local_dir") install(rpkg_tar_gz, dir_fpath)