Skip to content

Commit f91750f

Browse files
committed
added script to deploy to GCE
1 parent 91ef008 commit f91750f

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

benchmarks/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM python:3.11-slim
16+
17+
ENV PYTHONUNBUFFERED=0
18+
19+
WORKDIR /app
20+
21+
# install other requirements
22+
COPY benchmarks/requirements.txt /app/requirements.txt
23+
RUN pip install -r requirements.txt
24+
25+
# install bigtable library
26+
COPY scripts /app/python-bigtable/scripts
27+
COPY setup.py /app/python-bigtable/
28+
COPY README.rst /app/python-bigtable/
29+
COPY google /app/python-bigtable/google
30+
RUN python -m pip install -e /app/python-bigtable
31+
32+
# copy benchmark files
33+
COPY benchmarks /app
34+
COPY tests/system/data/setup_fixtures.py /app
35+
36+
# run benchmark
37+
CMD ["python", "-m", "pytest", ".", "-s"]

benchmarks/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pytest
2+
pytest-asyncio
3+
tqdm
4+
rich

benchmarks/run_on_gce.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
#!/bin/bash
16+
17+
PROJECT_ID=$(gcloud config get-value project)
18+
19+
SCRIPT_DIR=$(dirname "$0")
20+
cd $SCRIPT_DIR/..
21+
22+
# build container
23+
export DOCKER_BUILDKIT=1
24+
IMAGE_PATH="gcr.io/$PROJECT_ID/python-bigtable-benchmark"
25+
docker build -t $IMAGE_PATH -f $SCRIPT_DIR/Dockerfile .
26+
docker push $IMAGE_PATH
27+
28+
# deploy to GCE
29+
INSTANCE_NAME="python-bigtable-benchmark-$(date +%s)"
30+
ZONE=us-central1-b
31+
gcloud compute instances create-with-container $INSTANCE_NAME \
32+
--container-image=$IMAGE_PATH \
33+
--machine-type=n1-standard-4 \
34+
--zone=$ZONE \
35+
--scopes=cloud-platform \
36+
--container-restart-policy=never
37+
38+
# find container id
39+
echo "waiting for container to start..."
40+
while [[ -z "$CONTAINER_ID" ]]; do
41+
sleep 1
42+
CONTAINER_ID=$(gcloud compute instances get-serial-port-output $INSTANCE_NAME --zone $ZONE 2>/dev/null | grep "Starting a container with ID" | awk '{print $NF}')
43+
done
44+
echo "found container id: $CONTAINER_ID"
45+
46+
# print logs
47+
gcloud beta logging tail "$CONTAINER_ID" --format='value(jsonPayload.message)'

0 commit comments

Comments
 (0)