コード例 #1
0
    def run(self):
        atexit.register(self.killed, self.run_id)

        context = zmq.Context()
        self.socket = context.socket(zmq.DEALER)
        self.socket.connect(self.server_address)

        send_event(self.socket, WORKER_JOIN, self.run_id)
        run = decode_message(self.socket.recv())

        tool = import_class(run["tool"])

        context = {}
        context["socket"] = self.socket
        context["tool"] = tool
        context["run"] = run
        logger.info(f"Processing task: {run['directory']}")

        directory = Path(run["directory"])
        directory.mkdir(parents=True, exist_ok=True)

        payload = dict(tool_version=tool.version(), run_id=self.run_id)
        send_event(self.socket, RUN_START, payload)

        for runstep in run["steps"]:
            logger.debug(f"Running step {runstep['module']}")
            step = import_class(runstep["module"])
            config = json.loads(runstep["config"])
            step.execute(context, config)
            payload = {"run_id": self.run_id, "step": runstep["module"]}
            send_event(self.socket, RUN_STEP, payload)

        send_event(self.socket, RUN_FINISH, self.run_id)
        atexit.unregister(self.killed)
        send_event(self.socket, WORKER_LEAVE, self.run_id)
コード例 #2
0
    def bootstrap(self):
        self.socket.connect(self.server_address)

        client_results = bootstrap_client(self.config)
        bootstrapped_config = {**self.config, **client_results}

        logger.info("Sending bootstrap event to server")
        payload = dict(config=bootstrapped_config,
                       output_dir=self.output_dir,
                       repeat=self.repeat)
        send_event(self.socket, BOOTSTRAP, payload)

        self.pending = decode_message(self.socket.recv())
コード例 #3
0
 def receive_event(self):
     address, event_type, payload = self.frontend.recv_multipart()
     logger.trace((address, event_type, decode_message(payload)))
     return address, event_type, payload
コード例 #4
0
ファイル: base.py プロジェクト: fossabot/reprobench
 def get_pending_runs(self):
     send_event(self.socket, REQUEST_PENDING)
     self.queue = decode_message(self.socket.recv())