Skip to content

Commit 716247d

Browse files
tests for OD calibrations; changing /unit_api/jobs/stop
1 parent 599ee3f commit 716247d

File tree

9 files changed

+56
-24
lines changed

9 files changed

+56
-24
lines changed

asset-manifest.json

Lines changed: 4 additions & 4 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.f7cdb1ed.js",
4+
"main.js": "/static/js/main.ad988b9d.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.f7cdb1ed.js.map": "/static/js/main.f7cdb1ed.js.map"
39+
"main.ad988b9d.js.map": "/static/js/main.ad988b9d.js.map"
4040
},
4141
"entrypoints": [
4242
"static/css/main.02152627.css",
43-
"static/js/main.f7cdb1ed.js"
43+
"static/js/main.ad988b9d.js"
4444
]
45-
}
45+
}

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

pioreactorui/api.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def stop_all_jobs_in_experiment(experiment: str) -> ResponseReturnValue:
9191
"""Kills all jobs for workers assigned to experiment"""
9292
workers_in_experiment = get_all_workers_in_experiment(experiment)
9393
tasks.multicast_post_across_cluster(
94-
f"/unit_api/jobs/stop/experiment/{experiment}", workers_in_experiment
94+
f"/unit_api/jobs/stop", workers_in_experiment, params={'experiment': experiment}
9595
)
9696

9797
# sometimes the leader isn't part of the experiment, but a profile associated with the experiment is running:
@@ -109,10 +109,10 @@ def stop_all_jobs_on_worker_for_experiment(
109109
) -> ResponseReturnValue:
110110
"""Kills all jobs for worker assigned to experiment"""
111111
if pioreactor_unit == UNIVERSAL_IDENTIFIER:
112-
broadcast_post_across_cluster(f"/unit_api/jobs/stop/experiment/{experiment}")
112+
broadcast_post_across_cluster(f"/unit_api/jobs/stop", params={'experiment': experiment})
113113
else:
114114
tasks.multicast_post_across_cluster(
115-
f"/unit_api/jobs/stop/experiment/{experiment}", [pioreactor_unit]
115+
f"/unit_api/jobs/stop", [pioreactor_unit], params={'experiment': experiment}
116116
)
117117

118118
return Response(status=202)
@@ -123,21 +123,21 @@ def stop_all_jobs_on_worker_for_experiment(
123123
methods=["PATCH", "POST"],
124124
)
125125
@api.route(
126-
"/units/<pioreactor_unit>/jobs/stop/job_name/<job>/experiments/<experiment>",
126+
"/units/<pioreactor_unit>/jobs/stop/job_name/<job_name>/experiments/<experiment>",
127127
methods=["PATCH", "POST"],
128128
)
129-
def stop_job_on_unit(pioreactor_unit: str, experiment: str, job: str) -> ResponseReturnValue:
129+
def stop_job_on_unit(pioreactor_unit: str, experiment: str, job_name: str) -> ResponseReturnValue:
130130
"""Kills specified job on unit"""
131131

132132
msg = client.publish(
133-
f"pioreactor/{pioreactor_unit}/{experiment}/{job}/$state/set", b"disconnected", qos=1
133+
f"pioreactor/{pioreactor_unit}/{experiment}/{job_name}/$state/set", b"disconnected", qos=1
134134
)
135135
try:
136136
msg.wait_for_publish(timeout=2.0)
137137
except Exception:
138138
# TODO: make this $broadcastable
139139
tasks.multicast_post_across_cluster(
140-
f"/unit_api/jobs/stop/job_name/{job}", [pioreactor_unit]
140+
f"/unit_api/jobs/stop", [pioreactor_unit], params={'job_name': job_name}
141141
)
142142
abort(500)
143143

@@ -1261,7 +1261,7 @@ def create_experiment() -> ResponseReturnValue:
12611261
@api.route("/experiments/<experiment>", methods=["DELETE"])
12621262
def delete_experiment(experiment: str) -> ResponseReturnValue:
12631263
row_count = modify_app_db("DELETE FROM experiments WHERE experiment=?;", (experiment,))
1264-
broadcast_post_across_cluster(f"/unit_api/jobs/stop/experiment/{experiment}")
1264+
broadcast_post_across_cluster(f"/unit_api/jobs/stop", params={"experiment": experiment})
12651265

