Skip to content

Commit

Permalink
Prefix deployment log messages with the service name (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
benknoll-umn authored Oct 10, 2023
1 parent cb725da commit 0e3b496
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ dependencies = [
"pyyaml==6.0",
"tqdm>=4.0.0,<=4.65.0",
"googleapis-common-protos>=1.3.1,<=1.59.0",
"importlib-resources==5.12.0",
]
dynamic = ["version"]

Expand All @@ -64,7 +65,6 @@ test = [
"pytest-mock==3.10.0",
"grpcio-testing>=1.48.2,<=1.59.0",
"requests==2.31.0",
"importlib-resources==5.12.0",
]
docs = [
"sphinx==7.2.6",
Expand Down
14 changes: 10 additions & 4 deletions python/mtap/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def _get_java() -> str:
JAVA_EXE = _get_java()


def _listen(process: subprocess.Popen) -> int:
def _listen(process: subprocess.Popen, name: str) -> int:
for line in process.stdout:
print(line.decode(), end='', flush=True)
print(f'{name}: {line.decode()}', end='', flush=True)
return process.wait()


Expand Down Expand Up @@ -596,9 +596,14 @@ def _do_launch_all_processors(self, depl: '_ActiveDeployment'):
processor_deployment.startup_timeout
or self.shared_processor_config.startup_timeout
)
name = processor_deployment.name
if name is None:
entry_point = processor_deployment.entry_point
last_period = entry_point.rfind('.')
name = entry_point[last_period + 1:] if last_period > 0 else entry_point
address = depl.start_subprocess(
call,
processor_deployment.entry_point,
name,
sid,
startup_timeout,
enable_proxy
Expand Down Expand Up @@ -633,7 +638,8 @@ def start_subprocess(
start_new_session=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
listener = threading.Thread(target=_listen, args=(p,))
logger_name = f'{name}({sid})'
listener = threading.Thread(target=_listen, args=(p, logger_name))
listener.start()
self._processor_listeners.append(
(p, listener)
Expand Down
3 changes: 2 additions & 1 deletion python/mtap/pipeline/_error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ def __init__(self,
self.output_directory = 'errors' if output_directory is None else output_directory
if serializer is None:
serializer = Serializer.get('json')
if not issubclass(serializer, Serializer): serializer = Serializer.get(serializer)
if not issubclass(serializer, Serializer):
serializer = Serializer.get(serializer)
self.serializer = serializer

@classmethod
Expand Down

0 comments on commit 0e3b496

Please sign in to comment.