forked from M-Labs/artiq
master: add filename in worker log entries. Closes #226
This commit is contained in:
parent
cc6b808bf8
commit
ae19f1c75d
@ -18,7 +18,7 @@ async def _get_repository_entries(entry_dict,
|
||||
root, filename, get_device_db, log):
|
||||
worker = Worker({
|
||||
"get_device_db": get_device_db,
|
||||
"log": partial(log, "scan")
|
||||
"log": partial(log, "scan", os.path.basename(filename))
|
||||
})
|
||||
try:
|
||||
description = await worker.examine(os.path.join(root, filename))
|
||||
@ -124,7 +124,7 @@ class ExperimentDB:
|
||||
filename = os.path.join(wd, filename)
|
||||
worker = Worker({
|
||||
"get_device_db": self.get_device_db_fn,
|
||||
"log": partial(self.log_fn, "examine")
|
||||
"log": partial(self.log_fn, "examine", os.path.basename(filename))
|
||||
})
|
||||
try:
|
||||
description = await worker.examine(filename)
|
||||
|
@ -29,11 +29,11 @@ class LogBufferHandler(logging.Handler):
|
||||
part)
|
||||
|
||||
|
||||
def log_worker(rid, message):
|
||||
def log_worker(rid, filename, message):
|
||||
level, name, message = parse_log_message(message)
|
||||
log_with_name(name, level, message,
|
||||
extra={"source": "worker({})".format(rid)})
|
||||
log_worker.worker_pass_rid = True
|
||||
extra={"source": "worker({},{})".format(rid, filename)})
|
||||
log_worker.worker_pass_runinfo = True
|
||||
|
||||
|
||||
def log_args(parser):
|
||||
|
@ -1,4 +1,5 @@
|
||||
import sys
|
||||
import os
|
||||
import asyncio
|
||||
import logging
|
||||
import subprocess
|
||||
@ -45,6 +46,7 @@ class Worker:
|
||||
self.send_timeout = send_timeout
|
||||
|
||||
self.rid = None
|
||||
self.filename = None
|
||||
self.process = None
|
||||
self.watchdogs = dict() # wid -> expiration (using time.monotonic)
|
||||
|
||||
@ -191,8 +193,8 @@ class Worker:
|
||||
func = self.register_experiment
|
||||
else:
|
||||
func = self.handlers[action]
|
||||
if getattr(func, "worker_pass_rid", False):
|
||||
func = partial(func, self.rid)
|
||||
if getattr(func, "worker_pass_runinfo", False):
|
||||
func = partial(func, self.rid, self.filename)
|
||||
try:
|
||||
data = func(*obj["args"], **obj["kwargs"])
|
||||
reply = {"status": "ok", "data": data}
|
||||
@ -227,6 +229,7 @@ class Worker:
|
||||
|
||||
async def build(self, rid, pipeline_name, wd, expid, priority, timeout=15.0):
|
||||
self.rid = rid
|
||||
self.filename = os.path.basename(expid["file"])
|
||||
await self._create_process(expid["log_level"])
|
||||
await self._worker_action(
|
||||
{"action": "build",
|
||||
|
Loading…
Reference in New Issue
Block a user