[ARVADOS] created: 6c40b57dad64bea44694dd5cafd719f0338dd745

git at public.curoverse.com git at public.curoverse.com
Mon Nov 9 14:41:53 EST 2015


        at  6c40b57dad64bea44694dd5cafd719f0338dd745 (commit)


commit 6c40b57dad64bea44694dd5cafd719f0338dd745
Author: Brett Smith <brett at curoverse.com>
Date:   Mon Nov 9 10:13:21 2015 -0500

    6923: Improve Arvados SDK version logging in Crunch run script.
    
    * Use a mechanism that works in a wider variety of containers.  This
      only depends on Python itself and setuptools.  It won't generate
      spurious warnings by calling dpkg-query on Red Hat containers.
    * Don't log the version when we successfully set up the specified
      arvados_sdk_version.  The version will only be '0.1' in this case,
      and that's not helpful.

diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job
index c2ea186..3280f7b 100755
--- a/sdk/cli/bin/crunch-job
+++ b/sdk/cli/bin/crunch-job
@@ -2159,10 +2159,11 @@ if (@ARGV) {
     $Log->("Built Python SDK virtualenv");
   }
 
-  my $pip_bin = "pip";
+  my @pysdk_version_cmd = ("python", "-c",
+    "from pkg_resources import get_distribution as get; print get('arvados-python-client').version");
   if ($venv_built) {
     $Log->("Running in Python SDK virtualenv");
-    $pip_bin = "$venv_dir/bin/pip";
+    @pysdk_version_cmd = ();
     my $orig_argv = join(" ", map { quotemeta($_); } @ARGV);
     @ARGV = ("/bin/sh", "-ec",
              ". \Q$venv_dir/bin/activate\E; exec $orig_argv");
@@ -2171,14 +2172,18 @@ if (@ARGV) {
            "\$PATH. Can't install Python SDK.");
   }
 
-  my $pkgs = `(\Q$pip_bin\E freeze 2>/dev/null | grep arvados) || dpkg-query --show '*arvados*'`;
-  if ($pkgs) {
-    $Log->("Using Arvados SDK:");
-    foreach my $line (split /\n/, $pkgs) {
-      $Log->($line);
+  if (@pysdk_version_cmd) {
+    open(my $pysdk_version_pipe, "-|", @pysdk_version_cmd);
+    my $pysdk_version = <$pysdk_version_pipe>;
+    close($pysdk_version_pipe);
+    if ($? == 0) {
+      chomp($pysdk_version);
+      $Log->("Using Arvados SDK version $pysdk_version");
+    } else {
+      # A lot could've gone wrong here, but pretty much all of it means that
+      # Python won't be able to load the Arvados SDK.
+      $Log->("Warning: Arvados SDK not found");
     }
-  } else {
-    $Log->("Arvados SDK packages not found");
   }
 
   while (my ($sdk_dir, $sdk_envkey) = each(%SDK_ENVVARS)) {

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list