-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathupload_report.sh
More file actions
119 lines (100 loc) · 4.01 KB
/
Copy pathupload_report.sh
File metadata and controls
119 lines (100 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
## Usage:
## bash report/upload_report.sh results_dir [gcs_dir]
##
## results_dir is the local directory with the experiment results.
## gcs_dir is the name of the directory for the report in gs://oss-fuzz-gcb-experiment-run-logs/Result-reports/.
## Defaults to '$(whoami)-%YY-%MM-%DD'.
## additional_args are passed through to report.web (e.g., --with-csv)
# TODO(dongge): Re-write this script in Python as it gets more complex.
RESULTS_DIR=$1
GCS_DIR=$2
BENCHMARK_SET=$3
MODEL=$4
# All remaining arguments are additional args for report.web
shift 4
REPORT_ADDITIONAL_ARGS="$@"
DATE=$(date '+%Y-%m-%d')
# Sleep 5 minutes for the experiment to start.
sleep 300
if [[ $RESULTS_DIR = '' ]]
then
echo 'This script takes the results directory as the first argument'
exit 1
fi
if [[ $GCS_DIR = '' ]]
then
echo "This script needs to take gcloud Bucket directory as the second argument. Consider using $(whoami)-${DATE:?}."
exit 1
fi
# The LLM used to generate and fix fuzz targets.
if [[ $MODEL = '' ]]
then
echo "This script needs to take LLM as the third argument."
exit 1
fi
mkdir results-report
update_report() {
# Generate the report
if [[ $GCS_DIR != '' ]]; then
CLOUD_BASE_URL="https://llm-exp.oss-fuzz.com/Result-reports/${GCS_DIR}"
$PYTHON -m report.web -r "${RESULTS_DIR:?}" -b "${BENCHMARK_SET:?}" -m "$MODEL" -o results-report --base-url "$CLOUD_BASE_URL" --gcs-dir "${GCS_DIR}" $REPORT_ADDITIONAL_ARGS
else
$PYTHON -m report.web -r "${RESULTS_DIR:?}" -b "${BENCHMARK_SET:?}" -m "$MODEL" -o results-report $REPORT_ADDITIONAL_ARGS
fi
cd results-report || exit 1
# Upload the report to GCS.
echo "Uploading the report."
BUCKET_PATH="gs://oss-fuzz-gcb-experiment-run-logs/Result-reports/${GCS_DIR:?}"
# Upload HTMLs.
gsutil -q -m -h "Content-Type:text/html" \
-h "Cache-Control:public, max-age=3600" \
cp -r . "$BUCKET_PATH"
# Find all JSON files and upload them, removing the leading './'
find . -name '*json' | while read -r file; do
file_path="${file#./}" # Remove the leading "./".
gsutil -q -m -h "Content-Type:application/json" \
-h "Cache-Control:public, max-age=3600" cp "$file" "$BUCKET_PATH/$file_path"
done
cd ..
# Upload the raw results into the same GCS directory.
echo "Uploading the raw results."
gsutil -q -m cp -r "${RESULTS_DIR:?}" \
"gs://oss-fuzz-gcb-experiment-run-logs/Result-reports/${GCS_DIR:?}"
echo "See the published report at https://llm-exp.oss-fuzz.com/Result-reports/${GCS_DIR:?}/"
# Upload training data.
echo "Uploading training data."
rm -rf 'training_data'
gsutil -q rm -r "gs://oss-fuzz-gcb-experiment-run-logs/Result-reports/${GCS_DIR:?}/training_data" || true
$PYTHON -m data_prep.parse_training_data \
--experiment-dir "${RESULTS_DIR:?}" --save-dir 'training_data'
$PYTHON -m data_prep.parse_training_data --group \
--experiment-dir "${RESULTS_DIR:?}" --save-dir 'training_data'
$PYTHON -m data_prep.parse_training_data --coverage \
--experiment-dir "${RESULTS_DIR:?}" --save-dir 'training_data'
$PYTHON -m data_prep.parse_training_data --coverage --group \
--experiment-dir "${RESULTS_DIR:?}" --save-dir 'training_data'
gsutil -q cp -r 'training_data' \
"gs://oss-fuzz-gcb-experiment-run-logs/Result-reports/${GCS_DIR:?}"
}
while [[ ! -f /experiment_ended ]]; do
update_report
echo "Experiment is running..."
sleep 600
done
echo "Experiment finished."
update_report
echo "Final report uploaded."