Skip to content

Commit

Permalink
new multi profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Jan 29, 2025
1 parent 5b4e5b4 commit 5439897
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 15 deletions.
6 changes: 3 additions & 3 deletions asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files": {
"main.css": "/static/css/main.02152627.css",
"main.js": "/static/js/main.c1b772c6.js",
"main.js": "/static/js/main.e18b8229.js",
"static/media/roboto-all-500-normal.woff": "/static/media/roboto-all-500-normal.0ab669b7a0d19b178f57.woff",
"static/media/roboto-all-700-normal.woff": "/static/media/roboto-all-700-normal.a457fde362a540fcadff.woff",
"static/media/roboto-all-400-normal.woff": "/static/media/roboto-all-400-normal.c5d001fa922fa66a147f.woff",
Expand Down Expand Up @@ -36,10 +36,10 @@
"static/media/roboto-greek-ext-700-normal.woff2": "/static/media/roboto-greek-ext-700-normal.bd9854c751441ccc1a70.woff2",
"index.html": "/index.html",
"main.02152627.css.map": "/static/css/main.02152627.css.map",
"main.c1b772c6.js.map": "/static/js/main.c1b772c6.js.map"
"main.e18b8229.js.map": "/static/js/main.e18b8229.js.map"
},
"entrypoints": [
"static/css/main.02152627.css",
"static/js/main.c1b772c6.js"
"static/js/main.e18b8229.js"
]
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -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.c1b772c6.js"></script><link href="/static/css/main.02152627.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
<!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.e18b8229.js"></script><link href="/static/css/main.02152627.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
1 change: 1 addition & 0 deletions pioreactorui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def query_temp_local_metadata_db(
cur = _get_temp_local_metadata_db_connection().execute(query, args)
rv = cur.fetchall()
cur.close()
print(rv)
return (rv[0] if rv else None) if one else rv


Expand Down
43 changes: 37 additions & 6 deletions pioreactorui/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from . import publish_to_experiment_log
from . import publish_to_log
from . import query_app_db
from . import query_temp_local_metadata_db
from . import structs
from . import tasks
from .config import env
Expand All @@ -59,7 +60,7 @@
api = Blueprint("api", __name__, url_prefix="/api")


def to_json_response(json: str) -> ResponseReturnValue:
def as_json_response(json: str) -> ResponseReturnValue:
return Response(json, mimetype="application/json")


Expand Down Expand Up @@ -538,7 +539,7 @@ def get_growth_rates(experiment: str) -> ResponseReturnValue:
abort(400)

assert isinstance(growth_rates, dict)
return attach_cache_control(to_json_response(growth_rates["json"]))
return attach_cache_control(as_json_response(growth_rates["json"]))


@api.route("/experiments/<experiment>/time_series/temperature_readings", methods=["GET"])
Expand Down Expand Up @@ -572,7 +573,7 @@ def get_temperature_readings(experiment: str) -> ResponseReturnValue:
abort(400)

assert isinstance(temperature_readings, dict)
return attach_cache_control(to_json_response(temperature_readings["json"]))
return attach_cache_control(as_json_response(temperature_readings["json"]))


@api.route("/experiments/<experiment>/time_series/od_readings_filtered", methods=["GET"])
Expand Down Expand Up @@ -607,7 +608,7 @@ def get_od_readings_filtered(experiment: str) -> ResponseReturnValue:
abort(400)

assert isinstance(filtered_od_readings, dict)
return attach_cache_control(to_json_response(filtered_od_readings["json"]))
return attach_cache_control(as_json_response(filtered_od_readings["json"]))


@api.route("/experiments/<experiment>/time_series/od_readings", methods=["GET"])
Expand Down Expand Up @@ -640,7 +641,7 @@ def get_od_readings(experiment: str) -> ResponseReturnValue:
abort(400)

assert isinstance(raw_od_readings, dict)
return attach_cache_control(to_json_response(raw_od_readings["json"]))
return attach_cache_control(as_json_response(raw_od_readings["json"]))


@api.route("/experiments/<experiment>/time_series/<data_source>/<column>", methods=["GET"])
Expand Down Expand Up @@ -674,7 +675,7 @@ def get_fallback_time_series(data_source: str, experiment: str, column: str) ->
publish_to_error_log(str(e), "get_fallback_time_series")
abort(400)
assert isinstance(r, dict)
return attach_cache_control(to_json_response(r["json"]))
return attach_cache_control(as_json_response(r["json"]))


@api.route("/experiments/<experiment>/media_rates", methods=["GET"])
Expand Down Expand Up @@ -1641,6 +1642,36 @@ def is_local_access_point_active() -> ResponseReturnValue:
### experiment profiles


@api.route("/experiment_profiles/running/experiments/<experiment>", methods=["GET"])
def get_running_profiles(experiment: str) -> ResponseReturnValue:
jobs = query_temp_local_metadata_db(
"""
SELECT
json_group_array(json_object(
'job_name', m.job_name,
'experiment', m.experiment,
'job_id', m.id,
'settings', (
SELECT json_group_object(s.setting, s.value)
FROM pio_job_published_settings s
WHERE s.job_id = m.id
)
)) as result
FROM
pio_job_metadata m
WHERE
m.is_running=1 and
m.experiment = (?) AND
m.job_name="experiment_profile"
""",
(experiment,),
one=True,
)
assert isinstance(jobs, dict)

return as_json_response(jobs["result"])


@api.route("/contrib/experiment_profiles", methods=["POST"])
def create_experiment_profile() -> ResponseReturnValue:
body = request.get_json()
Expand Down
6 changes: 6 additions & 0 deletions pioreactorui/unit_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ def stop_all_jobs_by_source(job_source: str) -> ResponseReturnValue:
return create_task_response(task)


@unit_api.route("/jobs/stop/job_id/<job_id>", methods=["PATCH", "POST"])
def stop_all_jobs_by_id(job_id: int) -> ResponseReturnValue:
task = tasks.pio_kill("--job-id", job_id)
return create_task_response(task)


@unit_api.route("/jobs/running/experiments/<experiment>", methods=["GET"])
def get_running_jobs_for_experiment(experiment: str) -> ResponseReturnValue:
jobs = query_temp_local_metadata_db(
Expand Down
1 change: 0 additions & 1 deletion static/js/main.c1b772c6.js.map

This file was deleted.

8 changes: 4 additions & 4 deletions static/js/main.c1b772c6.js → static/js/main.e18b8229.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions static/js/main.e18b8229.js.map

Large diffs are not rendered by default.

0 comments on commit 5439897

Please sign in to comment.