Skip to content

Commit 7e724d4

Browse files
committed
Fix and require --metrics-file argument use
1 parent 8bfdd7c commit 7e724d4

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

doc/mdbook-metrics/src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ fn run_kani_metrics_script() -> Result<(), Error> {
4646
"kani_std_analysis.py",
4747
"--crate",
4848
"core",
49+
"--metrics-file",
50+
"metrics-data-core.json",
4951
"--plot-only",
5052
"--plot-dir",
5153
&tools_path.to_string_lossy(),
@@ -59,6 +61,8 @@ fn run_kani_metrics_script() -> Result<(), Error> {
5961
"kani_std_analysis.py",
6062
"--crate",
6163
"std",
64+
"--metrics-file",
65+
"metrics-data-std.json",
6266
"--plot-only",
6367
"--plot-dir",
6468
&tools_path.to_string_lossy(),

scripts/kani-std-analysis/kani_std_analysis.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,9 @@ def __init__(self, metrics_file, crate):
158158

159159
# Read historical data from self.metrics_file and initialize the date range.
160160
def read_historical_data(self):
161-
try:
162-
with open(self.metrics_file, 'r') as f:
163-
all_data = json.load(f)["results"]
164-
self.update_plot_metrics(all_data)
165-
except FileNotFoundError:
166-
all_data = {}
161+
with open(self.metrics_file, 'r') as f:
162+
all_data = json.load(f)["results"]
163+
self.update_plot_metrics(all_data)
167164

168165
self.dates = [datetime.strptime(data["date"], '%Y-%m-%d').date() for data in all_data]
169166

@@ -305,8 +302,8 @@ def main():
305302
help="Name of standard library crate to produce metrics for")
306303
parser.add_argument('--metrics-file',
307304
type=str,
308-
default="metrics-data.json",
309-
help="Path to the JSON file containing metrics data (default: metrics-data.json)")
305+
required=True,
306+
help="Path to the JSON file containing metrics data")
310307
parser.add_argument('--kani-list-file',
311308
type=str,
312309
default="kani-list.json",

scripts/run-kani.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,12 @@ main() {
309309
pushd scripts/kani-std-analysis
310310
pip install -r requirements.txt
311311
echo "Computing Kani-specific metrics..."
312-
./kani_std_analysis.py --crate core --kani-list-file $current_dir/kani-list.json
313-
./kani_std_analysis.py --crate std --kani-list-file $current_dir/kani-list.json
312+
./kani_std_analysis.py --crate core \
313+
--kani-list-file $current_dir/kani-list.json \
314+
--metrics-file metrics-data-core.json
315+
./kani_std_analysis.py --crate std \
316+
--kani-list-file $current_dir/kani-list.json \
317+
--metrics-file metrics-data-std.json
314318
popd
315319
rm kani-list.json
316320
fi

0 commit comments

Comments
 (0)