Skip to content

Commit b30036f

Browse files
aramesh7David Goodwin
authored and
David Goodwin
committed
Fixed GCS empty root directory bug, and updated cloud storage CI test. (#473)
* Fixed GCS empty root directory bug, and updated cloud storage CI * Added trailing slash check loop for CI
1 parent 4d28f43 commit b30036f

File tree

2 files changed

+115
-53
lines changed

2 files changed

+115
-53
lines changed

qa/L0_infer_cloud_storage/test.sh

+109-53
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ CLIENT_LOG_BASE="./client"
3131
INFER_TEST=infer_test.py
3232

3333
# Google cloud variables (Point to bucket when testing GCS)
34-
# NOTES:
35-
# - This folder MUST exist otherwise the GCS test will fail
36-
# - If this variable doesn't end in a slash gsutil-m cp becomes slow
3734

38-
DATA_URL="gs://path/to/gcs/bucket/models/"
35+
BUCKET_URL="gs://bucket"
36+
37+
# Remove Slash in BUCKET_URL
38+
BUCKET_URL=${BUCKET_URL%/}
39+
BUCKET_URL_SLASH="${BUCKET_URL}/"
3940

4041
SERVER=/opt/tensorrtserver/bin/trtserver
4142
SERVER_TIMEOUT=360
@@ -50,71 +51,126 @@ rm -f $SERVER_LOG_BASE* $CLIENT_LOG_BASE*
5051

5152
RET=0
5253

53-
SERVER_ARGS="--model-store=$DATA_URL --exit-timeout-secs=120"
54-
5554
# Construct model repository
5655

5756
KIND="KIND_GPU"
5857

59-
# copy models in model directory
60-
rm -rf models && mkdir -p models
61-
for FW in graphdef savedmodel netdef onnx libtorch plan; do
62-
cp -r /data/inferenceserver/qa_model_repository/${FW}_float32_float32_float32/ models/
63-
done
58+
for MAYBE_SLASH in "" "/"; do
59+
60+
ROOT_REPO="$BUCKET_URL$MAYBE_SLASH"
61+
MODEL_REPO="${BUCKET_URL_SLASH}models${MAYBE_SLASH}"
62+
63+
# copy models in model directory
64+
rm -rf models && mkdir -p models
65+
66+
# perform empty repo tests
67+
68+
SERVER_ARGS="--model-store=$ROOT_REPO --exit-timeout-secs=120"
69+
70+
run_server
71+
if [ "$SERVER_PID" == "0" ]; then
72+
echo -e "\n***\n*** Failed to start $SERVER\n***"
73+
cat $SERVER_LOG
74+
exit 1
75+
fi
76+
77+
kill $SERVER_PID
78+
wait $SERVER_PID
6479

65-
# Copy models with string inputs and remove nobatch (bs=1) models
66-
cp -r /data/inferenceserver/qa_model_repository/*_object_object_object/ models/
67-
rm -rf models/*nobatch*
80+
# run with a non-root empty model repo
81+
touch models/dummy
82+
gsutil cp -r models/ "$BUCKET_URL_SLASH"
6883

69-
for FW in graphdef savedmodel netdef onnx libtorch plan; do
70-
for MC in `ls models/${FW}*/config.pbtxt`; do
71-
echo "instance_group [ { kind: ${KIND} }]" >> $MC
84+
SERVER_ARGS="--model-store=$MODEL_REPO --exit-timeout-secs=120"
85+
86+
run_server
87+
if [ "$SERVER_PID" == "0" ]; then
88+
echo -e "\n***\n*** Failed to start $SERVER\n***"
89+
cat $SERVER_LOG
90+
exit 1
91+
fi
92+
93+
kill $SERVER_PID
94+
wait $SERVER_PID
95+
96+
gsutil -m rm "${BUCKET_URL_SLASH}**"
97+
rm models/dummy
98+
99+
# Now start model tests
100+
101+
for FW in graphdef savedmodel netdef onnx libtorch plan; do
102+
cp -r /data/inferenceserver/qa_model_repository/${FW}_float32_float32_float32/ models/
72103
done
73-
done
74104

75-
# now traverse the tree and create empty version directories that gsutil skips
76-
for dir in `ls models/`; do
77-
for subdir in `ls models/$dir`; do
78-
if [ -d models/$dir/$subdir ] && [ -z "$(ls models/$dir/$subdir)" ]; then
79-
touch models/$dir/$subdir/$subdir
80-
fi
105+
# Copy models with string inputs and remove nobatch (bs=1) models
106+
cp -r /data/inferenceserver/qa_model_repository/*_object_object_object/ models/
107+
rm -rf models/*nobatch*
108+
109+
for FW in graphdef savedmodel netdef onnx libtorch plan; do
110+
for MC in `ls models/${FW}*/config.pbtxt`; do
111+
echo "instance_group [ { kind: ${KIND} }]" >> $MC
112+
done
81113
done
82-
done
83114

84-
# copy contents of /models into GCS bucket.
85-
gsutil -m rm $DATA_URL** && \
86-
gsutil -m cp -r models/** $DATA_URL
115+
# now traverse the tree and create empty version directories that gsutil skips
116+
for dir in `ls models/`; do
117+
for subdir in `ls models/$dir`; do
118+
if [ -d models/$dir/$subdir ] && [ -z "$(ls models/$dir/$subdir)" ]; then
119+
touch models/$dir/$subdir/$subdir
120+
fi
121+
done
122+
done
87123

88-
run_server
89-
if [ "$SERVER_PID" == "0" ]; then
90-
echo -e "\n***\n*** Failed to start $SERVER\n***"
91-
cat $SERVER_LOG
92-
exit 1
93-
fi
124+
# Perform test with model repository variants
125+
for repo in "models/**" "models" ; do
94126

95-
set +e
127+
# copy contents of /models into GCS bucket.
128+
gsutil -m cp -r $repo $BUCKET_URL_SLASH
96129

97-
# python unittest seems to swallow ImportError and still return 0
98-
# exit code. So need to explicitly check CLIENT_LOG to make sure
99-
# we see some running tests
100-
python $INFER_TEST >$CLIENT_LOG 2>&1
101-
if [ $? -ne 0 ]; then
102-
cat $CLIENT_LOG
103-
echo -e "\n***\n*** Test Failed\n***"
104-
RET=1
105-
fi
130+
if [ "$repo" == "models" ]; then
131+
# set server arguments
132+
SERVER_ARGS="--model-store=$MODEL_REPO --exit-timeout-secs=120"
133+
else
134+
# set server arguments
135+
SERVER_ARGS="--model-store=$ROOT_REPO --exit-timeout-secs=120"
136+
fi
106137

107-
grep -c "HTTP/1.1 200 OK" $CLIENT_LOG
108-
if [ $? -ne 0 ]; then
109-
cat $CLIENT_LOG
110-
echo -e "\n***\n*** Test Failed To Run\n***"
111-
RET=1
112-
fi
138+
run_server
139+
if [ "$SERVER_PID" == "0" ]; then
140+
echo -e "\n***\n*** Failed to start $SERVER\n***"
141+
cat $SERVER_LOG
142+
exit 1
143+
fi
144+
145+
set +e
113146

114-
set -e
147+
# python unittest seems to swallow ImportError and still return 0
148+
# exit code. So need to explicitly check CLIENT_LOG to make sure
149+
# we see some running tests
150+
python $INFER_TEST >$CLIENT_LOG 2>&1
151+
if [ $? -ne 0 ]; then
152+
cat $CLIENT_LOG
153+
echo -e "\n***\n*** Test Failed\n***"
154+
RET=1
155+
fi
156+
157+
grep -c "HTTP/1.1 200 OK" $CLIENT_LOG
158+
if [ $? -ne 0 ]; then
159+
cat $CLIENT_LOG
160+
echo -e "\n***\n*** Test Failed To Run\n***"
161+
RET=1
162+
fi
163+
164+
set -e
115165

116-
kill $SERVER_PID
117-
wait $SERVER_PID
166+
kill $SERVER_PID
167+
wait $SERVER_PID
168+
169+
# Clean up bucket
170+
gsutil -m rm "${BUCKET_URL_SLASH}**"
171+
172+
done
173+
done
118174

119175
if [ $RET -eq 0 ]; then
120176
echo -e "\n***\n*** Test Passed\n***"

src/core/filesystem.cc

+6
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,12 @@ GCSFileSystem::IsDirectory(const std::string& path, bool* is_dir)
332332
"Could not get MetaData for bucket with name " + bucket);
333333
}
334334

335+
// Root case - bucket exists and object path is empty
336+
if (object_path.empty()) {
337+
*is_dir = true;
338+
return Status::Success;
339+
}
340+
335341
// Check whether it has children. If at least one child, it is a directory
336342
for (auto&& object_metadata :
337343
client_->ListObjects(bucket, gcs::Prefix(AppendSlash(object_path)))) {

0 commit comments

Comments
 (0)