1 |
1551
|
aaronmk
|
#!/bin/bash
|
2 |
1541
|
aaronmk
|
# Imports all inputs at once
|
3 |
|
|
|
4 |
1952
|
aaronmk
|
import_all_main ()
|
5 |
|
|
{
|
6 |
|
|
local self="${BASH_SOURCE[0]}"
|
7 |
|
|
local selfDir="$(dirname -- "$self")"
|
8 |
6211
|
aaronmk
|
cd "$selfDir/.."
|
9 |
1952
|
aaronmk
|
|
10 |
1953
|
aaronmk
|
if test "${BASH_LINENO[1]}" = 0; then # was run without initial "."
|
11 |
11371
|
aaronmk
|
echo "usage: [version=...] [inputs=(inputs/src/ ...)]; . $self \
|
12 |
|
|
[vars...] (note initial \".\")"|fold -s >&2
|
13 |
1952
|
aaronmk
|
return 2
|
14 |
|
|
fi
|
15 |
7103
|
aaronmk
|
: ${version=$(make -s version)}
|
16 |
10579
|
aaronmk
|
local by_col=${by_col-1} full_import=1
|
17 |
|
|
export version by_col full_import
|
18 |
1952
|
aaronmk
|
|
19 |
10847
|
aaronmk
|
# remove any leftover TNRS lockfile. usually, the PID in it would not exist,
|
20 |
|
|
# but sometimes it now refers to an active process which blocks tnrs.make.
|
21 |
10849
|
aaronmk
|
"rm" inputs/.TNRS/tnrs/tnrs.make.lock
|
22 |
10847
|
aaronmk
|
|
23 |
6946
|
aaronmk
|
make schemas/$version/install
|
24 |
|
|
|
25 |
11393
|
aaronmk
|
local hidden_srcs=1; . "$selfDir/with_all" Source/import_temp by_col=1 "$@"
|
26 |
6897
|
aaronmk
|
# note that this isn't affected by $import_source
|
27 |
6593
|
aaronmk
|
wait # wait for asynchronous commands
|
28 |
11374
|
aaronmk
|
unset hidden_srcs
|
29 |
6593
|
aaronmk
|
|
30 |
7095
|
aaronmk
|
local import_source= # Source tables have already been imported
|
31 |
|
|
export import_source # must come after local
|
32 |
6897
|
aaronmk
|
|
33 |
11393
|
aaronmk
|
# publish datasources that won't be published by `make .../import`
|
34 |
|
|
make inputs/.TNRS/publish
|
35 |
|
|
make inputs/.geoscrub/publish
|
36 |
|
|
|
37 |
6382
|
aaronmk
|
make inputs/.herbaria/import "$@" &
|
38 |
|
|
sleep 5 # wait for make commands to scroll by
|
39 |
|
|
|
40 |
5836
|
aaronmk
|
make inputs/.NCBI/import by_col=1 "$@"
|
41 |
5959
|
aaronmk
|
|
42 |
6594
|
aaronmk
|
wait # wait for asynchronous commands
|
43 |
5503
|
aaronmk
|
|
44 |
11286
|
aaronmk
|
. "$selfDir/with_all" import_scrub "$@" # uses $by_col
|
45 |
6210
|
aaronmk
|
|
46 |
7418
|
aaronmk
|
local jobs="$(jobs -p)"
|
47 |
|
|
echo "import_scrub PIDs: $jobs" >&2
|
48 |
|
|
|
49 |
10586
|
aaronmk
|
bin/after_import $jobs &
|
50 |
7276
|
aaronmk
|
echo "after_import PID: $!" >&2
|
51 |
7228
|
aaronmk
|
|
52 |
|
|
. bin/disown_all
|
53 |
1952
|
aaronmk
|
}
|
54 |
|
|
import_all_main "$@"
|