From b60a203bd81046de742aab3215afdca135d828d1 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Sun, 25 Mar 2018 00:19:08 +0100 Subject: [PATCH] parallel: Time in --bar is printed as 1d02h03m04s. --- doc/release_new_version | 31 +++++++------------------------ src/niceload | 2 +- src/niceload.pod | 4 ++-- src/parallel | 34 +++++++++++++++++++++++++++++++--- src/parallel.pod | 22 ++++++++++++++++++++-- src/parset.pod | 2 +- src/sql | 2 +- 7 files changed, 63 insertions(+), 34 deletions(-) diff --git a/doc/release_new_version b/doc/release_new_version index f54bf7b4..b7240da9 100644 --- a/doc/release_new_version +++ b/doc/release_new_version @@ -4,6 +4,7 @@ Check that documentation is updated (compare to web): +git grep -E '(alpha|beta) testing' | cat git diff last-release-commit Unmodified beta since last version => production Unmodified alpha since last version => beta @@ -198,37 +199,19 @@ to:parallel@gnu.org, bug-parallel@gnu.org stable-bcc: Jesse Alama -Subject: GNU Parallel 20180322 ('Hawking') released <<[stable]>> +Subject: GNU Parallel 20180422 ('Trèbes') released <<[stable]>> -GNU Parallel 20180322 ('Hawking') <<[stable]>> has been released. It is available for download at: http://ftpmirror.gnu.org/parallel/ +GNU Parallel 20180422 ('Trèbes') <<[stable]>> has been released. It is available for download at: http://ftpmirror.gnu.org/parallel/ <> Quote of the month: -If you aren’t nesting -gnu parallel calls in gnu parallel calls -I don’t know how you have fun. - -- Ernest W. Durbin III EWDurbin@twitter +<<>> + -- New in this release: -* niceload -p can now take multiple pids separated by comma - -* --timeout gives a warning when killing processes - -* --embed now uses the same code for all supported shells - -* --delay can now take arguments like 1h12m07s - -* Parallel. Straight from your command line https://medium.com/@alonisser/parallel-straight-from-your-command-line-feb6db8b6cee - -* GNU Parallel was used in POAP-Parallelized Open Babel & Autodock suite Pipeline https://github.com/inpacdb/POAP - -* Pi Cluster Parallel Script First Fire https://chiefio.wordpress.com/2018/02/23/pi-cluster-parallel-script-first-fire/ - -* How to Restore MySQL Logical Backup at Maximum Speed https://www.percona.com/blog/2018/02/22/restore-mysql-logical-backup-maximum-speed/ - <> @@ -301,13 +284,13 @@ Walk through the tutorial (man parallel_tutorial). Your commandline will love yo When using programs that use GNU Parallel to process data for publication please cite: -O. Tange (2011): GNU Parallel - The Command-Line Power Tool, ;login: The USENIX Magazine, February 2011:42-47. +O. Tange (2018): GNU Parallel 2018, April 2018, https://doi.org/10.5281/zenodo.1146014. If you like GNU Parallel: * Give a demo at your local user group/team/colleagues * Post the intro videos on Reddit/Diaspora*/forums/blogs/ Identi.ca/Google+/Twitter/Facebook/Linkedin/mailing lists -* Get the merchandise https://www.gnu.org/s/parallel/merchandise.html +* Get the merchandise https://gnuparallel.threadless.com/designs/gnu-parallel * Request or write a review for your favourite blog or magazine * Request or build a package for your favourite distribution (if it is not already there) * Invite me for your next conference diff --git a/src/niceload b/src/niceload index 1d3bb2a3..f8245118 100755 --- a/src/niceload +++ b/src/niceload @@ -24,7 +24,7 @@ use strict; use Getopt::Long; $Global::progname="niceload"; -$Global::version = 20180322; +$Global::version = 20180323; Getopt::Long::Configure("bundling","require_order"); get_options_from_array(\@ARGV) || die_usage(); if($opt::version) { diff --git a/src/niceload.pod b/src/niceload.pod index 272f1a93..4a2d952e 100644 --- a/src/niceload.pod +++ b/src/niceload.pod @@ -132,9 +132,9 @@ useful to keep the connection alive. Sets niceness. See B(1). -=item B<-p> I[,I] (alpha testing) +=item B<-p> I[,I] (beta testing) -=item B<--pid> I[,I] (alpha testing) +=item B<--pid> I[,I] (beta testing) Process IDs of processes to suspend. You can specify multiple process IDs with multiple B<-p> I or by separating the PIDs with comma. diff --git a/src/parallel b/src/parallel index f298b0cc..4eba3f67 100755 --- a/src/parallel +++ b/src/parallel @@ -1417,7 +1417,7 @@ sub check_invalid_option_combinations { sub init_globals { # Defaults: - $Global::version = 20180322; + $Global::version = 20180323; $Global::progname = 'parallel'; $Global::infinity = 2**31; $Global::debug = 0; @@ -3025,9 +3025,10 @@ sub progress { replace_placeholders(["\257<\257>"],0,0) : ""; # These chars mess up display in the terminal $arg =~ tr/[\011-\016\033\302-\365]//d; + my $eta_dhms = ::seconds_to_time_units($eta); my $bar_text = - sprintf("%d%% %d:%d=%ds %s", - $pctcomplete*100, $completed, $left, $eta, $arg); + sprintf("%d%% %d:%d=%s %s", + $pctcomplete*100, $completed, $left, $eta_dhms, $arg); my $terminal_width = terminal_columns(); my $s = sprintf("%-${terminal_width}s", substr($bar_text." "x$terminal_width, @@ -4594,6 +4595,33 @@ sub multiply_time_units { return wantarray ? @v : $v[0]; } +sub seconds_to_time_units { + # Convert seconds into ??d??h??m??s + # s=1, m=60, h=3600, d=86400 + # Input: + # $s = int in seconds + # Returns: + # $str = string time units + my $s = shift; + my $str; + my $d = int($s/86400); + $s -= $d * 86400; + my $h = int($s/3600); + $s -= $h * 3600; + my $m = int($s/60); + $s -= $m * 60; + if($d) { + $str = sprintf("%dd%02dh%02dm%02ds",$d,$h,$m,$s); + } elsif($h) { + $str = sprintf("%dh%02dm%02ds",$h,$m,$s); + } elsif($m) { + $str = sprintf("%dm%02ds",$m,$s); + } else { + $str = sprintf("%ds",$s); + } + return $str; +} + { my ($disk_full_fh, $b8193, $error_printed); sub exit_if_disk_full { diff --git a/src/parallel.pod b/src/parallel.pod index 395157ed..56d4a0d7 100644 --- a/src/parallel.pod +++ b/src/parallel.pod @@ -648,7 +648,7 @@ If I is omitted, there is no end of file string. If neither B<-E> nor B<-e> is used, no end of file string is used. -=item B<--embed> (alpha testing) +=item B<--embed> (beta testing) Embed GNU B in a shell script. If you need to distribute your script to someone who does not want to install GNU B you can @@ -2899,6 +2899,24 @@ B<$(date -d "today -$1 days" +%Y%m%d)> will give the dates in YYYYMMDD with B<$1> days subtracted. +=head1 EXAMPLE: Download world map from NASA + +NASA provides tiles to download on earthdata.nasa.gov. Download tiles +for Blue Marble world map and create a 10240x20480 map. + + base=https://map1a.vis.earthdata.nasa.gov/wmts-geo/wmts.cgi + service="SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0" + layer="LAYER=BlueMarble_ShadedRelief_Bathymetry" + set="STYLE=&TILEMATRIXSET=EPSG4326_500m&TILEMATRIX=5" + tile="TILEROW={1}&TILECOL={2}" + format="FORMAT=image%2Fjpeg" + url="$base?$service&$layer&$set&$tile&$format" + + parallel -j0 -q wget "$url" -O {1}_{2}.jpg ::: {0..19} ::: {0..39} + parallel eval convert +append {}_{0..39}.jpg line{}.jpg ::: {0..19} + convert -append line{0..19}.jpg world.jpg + + =head1 EXAMPLE: Copy files as last modified date (ISO8601) with added random digits find . | parallel cp {} '../destdir/{= $a=int(10000*rand); $_=pQ($_); @@ -3995,7 +4013,7 @@ the file at the same time. Name the semaphore to have multiple different semaphores active at the same time: - seq 3 | parallel sem --id mymutex sed -i -e 'i{}' myfile + seq 3 | parallel sem --id mymutex sed -i -e '1i{}' myfile =head1 EXAMPLE: Mutex for a script diff --git a/src/parset.pod b/src/parset.pod index 93e074c3..cedc3669 100644 --- a/src/parset.pod +++ b/src/parset.pod @@ -11,7 +11,7 @@ parset - set shell variables in parallel B I [options for GNU Parallel] -B I [options for GNU Parallel] (beta testing) +B I [options for GNU Parallel] =head1 DESCRIPTION diff --git a/src/sql b/src/sql index a59e8e2b..a91218ed 100755 --- a/src/sql +++ b/src/sql @@ -576,7 +576,7 @@ $Global::Initfile && unlink $Global::Initfile; exit ($err); sub parse_options { - $Global::version = 20180322; + $Global::version = 20180323; $Global::progname = 'sql'; # This must be done first as this may exec myself