Skip to content

Commit 900a743

Browse files
authored
Fix empty logs (#400)
* Remove ruff warnings in VScode * Fix error in comets, related to string coercion * Use a dynamic path to the data_dir when searching for logs * Silence warnings in VScode * Patch early to avoid pickle errors in interprocess communication * Fix: Import server again * Fix: collect early logging also in log file * Add missing bracket.
1 parent ca1a8bf commit 900a743

6 files changed

Lines changed: 31 additions & 6 deletions

File tree

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"python.analysis.diagnosticSeverityOverrides": {
3+
"reportUndefinedVariable": "none"
4+
},
5+
"files.associations": {
6+
"*logconf*.json": "jsonc"
7+
}
8+
}
9+

python/PiFinder/comets.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from skyfield.constants import GM_SUN_Pitjeva_2005_km3_s2 as GM_SUN
55
from PiFinder.utils import Timer, comet_file
66
from PiFinder.calc_utils import sf_utils
7+
import pandas as pd
78
import requests
89
import os
910
import logging
@@ -198,6 +199,14 @@ def calc_comets(
198199
.set_index("designation", drop=False)
199200
)
200201

202+
# groupby/last can coerce numeric columns to strings when NaN values
203+
# are present; ensure perihelion date fields are numeric before use
204+
for col in ("perihelion_year", "perihelion_month", "perihelion_day"):
205+
comets_df[col] = pd.to_numeric(comets_df[col], errors="coerce")
206+
comets_df = comets_df.dropna(
207+
subset=["perihelion_year", "perihelion_month", "perihelion_day"]
208+
)
209+
201210
# Report progress after pandas processing (roughly 66% of setup time)
202211
if progress_callback:
203212
progress_callback(2)

python/PiFinder/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151

5252
from PiFinder.displays import DisplayBase, get_display
5353

54+
import PiFinder.manager_patch as patch
55+
5456
from typing import Any, TYPE_CHECKING
5557

5658
# Mypy i8n fix
@@ -124,6 +126,9 @@ def setup_dirs():
124126
os.chmod(Path(utils.data_dir), 0o777)
125127

126128

129+
patch.apply()
130+
131+
127132
class StateManager(BaseManager):
128133
pass
129134

@@ -348,10 +353,6 @@ def main(
348353
)
349354
langXX.install()
350355

351-
import PiFinder.manager_patch as patch
352-
353-
patch.apply()
354-
355356
with StateManager() as manager:
356357
shared_state = manager.SharedState() # type: ignore[attr-defined]
357358
location = shared_state.location()

python/PiFinder/multiproclogging.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ def start(self, initial_queue: Optional[Queue] = None):
8787
len(self._queues) >= 1
8888
), "No queues in use. You should have requested at least one queue."
8989

90+
# Create the main-process queue BEFORE starting the sink so the sink
91+
# receives it in its queue list and monitors it.
92+
queue = initial_queue if initial_queue is not None else self.get_queue()
93+
9094
self._proc = Process(
9195
target=self._run_sink,
9296
args=(
@@ -97,7 +101,6 @@ def start(self, initial_queue: Optional[Queue] = None):
97101
# Start separate process that consumes from the queues.
98102
self._proc.start()
99103
# Now in this process we can divert logging to the newly created class
100-
queue = self.get_queue()
101104
MultiprocLogging.configurer(queue)
102105

103106
def join(self):

python/PiFinder/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ def logs_page():
781781
def stream_logs():
782782
try:
783783
position = int(request.query.get("position", 0))
784-
log_file = "/home/pifinder/PiFinder_data/pifinder.log"
784+
log_file = str(utils.data_dir / "pifinder.log")
785785

786786
try:
787787
file_size = os.path.getsize(log_file)

python/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ indent-width = 4
4242
# Assume Python 3.9
4343
target-version = "py39"
4444

45+
# _ is the i18n/gettext builtin injected at runtime
46+
builtins = ["_"]
47+
4548
[tool.ruff.lint]
4649
# Enable preview mode, allow os.env changes before imports
4750
preview = true

0 commit comments

Comments
 (0)