diff --git a/src/pfs_target_uploader/pn_app.py b/src/pfs_target_uploader/pn_app.py
index 8110401..aee9d8e 100644
--- a/src/pfs_target_uploader/pn_app.py
+++ b/src/pfs_target_uploader/pn_app.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import os
+import sys
from datetime import datetime, timezone
import gurobipy
@@ -38,11 +39,17 @@ def _toggle_widgets(widgets: list, disabled: bool = True):
def target_uploader_app(use_panel_cli=False):
pn.state.notifications.position = "bottom-left"
+ config = dotenv_values(".env.shared")
+
+ # configure logger to be multiprocessing-safe
+ log_level = config["LOG_LEVEL"] if "LOG_LEVEL" in config.keys() else "INFO"
+ logger.info(f"Log level is set to {log_level}")
+ logger.remove()
+ logger.add(sys.stderr, level=log_level, enqueue=True)
+
logger.info(f"{pn.state.headers=}")
logger.info(f"{pn.state.location.href=}")
- config = dotenv_values(".env.shared")
-
if "MAX_EXETIME" not in config.keys():
max_exetime: int = 900
else:
@@ -434,6 +441,7 @@ def cb_PPP(event):
clustering_algorithm=clustering_algorithm,
quiet=ppp_quiet,
max_exetime=max_exetime,
+ logger=logger,
)
panel_ppp.show_results()
diff --git a/src/pfs_target_uploader/utils/ppp.py b/src/pfs_target_uploader/utils/ppp.py
index 297209b..1535efa 100644
--- a/src/pfs_target_uploader/utils/ppp.py
+++ b/src/pfs_target_uploader/utils/ppp.py
@@ -55,7 +55,12 @@ def PPPrunStart(
quiet=True,
clustering_algorithm="HDBSCAN",
queue=None,
+ logger=None,
):
+ if logger is None:
+ logger.remove()
+ logger.add(sys.stderr, level="INFO", enqueue=True)
+
r_pfi = d_pfi / 2.0
ppp_quiet = quiet
diff --git a/src/pfs_target_uploader/widgets/PppResultWidgets.py b/src/pfs_target_uploader/widgets/PppResultWidgets.py
index 7c9a427..db5527c 100644
--- a/src/pfs_target_uploader/widgets/PppResultWidgets.py
+++ b/src/pfs_target_uploader/widgets/PppResultWidgets.py
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
+import multiprocessing as mp
import sys
-import multiprocessing as mp
import numpy as np
import panel as pn
from astropy import units as u
@@ -55,7 +55,7 @@ def __init__(
self.ppp_error_text_2 = (
"⚠️ **Error**\n\n"
- f"Calculation stops because time is running out. "
+ "Calculation stops because time is running out. "
"If you would get the complete outputs, please modify the input list or consult with the observatory. "
)
@@ -273,7 +273,12 @@ def run_ppp(
clustering_algorithm="HDBSCAN",
quiet=True,
max_exetime=900,
+ logger=None,
):
+ if logger is None:
+ logger.remove()
+ logger.add(sys.stderr, level="INFO", enqueue=True)
+
if weights is None:
weights = [2.02, 0.01, 0.01]
@@ -304,6 +309,7 @@ def run_ppp(
quiet,
clustering_algorithm,
ppp_run_results,
+ logger,
),
)