[m-rev.] for review: stop gator from copying sources to hosts that already have it

Samrith UONG samuong at gmail.com
Tue Feb 21 12:05:17 AEDT 2006


On 2/20/06, Julien Fischer <juliensf at cs.mu.oz.au> wrote:
>
> On Mon, 20 Feb 2006, Samrith UONG wrote:
>
> > For review by Ralph or Julien.
> >
> > Estimated hours taken: 0.2
> >
> > extras/gator/gator:
> >         Use gzip instead of bzip2, which is more likely to be available
> >         (and for some reason has disappeared off leopard).
> >
>
> Perhaps the script could check for the existence of bzip2 or gzip?
> (It should have reappeared on leopard now - was it actually ever
> installed?)
>

That's not a bad idea.  I've also made sure ssh, ssh-add and ssh-agent
are installed, since these are non-standard.

> >         Be a bit smarter about copying source code to other hosts.
> >         Don't copy it if it already exists on the remote machine.  Also
> >         delete it from the temporary directory once we're done with it
> >         so we don't waste space.
>
> That's fine.  (In the future could you please post diffs as unified diffs,
> with the -u option).
>

Sorry, forgot to do that.  Here's a new unified diff, including the
change mentioned above.

Index: gator
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/gator/gator,v
retrieving revision 1.3
diff -u -r1.3 gator
--- gator	20 Feb 2006 01:14:43 -0000	1.3
+++ gator	21 Feb 2006 01:01:13 -0000
@@ -34,6 +34,33 @@
 #			tausworthe3.m
 #

+compress=`which bzip2`
+suffix="bz2"
+if [ ! -x "$compress" ]
+then
+	compress=`which gzip`
+	suffix="gz"
+	if [ ! -x "$compress" ]
+	then
+		compress=`which compress`
+		suffix="Z"
+		if [ ! -x "$compress" ]
+		then
+			echo "$prog: error: $prog requires compress" >&2
+			exit 1
+		fi
+	fi
+fi
+
+ssh=`which ssh`
+ssh_add=`which ssh-add`
+ssh_agent=`which ssh-agent`
+if [ ! -x "$ssh" -o ! -x "$ssh_add" -o ! -x "$ssh_agent" ]
+then
+	echo "$prog: error: $prog requires OpenSSH" >&2
+	exit 1
+fi
+
 prog=`basename "$0"`
 usage="usage: $prog [-g generation] [-k] [-n count] [-v]"

@@ -96,15 +123,16 @@
 		printf "==> Copying sources from %s:%s\n" "$host" \
 		    "$benchmarks" >&2

-		ssh "$host" '(cd '"$benchmarks"' && tar -cf - .) | bzip2' \
-		    >"$tmp"/benchmarks.tar.bz2
+		ssh "$host" \
+		    '(cd '"$benchmarks"' && tar -cf - .) |'"$compress" \
+		    >"$tmp"/benchmarks.tar."$suffix"
 		break
 	fi

 	i=`expr $i + 1`
 done

-if [ ! -f "$tmp"/benchmarks.tar.bz2 ]
+if [ ! -f "$tmp"/benchmarks.tar."$suffix" ]
 then
 	echo '==> Error: couldn'\''t find benchmark program sources' >&2
 	exit 1
@@ -116,16 +144,23 @@
 	eval "host=\${host$i}"
 	eval "benchmarks=\${benchmarks$i}"

-	printf "==> Copying sources to %s:%s\n" "$host" "$benchmarks" >&2
+	if ssh "$host" [ ! -d "$benchmarks" ]
+	then
+		printf "==> Copying sources to %s:%s\n" "$host" "$benchmarks" \
+		    >&2

-	ssh "$host" rm -rf "$benchmarks"
-	ssh "$host" mkdir "$benchmarks"
-	ssh "$host" 'bzip2 -dc - | (cd '"$benchmarks"' && tar -xf -)' \
-	    <"$tmp"/benchmarks.tar.bz2
+		ssh "$host" rm -rf "$benchmarks"
+		ssh "$host" mkdir "$benchmarks"
+		ssh "$host" \
+		    "$compress"' -dc - | (cd '"$benchmarks"' && tar -xf -)' \
+		    <"$tmp"/benchmarks.tar."$suffix"
+	fi

 	i=`expr $i + 1`
 done

+rm "$tmp"/benchmarks.tar."$suffix"
+
 mmc --make evolve || exit 1

 generation=${generation:-1}
@@ -209,7 +244,7 @@
 		[ $j -lt $num_genotypes ] && echo ',' >>"$phenotypes"

 		# These files can be around 6 MB per generation (uncompressed).
-		bzip2 "$err"
+		"$compress" "$err"

 		j=`expr $j + 1`
 	done
@@ -237,7 +272,8 @@
 	# Print the top $count individuals in the history of the evolution.
 	#

-	printf "==> Current top %d\n" $n >&2
+	count=${count:-10}
+	printf "==> Current top %d\n" $count >&2
 	sort -rnk3 generations/*/ladder | grep -v '[0-9]e-' | head -n $count |
 	    sed -e 's/[ 	]*$//'
 done

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list