Skip to content

Commit

Permalink
remove default field; adding more http methods for broadcast; calibra…
Browse files Browse the repository at this point in the history
…tion work
  • Loading branch information
CamDavidsonPilon committed Dec 18, 2024
1 parent 89fb947 commit 9d3d0a2
Show file tree
Hide file tree
Showing 13 changed files with 314 additions and 269 deletions.
1 change: 0 additions & 1 deletion contrib/jobs/00_stirring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ published_settings:
label: Target stir RPM
description: Modify the target RPM of stirring. This will effect the optical density reading. Too low and the stirring may completely stop. Too high and the resulting vortex may interfere with the optics.
type: numeric
default: null
display: true
4 changes: 1 addition & 3 deletions contrib/jobs/03_temperature_automation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ published_settings:
unit:
label: Target temperature
type: numeric
description: Change the target temperature. Lower bound is the ambient temperature, and upperbound is 50℃. Only used in when Thermostat automation is active.
default: null
description: Change the target temperature. Lower bound is the ambient temperature, and upper bound is 50℃. Only used in when Thermostat automation is active.
display: true
- key: automation_name
type: string
display: false
default: ""
5 changes: 0 additions & 5 deletions contrib/jobs/04_dosing_automation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,26 @@ published_settings:
unit: min
label: Time between dosing
type: numeric
default: null
display: true
description: Change how long to wait between dilutions. Typically between 0.5 and 60 minutes. Changing may immediately trigger a dosing event.
- key: volume
unit: mL
label: Volume / dosing
type: numeric
default: null
display: true
description: Change the volume per dilution. Typical values are between 0.0mL and 2.0mL.
- key: target_normalized_od
unit: AU
label: Target nOD
type: numeric
default: null
display: true
description: Change the target normalized optical density. Typical values are between 1.0 AU and 100.0 AU.
- key: target_od
unit: OD
label: Target OD
type: numeric
default: null
display: true
description: Change the target optical density. Only used if running "Turbidostat Targeting OD" automation.
- key: automation_name
type: string
display: false
default: ""
1 change: 0 additions & 1 deletion contrib/jobs/05_leds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ published_settings:
label: LED intensity
type: string
display: true
default: ""
1 change: 0 additions & 1 deletion contrib/jobs/06_led_automation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ published_settings:
- key: automation_name
type: string
display: false
default: ""
1 change: 0 additions & 1 deletion contrib/jobs/13_pwms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ published_settings:
label: PWM intensity
type: string
display: true
default: ""
2 changes: 0 additions & 2 deletions contrib/jobs/50_self_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ published_settings:
type: boolean
- key: correlations_between_pds_and_leds
display: false
default: '[]'
type: json
- key: test_positive_correlation_between_rpm_and_stirring
display: false
Expand All @@ -43,5 +42,4 @@ published_settings:
type: boolean
- key: all_tests_passed
display: false
default: false
type: boolean
4 changes: 1 addition & 3 deletions contrib/jobs/background_job.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ published_settings:
label: Stirring speed # human readable name
description: This description is displayed with an editable field in Manage / Settings.
type: numeric # one of numeric, boolean, text
default: null
display: true # true to display on the /Pioreactors card
- key: something_else
unit: lb
label: Something else
description: This description is displayed with an editable field in Manage / Settings.
type: numeric # one of numeric, boolean, text
default: null
display: true # true to display on the /Pioreactors card
display: true # true to display on the /Pioreactors card
14 changes: 8 additions & 6 deletions pioreactorui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,16 @@ def handle_server_error(e):
return app


def msg_to_JSON(msg: str, task: str, level: str) -> bytes:
def msg_to_JSON(msg: str, task: str, level: str, timestamp: None | str = None) -> bytes:
if timestamp is None:
timestamp = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")
return dumps(
{
"message": msg.strip(),
"task": task,
"source": "ui",
"level": level,
"timestamp": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
"timestamp": timestamp,
}
)

Expand Down Expand Up @@ -157,8 +159,8 @@ def _get_app_db_connection():
return db


def _get_local_metadata_db_connection():
db = getattr(g, "_metadata_database", None)
def _get_temp_local_metadata_db_connection():
db = getattr(g, "_local_metadata_database", None)
if db is None:
db = g._local_metadata_database = sqlite3.connect(
f"{tempfile.gettempdir()}/local_intermittent_pioreactor_metadata.sqlite"
Expand All @@ -177,10 +179,10 @@ def query_app_db(
return (rv[0] if rv else None) if one else rv


def query_local_metadata_db(
def query_temp_local_metadata_db(
query: str, args=(), one: bool = False
) -> dict[str, t.Any] | list[dict[str, t.Any]] | None:
cur = _get_local_metadata_db_connection().execute(query, args)
cur = _get_temp_local_metadata_db_connection().execute(query, args)
rv = cur.fetchall()
cur.close()
return (rv[0] if rv else None) if one else rv
Expand Down
Loading

0 comments on commit 9d3d0a2

Please sign in to comment.