Skip to content

Commit 978d705

Browse files
author
RomaLzhih
committed
feat(ae): update file remove
1 parent 4ef7a43 commit 978d705

1 file changed

Lines changed: 9 additions & 31 deletions

File tree

docker-run.sh

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ download_data_host() {
104104
print_info "Downloading real-world data on HOST..."
105105

106106
# Resolve absolute path for data_path
107-
if command -v realpath &> /dev/null; then
107+
if command -v realpath &>/dev/null; then
108108
data_path=$(realpath "$data_path")
109109
else
110110
data_path=$(cd "$data_path" && pwd)
@@ -135,7 +135,7 @@ run_container() {
135135
mkdir -p "$data_path"
136136

137137
create_host_dirs
138-
138+
139139
if [ "$should_download" = "true" ]; then
140140
download_data_host "$data_path"
141141
else
@@ -200,7 +200,7 @@ run_full_eval() {
200200
mkdir -p "$data_path"
201201

202202
create_host_dirs
203-
203+
204204
if [ "$should_download" = "true" ]; then
205205
download_data_host "$data_path"
206206
else
@@ -274,15 +274,15 @@ cleanup() {
274274

275275
# Use Docker to remove files (to handle root permissions)
276276
print_info "Removing generated files using Docker..."
277-
277+
278278
local mounts="-v $(pwd)/script_ae:/workspace/script_ae"
279279
local cmd="rm -rf /workspace/script_ae/data /workspace/script_ae/logs /workspace/script_ae/plots"
280280

281281
if [ -n "$data_path" ]; then
282282
# Only mount if data_path exists to avoid docker creating it as root
283283
if [ -d "$data_path" ]; then
284-
# Use realpath for the mount
285-
if command -v realpath &> /dev/null; then
284+
# Use realpath for the mount
285+
if command -v realpath &>/dev/null; then
286286
local abs_data_path=$(realpath "$data_path")
287287
else
288288
local abs_data_path=$(cd "$data_path" && pwd)
@@ -292,32 +292,10 @@ cleanup() {
292292
print_info "Also removing real-world data in: $data_path/geometry"
293293
fi
294294
fi
295-
296-
# Determine which image to use for cleanup
297-
local clean_image=""
298-
if docker image inspect "$IMAGE_NAME" >/dev/null 2>&1; then
299-
clean_image="$IMAGE_NAME"
300-
elif docker image inspect "alpine:latest" >/dev/null 2>&1; then
301-
clean_image="alpine:latest"
302-
elif docker image inspect "ubuntu:latest" >/dev/null 2>&1; then
303-
clean_image="ubuntu:latest"
304-
fi
305295

306-
if [ -n "$clean_image" ]; then
307-
print_info "Using image '$clean_image' for cleanup..."
308-
# Use bash if available, otherwise sh (for alpine)
309-
local shell_cmd="/bin/bash"
310-
if [[ "$clean_image" == *"alpine"* ]]; then
311-
shell_cmd="/bin/sh"
312-
fi
313-
314-
docker run --rm $mounts "$clean_image" "$shell_cmd" -c "$cmd"
315-
else
316-
print_warn "No suitable Docker image found for cleanup. Attempting local removal (may fail if files are root-owned)..."
317-
rm -rf script_ae/data script_ae/logs script_ae/plots
318-
if [ -n "$data_path" ] && [ -d "$data_path/geometry" ]; then
319-
rm -rf "$data_path/geometry"
320-
fi
296+
rm -rf script_ae/data script_ae/logs script_ae/plots
297+
if [ -n "$data_path" ] && [ -d "$data_path/geometry" ]; then
298+
rm -rf "$data_path/geometry"
321299
fi
322300

323301
# Remove stopped containers

0 commit comments

Comments
 (0)