-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpull_images_entrypoint.sh
More file actions
executable file
·63 lines (53 loc) · 1.46 KB
/
pull_images_entrypoint.sh
File metadata and controls
executable file
·63 lines (53 loc) · 1.46 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
#!/bin/bash
# Wrapper script for pull_images.py
# Make a usage string that advises the acceptable values of the second argument "save_pixel_data" are "true", "false" or nothing
usage="Usage: $0 <image_index> <output_dir> [<chunk_size>] [<retry_limit>]
<image_index>: pandas dataframe in parquet format listing SOP Instance UIDs to pull.
<output_dir> (path): directory to save logs.
<chunk_size>: [optional] number of images to pull at once [1].
<retry_limit>: [optional] number of times to retry failed pull requests [10]
"
script_dir=$(dirname "$(readlink -f "$0")")
py_file=${script_dir}/pull_images.py
if [[ ! -f $py_file ]]
then
echo "Must have python script in the same directory: $py_file"
exit 1
fi
env_script=${script_dir}/set_pacs_envs.sh
if [[ ! -f $env_script ]]
then
echo "Must have environment script in the same directory: $env_script"
exit 1
fi
image_index="$1"
if [[ -z "$image_index" ]]
then
echo "$usage"
exit 1
fi
output_dir="$2"
if [[ -z "$output_dir" ]]
then
echo "$usage"
exit 1
fi
if [[ ! -d "$output_dir" ]]
then
mkdir -p "$output_dir"
fi
chunk_size_arg=""
if [[ ! -z "$3" ]]
then
chunk_size_arg="--chunk_size $3"
fi
retry_limit_arg=""
if [[ ! -z "$4" ]]
then
retry_limit_arg="--retry_limit $4"
fi
. "$env_script"
command="python -u ""$py_file"" --image_index ""$image_index"" --output_dir ""$output_dir"" ""$chunk_size_arg"" ""$retry_limit_arg"""
echo "Command to run:"
echo "$command"
$command |& tee "$output_dir"/pull_images.log