Skip to content

Commit

Permalink
[build/deps] Fix field sorting, and add xargs slot
Browse files Browse the repository at this point in the history
Use GNU xargs for --process-slot-var.

csv2html - columns with strftime formats are marked as
'case-insensitive', not 'number'.
  • Loading branch information
Andy C committed Jan 27, 2024
1 parent 3054c92 commit 2f11b8a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .builds/worker6.yml
Expand Up @@ -7,6 +7,8 @@ packages:
- zip
# for SSH debugging!
- vim
# GNU xargs instead of busybox xargs, for --process-slot-var
- findutils
# - time # causes an error, don't need it

secrets:
Expand Down
26 changes: 20 additions & 6 deletions build/deps.sh
Expand Up @@ -630,6 +630,7 @@ maybe-install-wedge() {
# python3 because it's OUTSIDE the container
# Separate columns that could be joined: number of files, total size
my-time-tsv --print-header \
--field xargs_slot \
--field wedge \
--field wedge_HREF \
--field version \
Expand All @@ -644,6 +645,7 @@ maybe-install-wedge() {

set +o errexit
my-time-tsv \
--field "$XARGS_SLOT" \
--field "$name" \
--field "$name.log.txt" \
--field "$version" \
Expand All @@ -667,8 +669,14 @@ dummy-task() {

echo "Building $name $version"

echo "sleep 0.$SECONDS"
sleep "0.$SECONDS"
# random float between 0 and 3
# weirdly we need a seed from bash
# https://stackoverflow.com/questions/4048378/random-numbers-generation-with-awk-in-bash-shell
local secs
secs=$(awk -v seed=$RANDOM 'END { srand(seed); print rand() * 3 }' < /dev/null)

echo "sleep $secs"
sleep $secs

echo 'stdout'
log 'stderr'
Expand All @@ -695,21 +703,22 @@ dummy-task-wrapper() {
# python3 because it's OUTSIDE the container
# Separate columns that could be joined: number of files, total size
my-time-tsv --print-header \
--field xargs_slot \
--field wedge \
--field wedge_HREF \
--field version \
--output $task_file

my-time-tsv \
--field "$XARGS_SLOT" \
--field "$name" \
--field "$name.log.txt" \
--field "$version" \
--append \
--output $task_file \
$0 dummy-task "$@" >$log_file 2>&1 || true

# TODO: if it fails, print FAILED immediately
echo " DONE $(timestamp) $name $version"
echo " DONE $(timestamp) $name $version"
}

html-head() {
Expand Down Expand Up @@ -771,9 +780,10 @@ install-wedge-list() {
fi

# Reads from stdin
xargs "${flags[@]}" -n 3 -- $0 maybe-install-wedge
# Note: --process-slot-var requires GNU xargs! busybox args doesn't have it.
xargs "${flags[@]}" -n 3 --process-slot-var=XARGS_SLOT -- $0 maybe-install-wedge

#xargs "${flags[@]}" -n 3 -- $0 dummy-task-wrapper
#xargs "${flags[@]}" -n 3 --process-slot-var=XARGS_SLOT -- $0 dummy-task-wrapper
}

write-task-report() {
Expand All @@ -792,6 +802,7 @@ start_time float 1 %H:%M:%S
end_time float 1 %H:%M:%S
sys_secs float 1 -
max_rss_KiB integer 0 -
xargs_slot integer 0 -
wedge string 0 -
wedge_HREF string 0 -
version string 0 -
Expand All @@ -814,12 +825,15 @@ fake-py3-libs-wedge() {
local log_file=$WEDGE_LOG_DIR/$name.log.txt

my-time-tsv --print-header \
--field xargs_slot \
--field wedge \
--field wedge_HREF \
--field version \
--output $task_file

# There is no xargs slot!
my-time-tsv \
--field "-1" \
--field "$name" \
--field "$name.log.txt" \
--field "$version" \
Expand Down
6 changes: 5 additions & 1 deletion web/table/csv2html.py
Expand Up @@ -154,6 +154,10 @@ def ColumnPrecision(self, index):
col_name = self.col_names[index]
return self.precision_lookup.get(col_name, 1) # default is arbitrary

def HasStrfTime(self, col_name):
# An explicit - means "no entry"
return self.strftime_lookup.get(col_name, '-') != '-'

def ColumnStrftime(self, index):
col_name = self.col_names[index]
return self.strftime_lookup.get(col_name, '-')
Expand Down Expand Up @@ -277,7 +281,7 @@ def PrintColGroup(col_names, schema):
continue

# CSS class is used for sorting
if schema.IsNumeric(col):
if schema.IsNumeric(col) and not schema.HasStrfTime(col):
css_class = 'number'
else:
css_class = 'case-insensitive'
Expand Down

0 comments on commit 2f11b8a

Please sign in to comment.