Skip to content

Commit ee09142

Browse files
update
1 parent 843a12a commit ee09142

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

pioreactorui/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
logger.debug(f"Starting {NAME}={VERSION} on {HOSTNAME}...")
5656
logger.debug(f".env={dict(env)}")
5757

58-
client = mqtt.Client(callback_api_version=CallbackAPIVersion.VERSION2)
58+
client = mqtt.Client(client_id="pioreactor_ui", callback_api_version=CallbackAPIVersion.VERSION2)
5959
client.username_pw_set(
6060
pioreactor_config.get("mqtt", "username", fallback="pioreactor"),
6161
pioreactor_config.get("mqtt", "password", fallback="raspberry"),
@@ -192,12 +192,11 @@ def _get_temp_local_metadata_db_connection():
192192
db = getattr(g, "_local_metadata_database", None)
193193
if db is None:
194194
db = g._local_metadata_database = sqlite3.connect(
195-
pioreactor_config.get("storage", "temporary_cache")
195+
f'file:{pioreactor_config.get("storage", "temporary_cache")}?mode=ro', uri=True
196196
)
197197
db.row_factory = _make_dicts
198198
db.executescript(
199199
"""
200-
PRAGMA synchronous = 1; -- aka NORMAL, recommended when using WAL
201200
PRAGMA temp_store = 2; -- stop writing small files to disk, use mem
202201
PRAGMA busy_timeout = 15000;
203202
PRAGMA foreign_keys = ON;

pioreactorui/api.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,12 @@ def get_logs_for_unit(pioreactor_unit: str) -> ResponseReturnValue:
518518

519519

520520
@api.route("/workers/<pioreactor_unit>/experiments/<experiment>/logs", methods=["POST"])
521+
@api.route("/units/<pioreactor_unit>/experiments/<experiment>/logs", methods=["POST"])
521522
def publish_new_log(pioreactor_unit: str, experiment: str) -> ResponseReturnValue:
522523
body = request.get_json()
524+
source_ = body.get("source_", "ui")
523525

524-
topic = f"pioreactor/{pioreactor_unit}/{experiment}/logs/ui/{body['level'].lower()}"
526+
topic = f"pioreactor/{pioreactor_unit}/{experiment}/logs/{source_}/{body['level'].lower()}"
525527
client.publish(
526528
topic,
527529
msg_to_JSON(
@@ -1275,14 +1277,14 @@ def export_datasets() -> ResponseReturnValue:
12751277
"--output", filename_with_path.as_posix(), *cmd_tables, *experiment_options, *other_options
12761278
)
12771279
try:
1278-
status = result(blocking=True, timeout=5 * 60)
1280+
status, msg = result(blocking=True, timeout=5 * 60)
12791281
except (HueyException, TaskException):
12801282
status = False
12811283
return {"result": status, "filename": None, "msg": "Timed out"}, 500
12821284

12831285
if not status:
1284-
publish_to_error_log("Failed.", "export_datasets")
1285-
return {"result": status, "filename": None, "msg": "Failed."}, 500
1286+
publish_to_error_log(msg, "export_datasets")
1287+
return {"result": status, "filename": None, "msg": msg}, 500
12861288

12871289
return {"result": status, "filename": filename, "msg": "Finished"}, 200
12881290

pioreactorui/tasks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ def pio_plugins_list(*args: str, env: dict[str, str] = {}) -> tuple[bool, str]:
204204

205205
@huey.task()
206206
@huey.lock_task("export-data-lock")
207-
def pio_run_export_experiment_data(*args: str, env: dict[str, str] = {}) -> bool:
207+
def pio_run_export_experiment_data(*args: str, env: dict[str, str] = {}) -> tuple[bool, bytes]:
208208
logger.info(f'Executing `{join(("pio", "run", "export_experiment_data") + args)}`, {env=}')
209209
result = run(
210210
(PIO_EXECUTABLE, "run", "export_experiment_data") + args,
211211
env=dict(os.environ) | env,
212212
)
213-
return result.returncode == 0
213+
return result.returncode == 0, result.stdout.strip()
214214

215215

216216
@huey.task(priority=100)
@@ -391,7 +391,7 @@ def multicast_post_across_cluster(
391391

392392
@huey.task(priority=10)
393393
def get_from_worker(
394-
worker: str, endpoint: str, json: dict | None = None, timeout=1.0, return_raw=False
394+
worker: str, endpoint: str, json: dict | None = None, timeout=5.0, return_raw=False
395395
) -> tuple[str, Any]:
396396
try:
397397
address = resolve_to_address(worker)
@@ -419,7 +419,7 @@ def multicast_get_across_cluster(
419419
endpoint: str,
420420
workers: list[str],
421421
json: dict | list[dict | None] | None = None,
422-
timeout: float = 1.0,
422+
timeout: float = 5.0,
423423
return_raw=False,
424424
) -> dict[str, Any]:
425425
# this function "consumes" one huey thread waiting fyi

pioreactorui/unit_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def get_all_calibrations_as_zipped_yaml() -> ResponseReturnValue:
720720
buffer = BytesIO()
721721

722722
with zipfile.ZipFile(buffer, "w", zipfile.ZIP_DEFLATED) as zip_file:
723-
for file_path in sorted(calibration_dir.rglob("*")):
723+
for file_path in sorted(calibration_dir.rglob("*.yaml")):
724724
if file_path.is_file():
725725
arc_name = file_path.relative_to(calibration_dir)
726726
zip_file.write(str(file_path), arcname=str(arc_name))

0 commit comments

Comments
 (0)