Skip to content

Commit af978a0

Browse files
fix for leader-only units
1 parent b14a09a commit af978a0

File tree

6 files changed

+43
-23
lines changed

6 files changed

+43
-23
lines changed

asset-manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"files": {
33
"main.css": "/static/css/main.02152627.css",
4-
"main.js": "/static/js/main.1bd8013b.js",
4+
"main.js": "/static/js/main.0a4f5feb.js",
55
"static/media/roboto-all-500-normal.woff": "/static/media/roboto-all-500-normal.0ab669b7a0d19b178f57.woff",
66
"static/media/roboto-all-700-normal.woff": "/static/media/roboto-all-700-normal.a457fde362a540fcadff.woff",
77
"static/media/roboto-all-400-normal.woff": "/static/media/roboto-all-400-normal.c5d001fa922fa66a147f.woff",
@@ -36,10 +36,10 @@
3636
"static/media/roboto-greek-ext-700-normal.woff2": "/static/media/roboto-greek-ext-700-normal.bd9854c751441ccc1a70.woff2",
3737
"index.html": "/index.html",
3838
"main.02152627.css.map": "/static/css/main.02152627.css.map",
39-
"main.1bd8013b.js.map": "/static/js/main.1bd8013b.js.map"
39+
"main.0a4f5feb.js.map": "/static/js/main.0a4f5feb.js.map"
4040
},
4141
"entrypoints": [
4242
"static/css/main.02152627.css",
43-
"static/js/main.1bd8013b.js"
43+
"static/js/main.0a4f5feb.js"
4444
]
4545
}

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Pioreactor"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.1bd8013b.js"></script><link href="/static/css/main.02152627.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
1+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Pioreactor"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.0a4f5feb.js"></script><link href="/static/css/main.02152627.css" rel="stylesheet"></head><body><div id="root"></div></body></html>

pioreactorui/api.py

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ def get_recent_logs(experiment: str) -> ResponseReturnValue:
393393
return jsonify(recent_logs)
394394

395395

396-
@api.route("/experiments/<experiment>/logs", methods=["GET"])
397-
def get_exp_logs(experiment: str) -> ResponseReturnValue:
396+
@api.route("/logs", methods=["GET"])
397+
def get_logs() -> ResponseReturnValue:
398398
"""Shows event logs from all units, uses pagination."""
399399

400400
skip = int(request.args.get("skip", 0))
@@ -403,21 +403,15 @@ def get_exp_logs(experiment: str) -> ResponseReturnValue:
403403
recent_logs = query_app_db(
404404
f"""SELECT l.timestamp, level, l.pioreactor_unit, message, task, l.experiment
405405
FROM logs AS l
406-
JOIN experiment_worker_assignments_history h
407-
on h.pioreactor_unit = l.pioreactor_unit
408-
and h.assigned_at <= l.timestamp
409-
and DATETIME(l.timestamp) <= DATETIME(coalesce(h.unassigned_at, STRFTIME('%Y-%m-%dT%H:%M:%f000Z', 'NOW')), '+5 seconds')
410-
WHERE (l.experiment=? )
411-
AND ({get_level_string(min_level)})
412-
ORDER BY l.timestamp DESC LIMIT 50 OFFSET {skip};""",
413-
(experiment,),
406+
WHERE ({get_level_string(min_level)})
407+
ORDER BY l.timestamp DESC LIMIT 50 OFFSET {skip};"""
414408
)
415409

416410
return jsonify(recent_logs)
417411

418412

419-
@api.route("/logs", methods=["GET"])
420-
def get_logs() -> ResponseReturnValue:
413+
@api.route("/experiments/<experiment>/logs", methods=["GET"])
414+
def get_exp_logs(experiment: str) -> ResponseReturnValue:
421415
"""Shows event logs from all units, uses pagination."""
422416

423417
skip = int(request.args.get("skip", 0))
@@ -426,8 +420,14 @@ def get_logs() -> ResponseReturnValue:
426420
recent_logs = query_app_db(
427421
f"""SELECT l.timestamp, level, l.pioreactor_unit, message, task, l.experiment
428422
FROM logs AS l
429-
WHERE ({get_level_string(min_level)})
430-
ORDER BY l.timestamp DESC LIMIT 50 OFFSET {skip};"""
423+
JOIN experiment_worker_assignments_history h
424+
on h.pioreactor_unit = l.pioreactor_unit
425+
and h.assigned_at <= l.timestamp
426+
and DATETIME(l.timestamp) <= DATETIME(coalesce(h.unassigned_at, STRFTIME('%Y-%m-%dT%H:%M:%f000Z', 'NOW')), '+5 seconds')
427+
WHERE (l.experiment=? )
428+
AND ({get_level_string(min_level)})
429+
ORDER BY l.timestamp DESC LIMIT 50 OFFSET {skip};""",
430+
(experiment,),
431431
)
432432

433433
return jsonify(recent_logs)
@@ -460,7 +460,7 @@ def get_recent_logs_for_unit_and_experiment(
460460

461461
@api.route("/workers/<pioreactor_unit>/experiments/<experiment>/logs", methods=["GET"])
462462
def get_logs_for_unit_and_experiment(pioreactor_unit: str, experiment: str) -> ResponseReturnValue:
463-
"""Shows event logs from all units, uses pagination."""
463+
"""Shows event logs from specific unit and experiment, uses pagination."""
464464

465465
skip = int(request.args.get("skip", 0))
466466
min_level = request.args.get("min_level", "INFO")
@@ -482,6 +482,26 @@ def get_logs_for_unit_and_experiment(pioreactor_unit: str, experiment: str) -> R
482482
return jsonify(recent_logs)
483483

484484

485+
@api.route("/units/<pioreactor_unit>/system_logs", methods=["GET"])
486+
def get_system_logs_for_unit(pioreactor_unit: str) -> ResponseReturnValue:
487+
"""Shows system logs from specific unit uses pagination."""
488+
489+
skip = int(request.args.get("skip", 0))
490+
min_level = request.args.get("min_level", "INFO")
491+
492+
recent_logs = query_app_db(
493+
f"""SELECT l.timestamp, l.level, l.pioreactor_unit, l.message, l.task, l.experiment
494+
FROM logs AS l
495+
WHERE (l.experiment="$experiment")
496+
AND (l.pioreactor_unit=? or l.pioreactor_unit=?)
497+
AND ({get_level_string(min_level)})
498+
ORDER BY l.timestamp DESC LIMIT 50 OFFSET {skip};""",
499+
(pioreactor_unit, UNIVERSAL_IDENTIFIER),
500+
)
501+
502+
return jsonify(recent_logs)
503+
504+
485505
@api.route("/units/<pioreactor_unit>/logs", methods=["GET"])
486506
def get_logs_for_unit(pioreactor_unit: str) -> ResponseReturnValue:
487507
"""Shows event logs from all units, uses pagination."""
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)