Project

General

Profile

« Previous | Next » 

Revision 12779

*{.sh,run}: use new begin_target instead of `echo_func; set_make_vars`

View differences:

trunk/inputs/GBIF/raw_occurrence_record_plants/run
7 7

  
8 8
herbaria_filter.ih.csv_/make()
9 9
{
10
	echo_func; set_make_vars; check_target_exists
10
	begin_target; check_target_exists
11 11
	
12 12
	use_local
13 13
	limit= query='SELECT DISTINCT "specimenHolderInstitutions" FROM herbaria.ih ORDER BY "specimenHolderInstitutions"' \
......
16 16

  
17 17
ih_herbarium/make() # stores IH herbaria
18 18
{
19
	echo_func; set_make_vars
19
	begin_target
20 20
	
21 21
	use_local_remote
22 22
	local table="$target_stem"
......
34 34

  
35 35
plant_fraction/make() # runtime: 1 hr ("10603 rows affected (53 min 44.68 sec)")
36 36
{
37
	echo_func; set_make_vars; mk_table_esc
37
	begin_target; mk_table_esc
38 38
	
39 39
	use_local_remote
40 40
	if remaking; then table=plant_fraction table_esc= mk_drop|mysql; fi
......
62 62

  
63 63
plant_fraction/seal()
64 64
{
65
	echo_func; set_make_vars
65
	begin_target
66 66
	
67 67
	use_local_remote
68 68
	table=plant_fraction table_esc= mysql_seal_table
......
70 70

  
71 71
plant_fraction_for_herbaria_filter/make()
72 72
{
73
	echo_func; set_make_vars; mk_table_esc
73
	begin_target; mk_table_esc
74 74
	
75 75
	plant_fraction/make
76 76
	use_local_remote
......
87 87

  
88 88
herbaria_filter/make() # runtime: ~0 ("0m2.235s"): CSV import, index scans only
89 89
{
90
	echo_func; set_make_vars
90
	begin_target
91 91
	
92 92
	use_local_remote
93 93
	local table="$target_stem"
......
114 114

  
115 115
herbaria_filter/seal()
116 116
{
117
	echo_func; set_make_vars
117
	begin_target
118 118
	
119 119
	use_local_remote
120 120
	table=herbaria_filter table_esc= mysql_seal_table
......
122 122

  
123 123
table/make() # makes the filter view
124 124
{
125
	echo_func; set_make_vars; mk_table_esc
125
	begin_target; mk_table_esc
126 126
	
127 127
	herbaria_filter/make
128 128
	use_local_remote
......
152 152
# to view runtime when using `screen`:
153 153
# press Ctrl-A [ , use arrow keys/Ctrl-B/Ctrl-F, and then Esc to leave copy mode
154 154
{
155
	echo_func; set_make_vars; check_target_exists
155
	begin_target; check_target_exists
156 156
	
157 157
	table/make
158 158
	self_make table.tsv/make__src_table_run
trunk/inputs/GBIF/_MySQL/GBIFPortalDB-2013-02-20.data.sql.run
18 18
func_override ^.preamble.sql/make__resume_import_sh
19 19
^.preamble.sql/make()
20 20
{
21
	echo_func; set_make_vars
21
	begin_target
22 22
	top_file="$dumpfile" self_make ^.preamble.sql/make__resume_import_sh
23 23
}
24 24

  
trunk/inputs/.TNRS/data.sql.run
5 5

  
6 6
refresh() # usage: .../data.sql.run refresh
7 7
{
8
	echo_func; set_make_vars
8
	begin_target
9 9
	"$top_dir"/../test_taxonomic_names/test_scrub
10 10
	remake=1 export_ # update data.sql with the changes
11 11
}
trunk/inputs/IRMNG/homonyms.run
6 6

  
7 7
*.htm/make()
8 8
{
9
	echo_func; set_make_vars; check_wildcard_target_exists
9
	begin_target; check_wildcard_target_exists
10 10
	local letter_range="${letter_range-[A-Z]}"
11 11
	local rank="${table%_homonyms}"
12 12
	curl --output '#1.htm' "http://www.marine.csiro.au/mirrorsearch/ir_search.list_homonyms?hlevel=$rank&start_letter=$letter_range&restrict_by=pln&output_style=delim_rows"
......
14 14

  
15 15
*.txt/make()
16 16
{
17
	echo_func; set_make_vars; deferred_check_target_exists
17
	begin_target; deferred_check_target_exists
18 18
	*.htm/make
19 19
	for in in "$top_dir"/*.htm; do
20 20
		stdout="${in/%.htm/.txt}" to_file grep -vE '^<' "$in" # strip tags
......
24 24
func_override import__table_run
25 25
import()
26 26
{
27
	echo_func; set_make_vars
27
	begin_target
28 28
	*.txt/make
29 29
	self_make import__table_run "$@"
30 30
}
trunk/inputs/VegBank/run
5 5

  
6 6
refresh() # usage: on *vegbiendev*: .../run refresh
7 7
{
8
	echo_func; set_make_vars
8
	begin_target
9 9
	local remake=1 # run all commands below in this mode
10 10
	datasrc_make vegbank.schema.sql
11 11
	datasrc_make vegbank.data.sql # runtime: 3.5 min (":17:38" - ":14:16" =3:22)
trunk/schemas/VegCore/ERD/VegCore.ERD.mwb.run
24 24

  
25 25
../VegCore.my.sql/make()
26 26
{
27
	echo_func; set_make_vars
27
	begin_target
28 28
	database=VegCore create_db=1 mysqldump_local --skip-add-drop-table \
29 29
>"$target"
30 30
}
......
37 37

  
38 38
../VegCore.pg.sql/make()
39 39
{
40
	echo_func; set_make_vars
40
	begin_target
41 41
	sql_ascii=1 my2pg <"${target%.pg.sql}.my.sql" >"$target"
42 42
}
43 43

  
trunk/schemas/VegCore/ERD/VegCore.ERD.png.map.htm.run
16 16

  
17 17
cleanup()
18 18
{
19
	echo_func; set_make_vars
19
	begin_target
20 20
	in_place "$top_file" $sed_cmd \
21 21
-e 's/&amp;/\&/g
22 22
# undo double-encodings' \
......
27 27

  
28 28
header.htm/make()
29 29
{
30
	echo_func; set_make_vars
30
	begin_target
31 31
	stdout="$target" to_file sed \
32 32
-e 's/( alt="[^:"]*): ([^"]*)(")/\1\3 title="\2"/g' \
33 33
"$top_file"
trunk/BIEN2/country_species/run
8 8

  
9 9
all() # runtime: 1 min ("0m56.053s")
10 10
{
11
	echo_func; set_make_vars; deferred_check_target_exists
11
	begin_target; deferred_check_target_exists
12 12
	
13 13
	if ! isset password; then
14 14
		local_export password; read -rsp 'Enter your MySQL password: ' password
trunk/run
10 10

  
11 11
taxon_trait/make() # runtime: ~0 ("real 0m0.411s") @ r10826
12 12
{
13
	echo_func; set_make_vars; check_fake_target_exists
13
	begin_target; check_fake_target_exists
14 14
	local order_by=(scientificName measurementType)
15 15
	pg_export_table_to_dir "$target_filename"
16 16
}
trunk/lib/runscripts/datasrc_dir.run
11 11

  
12 12
import()
13 13
{
14
	echo_func; set_make_vars
14
	begin_target
15 15
	if remaking; then datasrc_make uninstall; fi
16 16
	prep_try; if ! pg_schema_exists; then # uses $schema
17 17
		rethrow
trunk/lib/runscripts/file.pg.sql.run
8 8

  
9 9
export_() # usage: rm=1 .../file.run export_
10 10
{
11
	echo_func; set_make_vars; deferred_check_target_exists
11
	begin_target; deferred_check_target_exists
12 12
	create_schema= to_top_file pg_dump_local \
13 13
--exclude-table='*.*\y"Source"\y*' "$@"
14 14
}
trunk/lib/runscripts/table.run
55 55

  
56 56
load_data()
57 57
{
58
	echo_func; set_make_vars
58
	begin_target
59 59
	if remaking; then in_top_dir rm -f header.csv; fi # remake it
60 60
	datasrc_make_install schema
61 61
	is_view="$is_view" table_make_install ${_remake:+re}install # just the table
......
63 63

  
64 64
trim_table()
65 65
{
66
	echo_func; set_make_vars
66
	begin_target
67 67
	if test "$is_view"; then return 0; fi # do not modify view columns
68 68
	psql <<EOF
69 69
SELECT util.trim('"$table"', '$map_table')
......
72 72

  
73 73
reset_col_names()
74 74
{
75
	echo_func; set_make_vars
75
	begin_target
76 76
	if test "$is_view"; then return 0; fi # do not rename view columns
77 77
	psql <<EOF
78 78
SELECT util.reset_col_names('"$table"', '$map_table')
......
86 86
# collisions may result if the staging table gets messed up (e.g. due to missing
87 87
# input columns in map.csv).
88 88
{
89
	echo_func; set_make_vars
89
	begin_target
90 90
	if test "$is_view"; then return 0; fi # do not rename view columns
91 91
	
92 92
	if remaking; then reset_col_names; fi
......
99 99
EOF
100 100
}
101 101

  
102
test_() { echo_func; set_make_vars; piped_cmd yes|table_make test; }
102
test_() { begin_target; piped_cmd yes|table_make test; }
103 103

  
104 104
mappings()
105 105
{
106
	echo_func; set_make_vars
106
	begin_target
107 107
	prep_try; public_schema_exists || { rethrow; return 0; }; rethrow
108 108
	if remaking; then in_top_dir rm -f map.csv; fi # remake it
109 109
	test_
......
111 111

  
112 112
custom_postprocess() # overridable
113 113
{
114
	echo_func; set_make_vars
114
	begin_target
115 115
	local file="$postprocess_sql"
116 116
	if test -e "$file"; then
117 117
		table_make "$(basename "$file")" # apply renames to SQL statements
......
120 120
}
121 121

  
122 122
mk_derived()
123
{ echo_func; set_make_vars; "$root_dir"/schemas/VegCore/mk_derived; }
123
{ begin_target; "$root_dir"/schemas/VegCore/mk_derived; }
124 124

  
125 125
postprocess()
126 126
{
127
	echo_func; set_make_vars
127
	begin_target
128 128
	kw_params can_test; local can_test="${can_test-1}"
129 129
	if remaking; then trim_table; fi
130 130
	map_table
......
135 135

  
136 136
import()
137 137
{
138
	echo_func; set_make_vars
138
	begin_target
139 139
	self_make load_data
140 140
	postprocess
141 141
}
trunk/lib/runscripts/mysql.table.run
11 11

  
12 12
table.tsv.md5/make()
13 13
{
14
	echo_func; set_make_vars; check_target_exists
14
	begin_target; check_target_exists
15 15
	table_make "$target_filename"
16 16
}
17 17

  
18 18
table.tsv.gz/upload()
19 19
{
20
	echo_func; set_make_vars
20
	begin_target
21 21
	live=1 sync_upload "$target"
22 22
}
23 23

  
24 24
table.tsv.gz/make()
25 25
{
26
	echo_func; set_make_vars
26
	begin_target
27 27
	table_make "$target_filename"
28 28
	if test ! "$test"; then table.tsv.gz/upload; fi
29 29
}
30 30

  
31 31
table.tsv/make() # usage: [remake=1] [limit=...] .../run table.tsv/make
32 32
{
33
	echo_func; set_make_vars; check_target_exists
33
	begin_target; check_target_exists
34 34
	(set_large_table; to_target mysql_export_local) || return
35 35
	remake=1 bg_cmd "$target_filename".gz/make; sleep 6 # wait for log msgs
36 36
	remake=1 "$target_filename".md5/make
......
46 46

  
47 47
archive_prev_versions()
48 48
{
49
	echo_func; set_make_vars
49
	begin_target
50 50
	(mv_glob table.*.tsv "$top_dir"/_archive/)
51 51
}
52 52

  
53 53
func_override import__table_run
54 54
import()
55 55
{
56
	echo_func; set_make_vars
56
	begin_target
57 57
	export_mysql
58 58
	archive_prev_versions
59 59
	self_make import__table_run "$@"
trunk/lib/runscripts/in_datasrc_dir.run
12 12
datasrc_make() # runs make in datasrc dir
13 13
# requires Makefile in datasrc dir with `include ../input.Makefile`
14 14
{
15
	echo_func; set_make_vars
15
	begin_target
16 16
	if remaking; then set -- "${@/%/-remake}"; fi #replace empty str at end (/%)
17 17
	make --directory="$top_dir" "$@"
18 18
}
trunk/lib/runscripts/extract.run
8 8

  
9 9
export_()
10 10
{
11
	echo_func; set_make_vars; deferred_check_target_exists
11
	begin_target; deferred_check_target_exists
12 12
	table="$extract_view" to_top_file pg_export
13 13
}
14 14

  
trunk/lib/sh/resume_import.sh
71 71

  
72 72
^.preamble.sql/make()
73 73
{
74
	echo_func; set_make_vars
74
	begin_target
75 75
	local target="$preamble_file"; check_target_exists
76 76
	to_target sql_preamble <"$top_file"
77 77
}
trunk/lib/sh/db_make.sh
6 6

  
7 7
pg_export_table_to_dir()
8 8
{
9
	echo_func; set_make_vars; check_fake_target_exists
9
	begin_target; check_fake_target_exists
10 10
	local table="$1"; shift; mk_table_esc
11 11
	stdout="$exports_dir/$table.csv" to_file pg_export "$@"
12 12
}

Also available in: Unified diff