def run(): parser = argparse.ArgumentParser() parser.add_argument( '-c', '--config', metavar='FILE', help="path to configuration file", default="~/gtlaunch.json", ) parser.add_argument( '-v', '--verbose', help="verbose output", action='store_true', ) parser.add_argument( '-V', '--version', action='version', version='%%(prog)s %s' % __version__, ) group = parser.add_mutually_exclusive_group(required=True) group.add_argument( '-l', '--list', help="list all projects", action='store_true', ) group.add_argument( dest='project', metavar='PROJECT', help="project label", nargs='?', ) args = parser.parse_args() try: launcher = Launcher(args) launcher.run() except LauncherError as e: print("Launcher error: {}".format(e)) sys.exit(1)
def launchExecutor(self, framework_id, info, executor_info, directory, resources): fid = framework_id.value eid = executor_info.executor_id.value logger.info("Launching %s (%s) in %s with resources %s for framework %s", eid, executor_info.command.value, directory, resources, fid) pid = os.fork() assert pid >= 0 if pid: logger.info("Forked executor at %d", pid) pinfo = ProcessInfo(framework_id, executor_info.executor_id, pid, directory) self.infos.setdefault(fid, {})[eid] = pinfo self.pids[pid] = pinfo self.slave.executorStarted(framework_id, executor_info.executor_id, pid) else: #pid = os.setsid() # copy UPID of slave launcher = Launcher(framework_id, executor_info.executor_id, executor_info.command, info.user, directory, self.slave) launcher.run()
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ import bootstrap from config import Config from log import EntityLoggerProxy from log.level import TRACE from maps.calculator import Calculator from launcher import Launcher """ Simple example that validates that the calculator is present on the screen. Results can be found in the /results directory. """ # Change logging level verbosity EntityLoggerProxy.getLogger().setLevel(TRACE) Config.setScreenshotLoggingLevel(TRACE) # Launch the Calculator binary calculator = Launcher.run('Calculator') # Validate that the calculator exists on the screen calculator.validate()
filled_settings[args_key] = args_value if len(filled_settings): return None return filled_settings if __name__ == '__main__': args_dict = { 'launch_mode': ['--launch_mode', None, str, '指定启动模式'], 'dataset_dir': ['--dataset_dir', None, str, '训练数据目录'], 'valid_dir': ['--valid_dir', None, str, '验证数据目录'], 'test_dir': ['--test_dir', None, str, '测试数据目录'], 'net_path': ['--net_path', None, str, '网络保存路径'], 'anchors': ['--anchors', None, str, '目标参考框'], 'epochs': ['--epochs', None, int, '训练轮次'], 'batch_size': ['--batch_size', None, int, '训练批次大小'], 'is_new': ['--is_new', False, bool, '指定是否重头训练'] } parser = argparse.ArgumentParser(description='Hyperparams') for args_key, args_list in args_dict.items(): parser.add_argument(args_list[0], nargs='?', default=args_list[1], type=args_list[2], help=args_list[3]) parser.set_defaults(tboard=False) args = parser.parse_args() filled_settings = cvt_args2dict(args) runner = Launcher(filled_settings) runner.run()
#!/usr/bin/env python3 from tools import set_parameters from launcher import Launcher from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister parameters = set_parameters() # parameters['backend_name'] = 'qasm_simulator' # parameters['shots'] = 100 launcher = Launcher( **{item: parameters[item] for item in ['backend_name', 'shots']}) qr, cr = QuantumRegister(5), ClassicalRegister(5) circuit = QuantumCircuit(qr, cr) circuit.u3(0, 0, 0, qr[0]) circuit.h(qr[0]) circuit.cx(qr[0], qr[1]) # meas_qubits - кубиты, использующиеся для томографии. Порядок важен (для [0, 1] и [1, 0] ответ будет разным) print(launcher.run([circuit], meas_qubits=[0]))
from launcher import Launcher if __name__ == '__main__': l = Launcher() l.run()
def launch(self): self.entity = Launcher.run('Calculator')
class BenchmarkContext: index = 0 def __init__(self, params, workdir, config_template, env={}, config={}): BenchmarkContext.index += 1 self.params = params self.env = env self.config = config self.config_template = config_template self.workdir = os.path.join(workdir, f"test_{BenchmarkContext.index}") self.duration = 0 self.program_config = os.path.join(os.getcwd(), self.workdir, "benchmark.json") self.__create_dir() self.__dump_env() self.__prepare_launcher() self.__prepare_stats() def __create_dir(self): os.mkdir(self.workdir) #Create plot dir os.mkdir(os.path.join(self.workdir, "plots")) def __dump_params(self, params): with open(os.path.join(self.workdir, "params.yaml"), "w") as f: yaml.dump(params, f) def __dump_env(self): with open(os.path.join(self.workdir, "env.yaml"), "w") as f: yaml.dump(self.env, f) def __create_config(self, params): data = "" with open(self.config_template) as f: data = f.read() for key, value in params.items(): data = data.replace(f"${key}", str(value)) with open(self.program_config, "w") as f: f.write(data) def __prepare_launcher(self): params = self.__prepare_params(self.params) executable = self.config["test"]["command"].split() + [ "-b", "--monitoring-backend", self.config["test"]["config"]["monitoring"], "--config-path", self.program_config ] self.__dump_params(dict(executable=" ".join(executable), **params)) self.__create_config(params) self.launcher = Launcher(executable, self.workdir, self.env, self.config) def __prepare_stats(self): self.stats = StatisticManager(self.workdir, self.config) def run(self): print(f"Running with parameters: {self.params}") self.stats.pre() self.launcher.run() time.sleep(10) self.stats.start() if self.duration: t = datetime.datetime.now() + datetime.timedelta( seconds=self.duration - 10) print( f"Launched. Test expected to end at {t.strftime('%H:%M:%S')}") try: self.launcher.wait() except KeyboardInterrupt: self.launcher.force_quit() self.stats.stop() self.stats.post() def __prepare_params(self, params): params.update(self.config["test"]["config"]) params["duration"] = time_to_usec( self.config["test"]["duration"]) // 10**6 params["delay"] = time_to_usec(self.config["test"]["delay"]) // 10**6 self.duration = params["duration"] + params["delay"] return params
from region.transform import RegionMorph from launcher import Launcher """ Simple example that validates that the calculator is present on the screen. This example does not use the Launcher() class so it assumes that the application is already running. Results can be found in the /results directory. """ # Change logging level verbosity #EntityLoggerProxy.getLogger().setLevel(TRACE) Config.setScreenshotLoggingLevel(TRACE) # Launch the Calculator binary textedit = Launcher.run('TextEdit') logger = EntityLoggerProxy(textedit) # Type some text in the text area textedit[TextEdit.TEXT_AREA].type("This is a demo of SikuliFramework") # Resize the application size 4 times for i in range(0,4): # Get the current application region region = textedit.validate().region # Alternate between growing / shrinking application width offset = 100 * (1 - ((i % 2)*2)) # Modify the size of current application region