Skip to content

Commit

Permalink
more profile stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Jul 7, 2024
1 parent 1652956 commit 67a8e68
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
12 changes: 5 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<<<<<<< HEAD
### Upcoming

- improvements to the real-time profile editor,
- `hours_elapsed()` is a function in profile expressions.
- Breaking change: `log` in experiment profiles now uses expressions.
- improvements to the UI's experiment profile preview. It's so pretty!
- `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.
- Breaking change: `log` in experiment profiles now uses expressions instead of python 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}}`.
- Updated Raspberry Pi OS image to 2024-07-04.

### 24.7.5 & 24.7.6
=======

### 24.7.5 & 24.7.6 & 24.7.7
>>>>>>> master

Hotfix release for 24.7.3. This pins blinka to a specific version which does not install numpy.

Expand Down
3 changes: 2 additions & 1 deletion pioreactor/experiment_profiles/profile_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ def __str__(self) -> str:

class Job(Struct, forbid_unknown_fields=True):
actions: list[Action]
# description?
description: Optional[str] = None
# metadata?
# calibration_settings?
# config_options?
# logging?


PioreactorUnitName = str
Expand Down
44 changes: 44 additions & 0 deletions pioreactor/tests/test_execute_experiment_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,50 @@ def collection_actions(msg):
)


@patch("pioreactor.actions.leader.experiment_profile._load_experiment_profile")
def test_execute_experiment_profile_expression_in_common_also_works_with_unit_function(
mock__load_experiment_profile, active_workers_in_cluster
) -> None:
job_name = "jobbing"

for worker in active_workers_in_cluster:
publish(f"pioreactor/{worker}/_testing_experiment/{job_name}/target", 10, retain=True)

action = Start(
hours_elapsed=0, options={"target": "${{unit():jobbing:target + 1}}"}, if_="unit():jobbing:target > 0"
)

profile = Profile(
experiment_profile_name="test_profile",
plugins=[],
common=CommonBlock(
jobs={
job_name: Job(actions=[action]),
}
),
metadata=Metadata(author="test_author"),
)

mock__load_experiment_profile.return_value = profile

actions = []

def collection_actions(msg):
actions.append(msg.payload.decode())

subscribe_and_callback(
collection_actions,
[f"pioreactor/{worker}/_testing_experiment/run/jobbing" for worker in active_workers_in_cluster],
allow_retained=False,
)

execute_experiment_profile("profile.yaml", "_testing_experiment")

assert actions == ['{"options":{"target":11.0,"job_source":"experiment_profile"},"args":[]}'] * len(
active_workers_in_cluster
)


@patch("pioreactor.actions.leader.experiment_profile._load_experiment_profile")
def test_execute_experiment_profile_when_action_simple(mock__load_experiment_profile) -> None:
experiment = "_testing_experiment"
Expand Down

0 comments on commit 67a8e68

Please sign in to comment.