Skip to content

Commit 4ab2fc0

Browse files
talsperreclaude
andauthored
Remove unused audit() callbacks from test_config flow files (#3171)
## Summary The four `test/test_config/*.py` flow files each defined an `audit(run, parameters, configs, stdout_path)` callback intended for an in-tree test runner that would execute the flow and post-validate artifacts on the resulting Run. That runner is no longer driving these flows — the validations have moved into the pytest suite — so the audit functions are dead code, along with the imports (`json`, `os`) and one helper (`find_param_in_parameters` in `mutable_flow.py`) that became unused. ## What changed - `config_simple.py`: removed `audit()`, dropped now-unused `import json`. - `config_parser.py`: removed `audit()`, dropped now-unused `import json` and `import os`. - `config_corner_cases.py`: removed `audit()`, dropped now-unused `import json`. - `mutable_flow.py`: removed `audit()` + `find_param_in_parameters()` helper, dropped now-unused `import json`. Net: `4 files changed, 205 deletions(-)`. No behavior change — nothing in the repo imports or calls these functions (verified via grep across the tree). ## Test plan - [x] `python -m py_compile` clean on all four files - [x] `pre-commit run --files test/test_config/{config_simple,config_parser,config_corner_cases,mutable_flow}.py` passes (black, AST check, etc.) - [ ] CI green 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b5fc5e7 commit 4ab2fc0

4 files changed

Lines changed: 0 additions & 205 deletions

File tree

test/test_config/config_corner_cases.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import os
32

43
from metaflow import (
@@ -15,43 +14,6 @@
1514
default_config = {"a": {"b": "41", "project_name": "config_project"}}
1615

1716

18-
def audit(run, parameters, configs, stdout_path):
19-
# We should only have one run here
20-
if len(run) != 1:
21-
raise RuntimeError("Expected only one run; got %d" % len(run))
22-
run = run[0]
23-
24-
# Check successful run
25-
if not run.successful:
26-
raise RuntimeError("Run was not successful")
27-
28-
if configs and configs.get("cfg_default_value"):
29-
config = configs["cfg_default_value"]
30-
else:
31-
config = default_config
32-
33-
expected_token = parameters["trigger_param"]
34-
35-
# Check that we have the proper project name
36-
if f"project:{config['a']['project_name']}" not in run.tags:
37-
raise RuntimeError("Project name is incorrect.")
38-
39-
# Check the value of the artifacts in the end step
40-
end_task = run["end"].task
41-
assert end_task.data.trigger_param == expected_token
42-
if (
43-
end_task.data.config_val != 5
44-
or end_task.data.config_val_2 != config["a"]["b"]
45-
or end_task.data.config_from_env != "5"
46-
or end_task.data.config_from_env_2 != config["a"]["b"]
47-
or end_task.data.var1 != "1"
48-
or end_task.data.var2 != "2"
49-
):
50-
raise RuntimeError("Config values are incorrect.")
51-
52-
return None
53-
54-
5517
def trigger_name_func(ctx):
5618
return [current.project_flow_name + "Trigger"]
5719

test/test_config/config_parser.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import json
2-
import os
3-
41
from metaflow import (
52
Config,
63
FlowSpec,
@@ -17,56 +14,6 @@
1714
default_config = {"project_name": "config_parser"}
1815

1916

20-
def audit(run, parameters, configs, stdout_path):
21-
# We should only have one run here
22-
if len(run) != 1:
23-
raise RuntimeError("Expected only one run; got %d" % len(run))
24-
run = run[0]
25-
26-
# Check successful run
27-
if not run.successful:
28-
raise RuntimeError("Run was not successful")
29-
30-
if len(parameters) > 1:
31-
expected_tokens = parameters[-1].split()
32-
if len(expected_tokens) < 8:
33-
raise RuntimeError("Unexpected parameter list: %s" % str(expected_tokens))
34-
expected_token = expected_tokens[7]
35-
else:
36-
expected_token = ""
37-
38-
# Check that we have the proper project name
39-
if f"project:{default_config['project_name']}" not in run.tags:
40-
raise RuntimeError("Project name is incorrect.")
41-
42-
# Check the value of the artifacts in the end step
43-
end_task = run["end"].task
44-
assert end_task.data.trigger_param == expected_token
45-
46-
if end_task.data.lib_version != "2.5.148":
47-
raise RuntimeError("Library version is incorrect.")
48-
49-
# Check we properly parsed the requirements file
50-
if len(end_task.data.req_config) != 2:
51-
raise RuntimeError(
52-
"Requirements file is incorrect -- expected 2 keys, saw %s"
53-
% str(end_task.data.req_config)
54-
)
55-
if end_task.data.req_config["python"] != "3.10.*":
56-
raise RuntimeError(
57-
"Requirements file is incorrect -- got python version %s"
58-
% end_task.data.req_config["python"]
59-
)
60-
61-
if end_task.data.req_config["packages"] != {"regex": "2024.11.6"}:
62-
raise RuntimeError(
63-
"Requirements file is incorrect -- got packages %s"
64-
% end_task.data.req_config["packages"]
65-
)
66-
67-
return None
68-
69-
7017
def trigger_name_func(ctx):
7118
return [current.project_flow_name + "Trigger"]
7219

test/test_config/config_simple.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import os
32

43
from metaflow import (
@@ -15,47 +14,6 @@
1514
default_config = {"a": {"b": "41", "project_name": "config_project"}}
1615

1716

18-
def audit(run, parameters, configs, stdout_path):
19-
# We should only have one run here
20-
if len(run) != 1:
21-
raise RuntimeError("Expected only one run; got %d" % len(run))
22-
run = run[0]
23-
24-
# Check successful run
25-
if not run.successful:
26-
raise RuntimeError("Run was not successful")
27-
28-
if configs and configs.get("cfg_default_value"):
29-
config = json.loads(configs["cfg_default_value"])
30-
else:
31-
config = default_config
32-
33-
if len(parameters) > 1:
34-
expected_tokens = parameters[-1].split()
35-
if len(expected_tokens) < 8:
36-
raise RuntimeError("Unexpected parameter list: %s" % str(expected_tokens))
37-
expected_token = expected_tokens[7]
38-
else:
39-
expected_token = ""
40-
41-
# Check that we have the proper project name
42-
if f"project:{config['a']['project_name']}" not in run.tags:
43-
raise RuntimeError("Project name is incorrect.")
44-
45-
# Check the value of the artifacts in the end step
46-
end_task = run["end"].task
47-
assert end_task.data.trigger_param == expected_token
48-
if (
49-
end_task.data.config_val != 5
50-
or end_task.data.config_val_2 != config["a"]["b"]
51-
or end_task.data.config_from_env != "5"
52-
or end_task.data.config_from_env_2 != config["a"]["b"]
53-
):
54-
raise RuntimeError("Config values are incorrect.")
55-
56-
return None
57-
58-
5917
def trigger_name_func(ctx):
6018
return [current.project_flow_name + "Trigger"]
6119

test/test_config/mutable_flow.py

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import os
32

43
from metaflow import (
@@ -28,77 +27,6 @@
2827
}
2928

3029

31-
def find_param_in_parameters(parameters, name):
32-
for param in parameters:
33-
splits = param.split(" ")
34-
try:
35-
idx = splits.index("--" + name)
36-
return splits[idx + 1]
37-
except ValueError:
38-
continue
39-
return None
40-
41-
42-
def audit(run, parameters, configs, stdout_path):
43-
# We should only have one run here
44-
if len(run) != 1:
45-
raise RuntimeError("Expected only one run; got %d" % len(run))
46-
run = run[0]
47-
48-
# Check successful run
49-
if not run.successful:
50-
raise RuntimeError("Run was not successful")
51-
52-
if configs:
53-
# We should have one config called "config"
54-
if len(configs) != 1 or not configs.get("config"):
55-
raise RuntimeError("Expected one config called 'config'")
56-
config = json.loads(configs["config"])
57-
else:
58-
config = default_config
59-
60-
if len(parameters) > 1:
61-
expected_tokens = parameters[-1].split()
62-
if len(expected_tokens) < 8:
63-
raise RuntimeError("Unexpected parameter list: %s" % str(expected_tokens))
64-
expected_token = expected_tokens[7]
65-
else:
66-
expected_token = ""
67-
68-
# Check that we have the proper project name
69-
if f"project:{config['project_name']}" not in run.tags:
70-
raise RuntimeError("Project name is incorrect.")
71-
72-
# Check the start step that all values are properly set. We don't need
73-
# to check end step as it would be a duplicate
74-
start_task_data = run["start"].task.data
75-
76-
assert start_task_data.trigger_param == expected_token
77-
for param in config["parameters"]:
78-
value = find_param_in_parameters(parameters, param["name"]) or param["default"]
79-
if not hasattr(start_task_data, param["name"]):
80-
raise RuntimeError(f"Missing parameter {param['name']}")
81-
if getattr(start_task_data, param["name"]) != value:
82-
raise RuntimeError(
83-
f"Parameter {param['name']} has incorrect value %s versus %s expected"
84-
% (getattr(start_task_data, param["name"]), value)
85-
)
86-
assert (
87-
start_task_data.flow_level
88-
== config["flow_add_environment"]["vars"]["FLOW_LEVEL"]
89-
)
90-
assert (
91-
start_task_data.step_level
92-
== config["step_add_environment"]["vars"]["STEP_LEVEL"]
93-
)
94-
assert (
95-
start_task_data.step_level_2
96-
== config["step_add_environment_2"]["vars"]["STEP_LEVEL_2"]
97-
)
98-
99-
return None
100-
101-
10230
class ModifyFlow(FlowMutator):
10331
def mutate(self, mutable_flow):
10432
steps = ["start", "end"]

0 commit comments

Comments
 (0)