Skip to content

Commit 320d30a

Browse files
api end point names
1 parent b0e2f4c commit 320d30a

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

core/pioreactor/web/api.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ def shutdown_unit(pioreactor_unit: str) -> DelayedResponseReturnValue:
458458

459459

460460
@api_bp.route("/units/<pioreactor_unit>/system/utc_clock", methods=["GET"])
461-
def get_clocktime(pioreactor_unit: str) -> DelayedResponseReturnValue:
461+
def get_unit_utc_clock(pioreactor_unit: str) -> DelayedResponseReturnValue:
462462
if pioreactor_unit == UNIVERSAL_IDENTIFIER:
463463
task = broadcast_get_across_cluster("/unit_api/system/utc_clock")
464464
else:
@@ -467,7 +467,7 @@ def get_clocktime(pioreactor_unit: str) -> DelayedResponseReturnValue:
467467

468468

469469
@api_bp.route("/system/utc_clock", methods=["POST"])
470-
def set_clocktime() -> DelayedResponseReturnValue:
470+
def set_system_utc_clock() -> DelayedResponseReturnValue:
471471
# first update the leader:
472472
task1 = tasks.multicast_post(
473473
"/unit_api/system/utc_clock", [get_leader_hostname()], json=request.get_json()
@@ -1451,7 +1451,7 @@ def get_all_estimators(pioreactor_unit: str) -> DelayedResponseReturnValue:
14511451

14521452

14531453
@api_bp.route("/workers/<pioreactor_unit>/zipped_calibrations", methods=["GET"])
1454-
def get_all_calibrations_as_yamls(pioreactor_unit: str) -> ResponseReturnValue:
1454+
def get_zipped_calibrations(pioreactor_unit: str) -> ResponseReturnValue:
14551455
if pioreactor_unit == UNIVERSAL_IDENTIFIER:
14561456
task = broadcast_get_across_workers("/unit_api/zipped_calibrations", return_raw=True)
14571457
else:
@@ -1501,7 +1501,7 @@ def get_all_calibrations_as_yamls(pioreactor_unit: str) -> ResponseReturnValue:
15011501

15021502

15031503
@api_bp.route("/units/<pioreactor_unit>/zipped_dot_pioreactor", methods=["GET"])
1504-
def get_entire_dot_pioreactor(pioreactor_unit: str) -> ResponseReturnValue:
1504+
def get_zipped_dot_pioreactor(pioreactor_unit: str) -> ResponseReturnValue:
15051505
"""Download a ZIP of ~/.pioreactor from one or all workers.
15061506
15071507
- For a specific worker, fetch raw bytes from its unit_api and proxy as a download.
@@ -2038,7 +2038,7 @@ def get_app_versions(pioreactor_unit: str) -> DelayedResponseReturnValue:
20382038

20392039

20402040
@api_bp.route("/system/upload", methods=["POST"])
2041-
def upload() -> ResponseReturnValue:
2041+
def upload_system_file() -> ResponseReturnValue:
20422042
if (Path(os.environ["DOT_PIOREACTOR"]) / "DISALLOW_UI_UPLOADS").is_file():
20432043
abort_with(403, "No UI uploads allowed")
20442044

@@ -2076,7 +2076,7 @@ def upload() -> ResponseReturnValue:
20762076

20772077

20782078
@api_bp.route("/automations/descriptors/<automation_type>", methods=["GET"])
2079-
def get_automation_contrib(automation_type: str) -> ResponseReturnValue:
2079+
def get_automation_descriptors(automation_type: str) -> ResponseReturnValue:
20802080
# security to prevent possibly reading arbitrary file
20812081
if automation_type not in {"temperature", "dosing", "led"}:
20822082
abort_with(
@@ -2099,17 +2099,17 @@ def get_automation_contrib(automation_type: str) -> ResponseReturnValue:
20992099
decoded_yaml = yaml_decode(file.read_bytes(), type=structs.AutomationDescriptor)
21002100
parsed_yaml[decoded_yaml.automation_name] = decoded_yaml
21012101
except (ValidationError, DecodeError) as e:
2102-
publish_to_error_log(f"Yaml error in {Path(file).name}: {e}", "get_automation_contrib")
2102+
publish_to_error_log(f"Yaml error in {Path(file).name}: {e}", "get_automation_descriptors")
21032103

21042104
return attach_cache_control(jsonify(list(parsed_yaml.values())))
21052105

21062106
except Exception as e:
2107-
publish_to_error_log(str(e), "get_automation_contrib")
2107+
publish_to_error_log(str(e), "get_automation_descriptors")
21082108
abort_with(400, str(e))
21092109

21102110

21112111
@api_bp.route("/jobs/descriptors", methods=["GET"])
2112-
def get_job_contrib() -> ResponseReturnValue:
2112+
def get_job_descriptors() -> ResponseReturnValue:
21132113
try:
21142114
job_path_builtins = Path(os.environ["DOT_PIOREACTOR"]) / "ui" / "jobs"
21152115
job_path_plugins = Path(os.environ["DOT_PIOREACTOR"]) / "plugins" / "ui" / "jobs"
@@ -2123,17 +2123,17 @@ def get_job_contrib() -> ResponseReturnValue:
21232123
decoded_yaml = yaml_decode(file.read_bytes(), type=structs.BackgroundJobDescriptor)
21242124
parsed_yaml[decoded_yaml.job_name] = decoded_yaml
21252125
except (ValidationError, DecodeError) as e:
2126-
publish_to_error_log(f"Yaml error in {Path(file).name}: {e}", "get_job_contrib")
2126+
publish_to_error_log(f"Yaml error in {Path(file).name}: {e}", "get_job_descriptors")
21272127

21282128
return attach_cache_control(jsonify(list(parsed_yaml.values())))
21292129

21302130
except Exception as e:
2131-
publish_to_error_log(str(e), "get_job_contrib")
2131+
publish_to_error_log(str(e), "get_job_descriptors")
21322132
abort_with(400, str(e))
21332133

21342134

21352135
@api_bp.route("/charts/descriptors", methods=["GET"])
2136-
def get_charts_contrib() -> ResponseReturnValue:
2136+
def get_chart_descriptors() -> ResponseReturnValue:
21372137
try:
21382138
chart_path_builtins = Path(os.environ["DOT_PIOREACTOR"]) / "ui" / "charts"
21392139
chart_path_plugins = Path(os.environ["DOT_PIOREACTOR"]) / "plugins" / "ui" / "charts"
@@ -2146,12 +2146,12 @@ def get_charts_contrib() -> ResponseReturnValue:
21462146
decoded_yaml = yaml_decode(file.read_bytes(), type=structs.ChartDescriptor)
21472147
parsed_yaml[decoded_yaml.chart_key] = decoded_yaml
21482148
except (ValidationError, DecodeError) as e:
2149-
publish_to_error_log(f"Yaml error in {Path(file).name}: {e}", "get_charts_contrib")
2149+
publish_to_error_log(f"Yaml error in {Path(file).name}: {e}", "get_chart_descriptors")
21502150

21512151
return attach_cache_control(jsonify(list(parsed_yaml.values())))
21522152

21532153
except Exception as e:
2154-
publish_to_error_log(str(e), "get_charts_contrib")
2154+
publish_to_error_log(str(e), "get_chart_descriptors")
21552155
abort_with(400, str(e))
21562156

21572157

@@ -2193,7 +2193,7 @@ def get_exportable_datasets() -> ResponseReturnValue:
21932193

21942194

21952195
@api_bp.route("/datasets/exportable/<target_dataset>/preview", methods=["GET"])
2196-
def preview_exportable_datasets(target_dataset) -> ResponseReturnValue:
2196+
def preview_exportable_dataset(target_dataset: str) -> ResponseReturnValue:
21972197
builtins = sorted((Path(os.environ["DOT_PIOREACTOR"]) / "exportable_datasets").glob("*.y*ml"))
21982198
plugins = sorted((Path(os.environ["DOT_PIOREACTOR"]) / "plugins" / "exportable_datasets").glob("*.y*ml"))
21992199

@@ -2217,7 +2217,7 @@ def preview_exportable_datasets(target_dataset) -> ResponseReturnValue:
22172217

22182218

22192219
@api_bp.route("/datasets/exportable/export", methods=["POST"])
2220-
def export_datasets() -> ResponseReturnValue:
2220+
def export_exportable_datasets() -> ResponseReturnValue:
22212221
body = request.get_json()
22222222

22232223
dataset_names: list[str] = body["datasets"]
@@ -2718,7 +2718,7 @@ def update_config_file(filename: str) -> ResponseReturnValue:
27182718

27192719

27202720
@api_bp.route("/config/files/<filename>/history", methods=["GET"])
2721-
def get_historical_config_for(filename: str) -> ResponseReturnValue:
2721+
def get_config_file_history(filename: str) -> ResponseReturnValue:
27222722
configs_for_filename = query_app_db(
27232723
"SELECT filename, timestamp, data FROM config_files_histories WHERE filename=? ORDER BY timestamp DESC",
27242724
(filename,),

core/pioreactor/web/unit_api.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def check_hardware_for_model() -> DelayedResponseReturnValue:
102102

103103
# Endpoint to check the status of a background task. unit_api is required to ping workers (who only expose unit_api)
104104
@unit_api_bp.route("/task_results/<task_id>", methods=["GET"])
105-
def task_status(task_id: str):
105+
def get_task_status(task_id: str):
106106
blob = {"task_id": task_id, "result_url_path": "/unit_api/task_results/" + task_id}
107107
try:
108108
task = huey.result(task_id)
@@ -214,7 +214,7 @@ def _locked_task_response(lock_name: str) -> ResponseReturnValue:
214214

215215

216216
@unit_api_bp.route("/system/update/<target>", methods=["POST", "PATCH"])
217-
def update_target(target: str) -> DelayedResponseReturnValue:
217+
def update_software_target(target: str) -> DelayedResponseReturnValue:
218218
if _task_is_locked("update-lock"):
219219
return _locked_task_response("update-lock")
220220

@@ -239,7 +239,7 @@ def update_target(target: str) -> DelayedResponseReturnValue:
239239

240240

241241
@unit_api_bp.route("/system/update", methods=["POST", "PATCH"])
242-
def update() -> DelayedResponseReturnValue:
242+
def update_software() -> DelayedResponseReturnValue:
243243
if _task_is_locked("update-lock"):
244244
return _locked_task_response("update-lock")
245245

@@ -257,7 +257,7 @@ def update() -> DelayedResponseReturnValue:
257257

258258

259259
@unit_api_bp.route("/system/reboot", methods=["POST", "PATCH"])
260-
def reboot() -> DelayedResponseReturnValue:
260+
def reboot_system() -> DelayedResponseReturnValue:
261261
"""Reboots unit"""
262262
# TODO: only let requests from the leader do this. Use lighttpd conf for this.
263263
if _task_is_locked("power-lock"):
@@ -271,7 +271,7 @@ def reboot() -> DelayedResponseReturnValue:
271271

272272

273273
@unit_api_bp.route("/system/shutdown", methods=["POST", "PATCH"])
274-
def shutdown() -> DelayedResponseReturnValue:
274+
def shutdown_system() -> DelayedResponseReturnValue:
275275
"""Shutdown unit"""
276276
if _task_is_locked("power-lock"):
277277
return _locked_task_response("power-lock")
@@ -442,7 +442,7 @@ def set_clock_time() -> DelayedResponseReturnValue: # type: ignore[return]
442442
#### DIR
443443
@unit_api_bp.route("/system/path/", defaults={"req_path": ""})
444444
@unit_api_bp.route("/system/path/<path:req_path>")
445-
def dir_listing(req_path: str):
445+
def list_system_path(req_path: str):
446446
if os.path.isfile(Path(os.environ["DOT_PIOREACTOR"]) / "DISALLOW_UI_FILE_SYSTEM"):
447447
abort_with(
448448
403,
@@ -631,7 +631,7 @@ def get_all_long_running_jobs() -> ResponseReturnValue:
631631

632632

633633
@unit_api_bp.route("/jobs/settings/job_name/<job_name>", methods=["GET"])
634-
def get_settings_for_a_specific_job(job_name: str) -> ResponseReturnValue:
634+
def get_job_settings(job_name: str) -> ResponseReturnValue:
635635
"""
636636
{
637637
"settings": {
@@ -658,7 +658,7 @@ def get_settings_for_a_specific_job(job_name: str) -> ResponseReturnValue:
658658

659659

660660
@unit_api_bp.route("/jobs/settings/job_name/<job_name>/setting/<setting>", methods=["GET"])
661-
def get_specific_setting_for_a_job(job_name: str, setting: str) -> ResponseReturnValue:
661+
def get_job_setting(job_name: str, setting: str) -> ResponseReturnValue:
662662
setting_metadata = query_temp_local_metadata_db(
663663
"""
664664
SELECT s.setting, s.value FROM
@@ -694,7 +694,7 @@ def update_job(job_name: str) -> ResponseReturnValue:
694694

695695

696696
@unit_api_bp.route("/capabilities", methods=["GET"])
697-
def discover_jobs_and_settings_available() -> ResponseReturnValue:
697+
def get_capabilities() -> ResponseReturnValue:
698698
from pioreactor.utils.capabilities import collect_capabilities
699699

700700
return jsonify(collect_capabilities())
@@ -747,7 +747,7 @@ def get_installed_plugins() -> ResponseReturnValue:
747747

748748

749749
@unit_api_bp.route("/plugins/installed/<filename>", methods=["GET"])
750-
def get_plugin(filename: str) -> ResponseReturnValue:
750+
def get_installed_plugin(filename: str) -> ResponseReturnValue:
751751
"""get a specific Python file in the .pioreactor/plugin folder"""
752752
# security bit: strip out any paths that may be attached, ex: ../../../root/bad
753753
file = Path(filename).name
@@ -1088,7 +1088,7 @@ def get_all_estimators() -> ResponseReturnValue:
10881088

10891089

10901090
@unit_api_bp.route("/zipped_calibrations", methods=["GET"])
1091-
def get_all_calibrations_as_zipped_yaml() -> ResponseReturnValue:
1091+
def get_zipped_calibrations() -> ResponseReturnValue:
10921092
calibration_dir = CALIBRATION_PATH
10931093

10941094
if not calibration_dir.exists():
@@ -1120,7 +1120,7 @@ def get_all_calibrations_as_zipped_yaml() -> ResponseReturnValue:
11201120

11211121

11221122
@unit_api_bp.route("/zipped_dot_pioreactor", methods=["GET"])
1123-
def get_entire_dot_pioreactor_as_zip() -> ResponseReturnValue:
1123+
def get_zipped_dot_pioreactor() -> ResponseReturnValue:
11241124
"""Create and return a ZIP of the entire DOT_PIOREACTOR directory.
11251125
11261126
Notes:

0 commit comments

Comments
 (0)