Commit 3e8a3be
[AUTOREVERT] tune entry point for cli and event bridge, enabling providing custom running configurations (#7526)
Changes lambda entry point for autorevert to enable better handling
eventbridge parameters.
The changes are:
* Moved entry point from a global `main` to specific ones for CLI and
lambda;
* Moved main execution logic to a reused function;
* Created a general config holder interface dataclass;
this enables to use the lambda with different configs from eventbridge
like:
```
resource "aws_cloudwatch_event_rule" "pytorch_auto_revert_5m" {
name = "pytorch-auto-revert-5m"
description = "Every 5 minutes with config A"
schedule_expression = "rate(5 minutes)"
}
resource "aws_cloudwatch_event_target" "pytorch_auto_revert_5m_target" {
rule = aws_cloudwatch_event_rule.pytorch_auto_revert_5m.name
target_id = "pytorch-auto-revert-5m"
arn = aws_lambda_function.pytorch_auto_revert.arn
input = jsonencode({
mode = "hud"
dry_run = false
overrides = {
bisection_limit = 10
clickhouse_database = "default"
}
})
}
```
Key reasonings on the decisions:
- created a single class for parsed configs that is distinct from
default configs, still allowing validating and maintaining readability
and single use (one is default, another is actual);
- Reused entry points from lambda and cli, so, mostly if not all, can be
fully replicated via cli in case of firefight or debugging;
- broken entry point for cli and lambda: one parses opts and dotfiles,
another parse eventbridge. Separation of concerns and easier to read;
- removed possibility of running without any parameters in CLI to
replicate lambda - there will be multiple configurations, so, this does
not make sense anymore;
---------
Signed-off-by: Jean Schmidt <[email protected]>
Co-authored-by: Ivan Zaitsev <[email protected]>1 parent 7a9babb commit 3e8a3be
File tree
5 files changed
+422
-62
lines changed- aws/lambda/pytorch-auto-revert
- pytorch_auto_revert
5 files changed
+422
-62
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | 20 | | |
25 | 21 | | |
26 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments