Skip to content

Commit

Permalink
deprecated warning for _control in profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Jul 14, 2024
1 parent 323a66a commit 9c230e1
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
58 changes: 52 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#### Enhancements

- UI chips everywhere!
- improvements to the UI's experiment profile preview.
- `hours_elapsed()` is a function in profile expressions, which returns the hours since the profile started.
- `unit()` can be used in mqtt fetch expressions. Example: `unit():stirring:target_rpm` is identical to `::stirring:target_rpm`. The latter can be seen as a shortened version of the former.
Expand All @@ -11,13 +10,60 @@

#### Breaking changes

- `log` in experiment profiles now uses expressions instead of Python string formatting. For example: `The unit {unit} is running {job} in experiment {experiment}` should be replaced by expressions in the string: `The unit ${{unit()}} is running ${{job_name()}} in the experiment ${{experiment}}`.
- remove the temperature_control, dosing_control, and led_control abstractions. These were introduced early in the Pioreactor software as a way to quickly change automations, but they have been more of a wort than a win. While working on experiment profiles recently, it became more and more clear how poor this abstraction was. The removal of them has some consequences however, and some backward incompatibilities.
- remove the temperature_control, dosing_control, and led_control abstractions. These were introduced early in the Pioreactor software as a way to quickly change automations, but they have been more of a wort than a win. While working on the internals of experiment profiles recently, it became more and more clear how poor this abstraction was. The removal of them has some consequences and some backward incompatibilities, however

- update experiment profiles
- update plugins
- updating experiment profiles: experiment profiles that have a `*_control` job will need to be updated to use `*_automation`, _eventually_. For now, we are allowing `*_control` in profiles: in the backend, we are renaming `*_control` to `*_automations`, but a warning will be produced. Later, we'll remove this renaming and profiles will need to be completely updated. Example:
```
experiment_profile_name: start_temp_control
metadata:
author: Cam DP
common:
jobs:
temperature_control:
actions:
- type: start
hours_elapsed: 0
options:
automation_name: thermostat
target_temperature: 30
temperature_automation:
actions:
- type: update
hours_elapsed: 6
options:
target_temperature: 35
```

becomes:

```
experiment_profile_name: start_temp_control
metadata:
author: Cam DP
common:
jobs:
temperature_automation:
actions:
- type: start
hours_elapsed: 0
options:
automation_name: thermostat
target_temperature: 30
- type: update
hours_elapsed: 6
options:
target_temperature: 35
```

- update plugins. For users using, specifically, the high-temp plugin, or temperature-expansion-kit plugin, new plugins will be released. Look on the forums, or documentation, for update instructions.

The benefits of removing this abstraction is much less code, less overhead, easier developer experience, and overall simplification. Later, we may create a new abstraction, but now we are moving abstractions back the level 0.

The benefits of removing this abstraction is much less code, less overhead, easier developer experience, and overall simplification. Later, we may create a new abstraction, but now we are back at a level 0 to build one.
- `log` in experiment profiles now uses expressions instead of Python string formatting. For example: `The unit {unit} is running {job} in experiment {experiment}` should be replaced by expressions in the string: `The unit ${{unit()}} is running ${{job_name()}} in the experiment ${{experiment}}`. Note: `{job}` is not `${{job_name()}}`.

### 24.7.5 & 24.7.6 & 24.7.7

Expand Down
7 changes: 7 additions & 0 deletions pioreactor/actions/leader/experiment_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ def wrapped_execute_action(
if job_name == "led_intensity":
action = _led_intensity_hack(action)

# TODO: remove in a future version.
if job_name in ["temperature_control", "led_control", "dosing_control"]:
logger.warning(
f'Found deprecated `{job_name}` in profile. Update this to `{job_name.replace("control", "automation")}` (or combine with existing `{job_name.replace("control", "automation")}`). See changelog.'
)
job_name = job_name.replace("control", "automation")

env = {"unit": unit, "experiment": experiment, "job_name": job_name}

match action:
Expand Down

0 comments on commit 9c230e1

Please sign in to comment.