Skip to content

Commit 5b1bd3c

Browse files
authored
Support specifying models in GKE experiment runs (#122)
Support specifying models in GKE experiment runs 1. Add `model` argument to `docker_run.sh`, `upload_report.sh`, and `web.py`. 2. Display the model name in experiment reports 3. Some TODOs to rewrite code to adapt to increasing complexity. Preview: <img width="1425" alt="image" src="https://github.com/google/oss-fuzz-gen/assets/20501961/96b12bb2-d945-43cb-b3eb-77f52f453297"> We can beautify the layout later.
1 parent 0ed11a3 commit 5b1bd3c

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

report/docker_run.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@
2626
## run_timeout: Timeout in seconds for each fuzzing target.
2727
## Default: 300
2828

29+
# TODO(dongge): Re-write this script in Python as it gets more complex.
30+
2931
BENCHMARK_SET=$1
3032
FREQUENCY_LABEL=$2
3133
RUN_TIMEOUT=$3
3234
SUB_DIR=$4
35+
MODEL=$5
3336
# Uses python3 by default and /venv/bin/python3 for Docker containers.
3437
PYTHON="$( [[ -x "/venv/bin/python3" ]] && echo "/venv/bin/python3" || echo "python3" )"
3538
export PYTHON
@@ -67,6 +70,12 @@ then
6770
echo "Sub-directory was not specified as the fourth argument. Defaulting to ${SUB_DIR:?}. Please consider using sub-directory to classify your experiment."
6871
fi
6972

73+
# The LLM used to generate and fix fuzz targets.
74+
if [[ $MODEL = '' ]]
75+
then
76+
MODEL='vertex_ai_code-bison-32k'
77+
echo "LLM was not specified as the fifth argument. Defaulting to ${MODEL:?}."
78+
fi
7079
DATE=$(date '+%Y-%m-%d')
7180
LOCAL_RESULTS_DIR='results'
7281
# Experiment name is used to label the Cloud Builds and as part of the
@@ -79,7 +88,7 @@ EXPERIMENT_NAME="${DATE:?}-${FREQUENCY_LABEL:?}-${BENCHMARK_SET:?}"
7988
GCS_REPORT_DIR="${SUB_DIR:?}/${EXPERIMENT_NAME:?}"
8089

8190
# Generate a report and upload it to GCS
82-
bash report/upload_report.sh "${LOCAL_RESULTS_DIR:?}" "${GCS_REPORT_DIR:?}" "${BENCHMARK_SET:?}" &
91+
bash report/upload_report.sh "${LOCAL_RESULTS_DIR:?}" "${GCS_REPORT_DIR:?}" "${BENCHMARK_SET:?}" "${MODEL:?}" &
8392
pid_report=$!
8493

8594
# Run the experiment
@@ -91,7 +100,7 @@ $PYTHON run_all_experiments.py \
91100
--template-directory 'prompts/template_xml' \
92101
--work-dir ${LOCAL_RESULTS_DIR:?} \
93102
--num-samples 10 \
94-
--mode 'vertex_ai_code-bison-32k'
103+
--model "$MODEL"
95104

96105
export ret_val=$?
97106

report/templates/base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
}
2323
</style>
2424
<body>
25+
LLM: {{ model }}
2526
{% block content %}{% endblock %}
2627
</body>

report/upload_report.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
## gcs_dir is the name of the directory for the report in gs://oss-fuzz-gcb-experiment-run-logs/Result-reports/.
2222
## Defaults to '$(whoami)-%YY-%MM-%DD'.
2323

24+
# TODO(dongge): Re-write this script in Python as it gets more complex.
25+
2426
RESULTS_DIR=$1
2527
GCS_DIR=$2
2628
BENCHMARK_SET=$3
29+
MODEL=$4
2730
WEB_PORT=8080
2831
DATE=$(date '+%Y-%m-%d')
2932

@@ -38,15 +41,22 @@ fi
3841

3942
if [[ $GCS_DIR = '' ]]
4043
then
41-
GCS_DIR="$(whoami)-${DATE:?}"
42-
echo "GCS directory was not specified as the second argument. Defaulting to ${GCS_DIR:?}."
44+
echo "This script needs to take gcloud Bucket directory as the second argument. Consider using $(whoami)-${DATE:?}."
45+
exit 1
46+
fi
47+
48+
# The LLM used to generate and fix fuzz targets.
49+
if [[ $MODEL = '' ]]
50+
then
51+
echo "This script needs to take LLM as the third argument."
52+
exit 1
4353
fi
4454

4555
mkdir results-report
4656

4757
while true; do
4858
# Spin up the web server generating the report (and bg the process).
49-
$PYTHON -m report.web "${RESULTS_DIR:?}" "${WEB_PORT:?}" "${BENCHMARK_SET:?}" &
59+
$PYTHON -m report.web "${RESULTS_DIR:?}" "${WEB_PORT:?}" "${BENCHMARK_SET:?}" "$MODEL" &
5060
pid_web=$!
5161

5262
cd results-report || exit 1

report/web.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,23 @@ def get_targets(benchmark: str, sample: str) -> list[Target]:
266266

267267
@app.route('/')
268268
def index():
269-
return render_template('index.html', benchmarks=list_benchmarks())
269+
return render_template('index.html',
270+
benchmarks=list_benchmarks(),
271+
model=model)
270272

271273

272274
@app.route('/json')
273275
def index_json():
274-
return render_template('index.json', benchmarks=list_benchmarks())
276+
return render_template('index.json',
277+
benchmarks=list_benchmarks(),
278+
model=model)
275279

276280

277281
@app.route('/sort')
278282
def index_sort():
279283
return render_template('index.html',
280-
benchmarks=sort_benchmarks(list_benchmarks()))
284+
benchmarks=sort_benchmarks(list_benchmarks()),
285+
model=model)
281286

282287

283288
@app.route('/benchmark/<benchmark>')
@@ -334,8 +339,10 @@ def serve(directory: str, port: int, benchmark_set: str):
334339

335340

336341
if __name__ == '__main__':
342+
# TODO(Dongge): Use argparser as this script gets more complex.
337343
results_dir = sys.argv[1]
338344
server_port = int(sys.argv[2])
339345
benchmark_dir = sys.argv[3] if len(sys.argv) > 3 else ''
346+
model = sys.argv[4] if len(sys.argv) > 4 else ''
340347

341348
serve(results_dir, server_port, benchmark_dir)

0 commit comments

Comments
 (0)