Skip to content

Commit 82e6aa6

Browse files
types
1 parent 802f2e0 commit 82e6aa6

File tree

12 files changed

+143
-140
lines changed

12 files changed

+143
-140
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.e5f2217d.js",
4+
"main.js": "/static/js/main.139d8094.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.e5f2217d.js.map": "/static/js/main.e5f2217d.js.map"
39+
"main.139d8094.js.map": "/static/js/main.139d8094.js.map"
4040
},
4141
"entrypoints": [
4242
"static/css/main.02152627.css",
43-
"static/js/main.e5f2217d.js"
43+
"static/js/main.139d8094.js"
4444
]
4545
}

config.dev.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ initial_alt_media_fraction=0.0
3434
[stirring.config]
3535
# test
3636
# ocmment
37-
target_rpm=500
37+
initial_target_rpm=500
3838
initial_duty_cycle=15
3939
pwm_hz=200
4040
use_rpm=True

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.e5f2217d.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.139d8094.js"></script><link href="/static/css/main.02152627.css" rel="stylesheet"></head><body><div id="root"></div></body></html>

pioreactorui/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ def query_app_db(
223223
cur = _get_app_db_connection().execute(query, args)
224224
rv = cur.fetchall()
225225
cur.close()
226-
return (rv[0] if rv else None) if one else rv
226+
if one:
227+
return rv[0] if rv else None # only when explicitly requested
228+
return rv
227229

228230

229231
def query_temp_local_metadata_db(

pioreactorui/api.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ def get_all_calibrations_as_yamls(pioreactor_unit: str) -> ResponseReturnValue:
10381038

10391039

10401040
@api.route("/workers/<pioreactor_unit>/calibrations/<device>", methods=["GET"])
1041-
def get_calibrations(pioreactor_unit, device) -> ResponseReturnValue:
1041+
def get_calibrations(pioreactor_unit: str, device: str) -> ResponseReturnValue:
10421042
if pioreactor_unit == UNIVERSAL_IDENTIFIER:
10431043
task = broadcast_get_across_cluster(f"/unit_api/calibrations/{device}")
10441044
else:
@@ -1049,7 +1049,7 @@ def get_calibrations(pioreactor_unit, device) -> ResponseReturnValue:
10491049

10501050

10511051
@api.route("/workers/<pioreactor_unit>/calibrations/<device>/<cal_name>", methods=["GET"])
1052-
def get_calibration(pioreactor_unit, device, cal_name) -> ResponseReturnValue:
1052+
def get_calibration(pioreactor_unit: str, device: str, cal_name: str) -> ResponseReturnValue:
10531053
if pioreactor_unit == UNIVERSAL_IDENTIFIER:
10541054
task = broadcast_get_across_cluster(f"/unit_api/calibrations/{device}/{cal_name}")
10551055
else:
@@ -1060,7 +1060,7 @@ def get_calibration(pioreactor_unit, device, cal_name) -> ResponseReturnValue:
10601060

10611061

10621062
@api.route("/workers/<pioreactor_unit>/calibrations/<device>", methods=["POST"])
1063-
def create_calibration(pioreactor_unit, device) -> ResponseReturnValue:
1063+
def create_calibration(pioreactor_unit: str, device: str) -> ResponseReturnValue:
10641064
yaml_data = request.get_json()["calibration_data"]
10651065

10661066
if not yaml_data:
@@ -1792,7 +1792,7 @@ def get_configs() -> ResponseReturnValue:
17921792
def strip_worker_name_from_config(file_name):
17931793
return file_name.removeprefix("config_").removesuffix(".ini")
17941794

1795-
def allow_file_through(file_name):
1795+
def allow_file_through(file_name: str):
17961796
if file_name == "config.ini":
17971797
return True
17981798
else:
@@ -2049,9 +2049,9 @@ def get_experiment_profiles() -> ResponseReturnValue:
20492049
if file.stat().st_size == 0:
20502050
parsed_yaml.append(
20512051
{
2052-
"experimentProfile": {
2053-
"experiment_profile_name": f"temporary name: {file.stem}"
2054-
},
2052+
"experimentProfile": Profile(
2053+
experiment_profile_name=f"temporary name: {file.stem}"
2054+
),
20552055
"file": Path(file).name,
20562056
"fullpath": Path(file).as_posix(),
20572057
}
@@ -2220,7 +2220,7 @@ def delete_worker(pioreactor_unit: str) -> ResponseReturnValue:
22202220
@api.route("/workers/<pioreactor_unit>/is_active", methods=["PUT"])
22212221
def change_worker_status(pioreactor_unit: str) -> ResponseReturnValue:
22222222
# Get the new status from the request body
2223-
data = request.json
2223+
data = request.get_json()
22242224
new_status = data.get("is_active")
22252225

22262226
if new_status not in [0, 1]:
@@ -2248,7 +2248,7 @@ def change_worker_status(pioreactor_unit: str) -> ResponseReturnValue:
22482248
@api.route("/workers/<pioreactor_unit>/model", methods=["PUT"])
22492249
def change_worker_model(pioreactor_unit: str) -> ResponseReturnValue:
22502250
# Get the new status from the request body
2251-
data = request.json
2251+
data = request.get_json()
22522252
model_version, model_name = data.get("model_version"), data.get("model_name")
22532253

22542254
if not model_version or not model_name:
@@ -2410,7 +2410,7 @@ def get_list_of_historical_workers_for_experiment(experiment: str) -> ResponseRe
24102410
@api.route("/experiments/<experiment>/workers", methods=["PUT"])
24112411
def add_worker_to_experiment(experiment: str) -> ResponseReturnValue:
24122412
# assign
2413-
data = request.json
2413+
data = request.get_json()
24142414
pioreactor_unit = data.get("pioreactor_unit")
24152415
if not pioreactor_unit:
24162416
return jsonify({"error": "Missing pioreactor_unit"}), 400

pioreactorui/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def is_testing_env():
2121
Path("/tmp") / "pioreactor_cache"
2222
) # sucks that is hardcoded - I don't have a config for this location.
2323

24-
env = dotenv_values(".env", verbose=True)
24+
env: dict[str, str] = dotenv_values(".env", verbose=True)
2525

2626
try:
2727
huey = SqliteHuey(filename=CACHE_DIR / "huey.db")

pioreactorui/tasks.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
PIO_EXECUTABLE = "/usr/local/bin/pio"
4848
PIOS_EXECUTABLE = "/usr/local/bin/pios"
4949
else:
50-
PIO_EXECUTABLE = env.get("PIO_EXECUTABLE")
51-
PIOS_EXECUTABLE = env.get("PIOS_EXECUTABLE")
50+
PIO_EXECUTABLE = env["PIO_EXECUTABLE"]
51+
PIOS_EXECUTABLE = env["PIOS_EXECUTABLE"]
5252

5353
ALLOWED_ENV = (
5454
"EXPERIMENT",
@@ -360,7 +360,7 @@ def post_to_worker(
360360
return worker, None
361361
except DecodeError:
362362
logger.error(
363-
f"Could not decode response from {worker}'s {endpoint=}, sent {json=} and returned {r.body}."
363+
f"Could not decode response from {worker}'s {endpoint=}, sent {json=} and returned {r.body.decode()}."
364364
)
365365
return worker, None
366366

@@ -412,7 +412,7 @@ def get_from_worker(
412412
return worker, None
413413
except DecodeError:
414414
logger.error(
415-
f"Could not decode response from {worker}'s {endpoint=}, sent {json=} and returned {r.body}."
415+
f"Could not decode response from {worker}'s {endpoint=}, sent {json=} and returned {r.body.decode()}."
416416
)
417417
return worker, None
418418

@@ -457,7 +457,7 @@ def patch_to_worker(worker: str, endpoint: str, json: dict | None = None) -> tup
457457
return worker, None
458458
except DecodeError:
459459
logger.error(
460-
f"Could not decode response from {worker}'s {endpoint=}, sent {json=} and returned {r.body}."
460+
f"Could not decode response from {worker}'s {endpoint=}, sent {json=} and returned {r.body.decode()}."
461461
)
462462
return worker, None
463463

@@ -489,7 +489,7 @@ def delete_from_worker(worker: str, endpoint: str, json: dict | None = None) ->
489489
return worker, None
490490
except DecodeError:
491491
logger.error(
492-
f"Could not decode response from {worker}'s {endpoint=}, sent {json=} and returned {r.body}."
492+
f"Could not decode response from {worker}'s {endpoint=}, sent {json=} and returned {r.body.decode()}."
493493
)
494494
return worker, None
495495

pioreactorui/unit_api.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
# Endpoint to check the status of a background task. unit_api is required to ping workers (who only expose unit_api)
5252
@unit_api.route("/task_results/<task_id>", methods=["GET"])
53-
def task_status(task_id):
53+
def task_status(task_id: str):
5454
try:
5555
task = huey.result(task_id)
5656
except TaskLockedException:
@@ -80,7 +80,7 @@ def task_status(task_id):
8080

8181

8282
@unit_api.route("/system/update/<target>", methods=["POST", "PATCH"])
83-
def update_target(target) -> ResponseReturnValue:
83+
def update_target(target: str) -> ResponseReturnValue:
8484
if target not in ("app", "ui"): # todo: firmware
8585
abort(404, "Invalid target")
8686

@@ -378,7 +378,7 @@ def get_all_running_jobs() -> ResponseReturnValue:
378378

379379

380380
@unit_api.route("/jobs/running/<job>", methods=["GET"])
381-
def get_running_job(job) -> ResponseReturnValue:
381+
def get_running_job(job: str) -> ResponseReturnValue:
382382
jobs = query_temp_local_metadata_db(
383383
"SELECT * FROM pio_job_metadata where is_running=1 and job_name=?", (job,)
384384
)
@@ -398,7 +398,7 @@ def get_all_long_running_jobs() -> ResponseReturnValue:
398398

399399

400400
@unit_api.route("/jobs/settings/job_name/<job_name>", methods=["GET"])
401-
def get_settings_for_a_specific_job(job_name) -> ResponseReturnValue:
401+
def get_settings_for_a_specific_job(job_name: str) -> ResponseReturnValue:
402402
"""
403403
{
404404
"settings": {
@@ -425,8 +425,8 @@ def get_settings_for_a_specific_job(job_name) -> ResponseReturnValue:
425425

426426

427427
@unit_api.route("/jobs/settings/job_name/<job_name>/setting/<setting>", methods=["GET"])
428-
def get_specific_setting_for_a_job(job_name, setting) -> ResponseReturnValue:
429-
setting = query_temp_local_metadata_db(
428+
def get_specific_setting_for_a_job(job_name: str, setting: str) -> ResponseReturnValue:
429+
setting_metadata = query_temp_local_metadata_db(
430430
"""
431431
SELECT s.setting, s.value FROM
432432
pio_job_published_settings s
@@ -437,8 +437,9 @@ def get_specific_setting_for_a_job(job_name, setting) -> ResponseReturnValue:
437437
(job_name, setting),
438438
one=True,
439439
)
440-
if setting:
441-
return jsonify({setting["setting"]: setting["value"]})
440+
assert isinstance(setting_metadata, dict)
441+
if setting_metadata:
442+
return jsonify({setting_metadata["setting"]: setting_metadata["value"]})
442443
else:
443444
return {"status": "error"}, 404
444445

@@ -597,7 +598,7 @@ def get_ui_version() -> ResponseReturnValue:
597598

598599

599600
@unit_api.route("/calibrations/<device>", methods=["POST"])
600-
def create_calibration(device) -> ResponseReturnValue:
601+
def create_calibration(device: str) -> ResponseReturnValue:
601602
"""
602603
Create a new calibration for the specified device.
603604
"""
@@ -744,7 +745,7 @@ def get_all_calibrations_as_zipped_yaml() -> ResponseReturnValue:
744745

745746

746747
@unit_api.route("/calibrations/<device>", methods=["GET"])
747-
def get_calibrations_by_device(device) -> ResponseReturnValue:
748+
def get_calibrations_by_device(device: str) -> ResponseReturnValue:
748749
calibration_dir = Path(env["DOT_PIOREACTOR"]) / "storage" / "calibrations" / device
749750

750751
if not calibration_dir.exists():
@@ -768,7 +769,7 @@ def get_calibrations_by_device(device) -> ResponseReturnValue:
768769

769770

770771
@unit_api.route("/calibrations/<device>/<cal_name>", methods=["GET"])
771-
def get_calibration(device, cal_name) -> ResponseReturnValue:
772+
def get_calibration(device: str, cal_name: str) -> ResponseReturnValue:
772773
calibration_path = (
773774
Path(env["DOT_PIOREACTOR"]) / "storage" / "calibrations" / device / f"{cal_name}.yaml"
774775
)
@@ -787,15 +788,15 @@ def get_calibration(device, cal_name) -> ResponseReturnValue:
787788

788789

789790
@unit_api.route("/active_calibrations/<device>/<cal_name>", methods=["PATCH"])
790-
def set_active_calibration(device, cal_name) -> ResponseReturnValue:
791+
def set_active_calibration(device: str, cal_name: str) -> ResponseReturnValue:
791792
with local_persistent_storage("active_calibrations") as c:
792793
c[device] = cal_name
793794

794795
return {"status": "success"}, 200
795796

796797

797798
@unit_api.route("/active_calibrations/<device>", methods=["DELETE"])
798-
def remove_active_status_calibration(device) -> ResponseReturnValue:
799+
def remove_active_status_calibration(device: str) -> ResponseReturnValue:
799800
with local_persistent_storage("active_calibrations") as c:
800801
if device in c:
801802
c.pop(device)

static/js/main.139d8094.js

Lines changed: 103 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)