12661266
if row_count > 0:
12671267
return Response(status=200)
@@ -2089,7 +2089,7 @@ def remove_worker_from_experiment(experiment: str, pioreactor_unit: str) -> Resp
20892089
)
20902090
if row_count > 0:
20912091
tasks.multicast_post_across_cluster(
2092-
f"/unit_api/jobs/stop/experiment/{experiment}", [pioreactor_unit]
2092+
f"/unit_api/jobs/stop", [pioreactor_unit], params={'experiment': experiment}
20932093
)
20942094
publish_to_experiment_log(
20952095
f"Removed {pioreactor_unit} from {experiment}.",
@@ -2109,7 +2109,7 @@ def remove_workers_from_experiment(experiment: str) -> ResponseReturnValue:
21092109
"DELETE FROM experiment_worker_assignments WHERE experiment = ?",
21102110
(experiment,),
21112111
)
2112-
task = broadcast_post_across_cluster(f"/unit_api/jobs/stop/experiment/{experiment}")
2112+
task = broadcast_post_across_cluster(f"/unit_api/jobs/stop", params={'experiment': experiment})
21132113
publish_to_experiment_log(
21142114
f"Removed all workers from {experiment}.",
21152115
experiment=experiment,

pioreactorui/unit_api.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,26 +288,59 @@ def stop_all_jobs() -> ResponseReturnValue:
288288
return create_task_response(task)
289289

290290

291+
@unit_api.route("/jobs/stop", methods=["PATCH", "POST"])
292+
def stop_jobs() -> ResponseReturnValue:
293+
job_name = request.args.get("job_name")
294+
experiment = request.args.get("experiment")
295+
job_source = request.args.get("job_source")
296+
job_id = request.args.get("job_id") # note job_id is typically an int, so you might convert it.
297+
298+
# If you need at least one query param:
299+
if not any([job_name, experiment, job_source, job_id]):
300+
return abort(400, "No job filter specified")
301+
302+
kill_args = []
303+
if job_name:
304+
kill_args.extend(["--job-name", job_name])
305+
if experiment:
306+
kill_args.extend(["--experiment", experiment])
307+
if job_source:
308+
kill_args.extend(["--job-source", job_source])
309+
if job_id:
310+
kill_args.extend(["--job-id", job_id])
311+
312+
task = tasks.pio_kill(*kill_args)
313+
return create_task_response(task)
314+
315+
316+
291317
@unit_api.route("/jobs/stop/job_name/<job_name>", methods=["PATCH", "POST"])
292318
def stop_job_by_name(job_name: str) -> ResponseReturnValue:
319+
# deprecated
293320
task = tasks.pio_kill("--job-name", job_name)
294321
return create_task_response(task)
295322

296323

297324
@unit_api.route("/jobs/stop/experiment/<experiment>", methods=["PATCH", "POST"])
298325
def stop_all_jobs_by_experiment(experiment: str) -> ResponseReturnValue:
326+
# deprecated
327+
299328
task = tasks.pio_kill("--experiment", experiment)
300329
return create_task_response(task)
301330

302331

303332
@unit_api.route("/jobs/stop/job_source/<job_source>", methods=["PATCH", "POST"])
304333
def stop_all_jobs_by_source(job_source: str) -> ResponseReturnValue:
334+
# deprecated
335+
305336
task = tasks.pio_kill("--job-source", job_source)
306337
return create_task_response(task)
307338

308339

309340
@unit_api.route("/jobs/stop/job_id/<job_id>", methods=["PATCH", "POST"])
310341
def stop_all_jobs_by_id(job_id: int) -> ResponseReturnValue:
342+
# deprecated
343+
311344
task = tasks.pio_kill("--job-id", job_id)
312345
return create_task_response(task)
313346

@@ -396,8 +429,7 @@ def get_specific_setting_for_a_job(job_name, setting) -> ResponseReturnValue:
396429

397430

398431
@unit_api.route("/jobs/settings/job_name/<job_name>", methods=["PATCH"])
399-
def update_job(job: str) -> ResponseReturnValue:
400-
# DONT USE YET
432+
def update_job(job_name: str) -> ResponseReturnValue:
401433
"""
402434
The body should look like:
403435

0 commit comments

Comments
 (0)