arvados-cli 0.1.20150224142231 → 0.1.20150227192315

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/crunch-job +56 -34
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f48e5cd2ae93dc785d14240c4d586269994f26c7
4
- data.tar.gz: f49bf2da971cf11912f90dfca0c9efd91550d37c
3
+ metadata.gz: fee9adf2c5e05f6708bcac31dde6f59bf2fe0247
4
+ data.tar.gz: 32b1e5d39a1e99b697efdb7c4a46f071c241ef4c
5
5
  SHA512:
6
- metadata.gz: 2ecc3650403a6e87f0c36b2bc629015841703bf24abe3092e6d51ba2551bca8084b365f18cc9f0bd559d0d9e8121875ed00a9c3dceba64af52343c9ac15e1ce2
7
- data.tar.gz: 030f93979b6a408a9b87a91ced431ec0ea10876e0bdc7ed0570241017537dc0a6ea1447ade6e22ff24b50919a9bd86fa8df0b9655f137b1d088f9ecbb8120f5b
6
+ metadata.gz: a53ba2e71b329d22e97800f5aca9bd765f63e4155d17c4ca1883b0939dbc411a29591fa33fee741c04975b9ee4533a3b2ab0bd8814f237e29b549e32f49639e6
7
+ data.tar.gz: aab8e8575cb748acb045b39ad2d24ba0ef503468e3a503c3529fc98eb21ea44334dfc8a22eecc3615649af496b40142ad03661386c3cba4746ea8c7db5ff5966
data/bin/crunch-job CHANGED
@@ -941,7 +941,7 @@ if (!$collated_output) {
941
941
  Log (undef, "Failed to write output collection");
942
942
  }
943
943
  else {
944
- Log(undef, "output hash " . $collated_output);
944
+ Log(undef, "job output $collated_output");
945
945
  $Job->update_attributes('output' => $collated_output);
946
946
  }
947
947
 
@@ -1037,7 +1037,6 @@ sub reapchildren
1037
1037
  if (!$temporary_fail || $Jobstep->{'failures'} >= 3) {
1038
1038
  # Give up on this task, and the whole job
1039
1039
  $main::success = 0;
1040
- $main::please_freeze = 1;
1041
1040
  }
1042
1041
  # Put this task back on the todo queue
1043
1042
  push @jobstep_todo, $jobstepid;
@@ -1056,7 +1055,9 @@ sub reapchildren
1056
1055
  $Jobstep->{'arvados_task'}->{finished_at} = strftime "%Y-%m-%dT%H:%M:%SZ", gmtime($Jobstep->{finishtime});
1057
1056
  $Jobstep->{'arvados_task'}->save;
1058
1057
  process_stderr ($jobstepid, $task_success);
1059
- Log ($jobstepid, "output " . $Jobstep->{'arvados_task'}->{output});
1058
+ Log ($jobstepid, sprintf("task output (%d bytes): %s",
1059
+ length($Jobstep->{'arvados_task'}->{output}),
1060
+ $Jobstep->{'arvados_task'}->{output}));
1060
1061
 
1061
1062
  close $reader{$jobstepid};
1062
1063
  delete $reader{$jobstepid};
@@ -1252,16 +1253,19 @@ sub process_stderr
1252
1253
  sub fetch_block
1253
1254
  {
1254
1255
  my $hash = shift;
1255
- my ($keep, $child_out, $output_block);
1256
-
1257
- my $cmd = "arv-get \Q$hash\E";
1258
- open($keep, '-|', $cmd) or die "fetch_block: $cmd: $!";
1259
- $output_block = '';
1256
+ my $keep;
1257
+ if (!open($keep, "-|", "arv-get", "--retries", retry_count(), $hash)) {
1258
+ Log(undef, "fetch_block run error from arv-get $hash: $!");
1259
+ return undef;
1260
+ }
1261
+ my $output_block = "";
1260
1262
  while (1) {
1261
1263
  my $buf;
1262
1264
  my $bytes = sysread($keep, $buf, 1024 * 1024);
1263
1265
  if (!defined $bytes) {
1264
- die "reading from arv-get: $!";
1266
+ Log(undef, "fetch_block read error from arv-get: $!");
1267
+ $output_block = undef;
1268
+ last;
1265
1269
  } elsif ($bytes == 0) {
1266
1270
  # sysread returns 0 at the end of the pipe.
1267
1271
  last;
@@ -1271,6 +1275,10 @@ sub fetch_block
1271
1275
  }
1272
1276
  }
1273
1277
  close $keep;
1278
+ if ($?) {
1279
+ Log(undef, "fetch_block arv-get exited " . exit_status_s($?));
1280
+ $output_block = undef;
1281
+ }
1274
1282
  return $output_block;
1275
1283
  }
1276
1284
 
@@ -1283,50 +1291,64 @@ sub create_output_collection
1283
1291
  Log (undef, "collate");
1284
1292
 
1285
1293
  my ($child_out, $child_in);
1286
- my $pid = open2($child_out, $child_in, 'python', '-c',
1287
- 'import arvados; ' .
1288
- 'import sys; ' .
1289
- 'print arvados.api()' .
1290
- '.collections()' .
1291
- '.create(body={"manifest_text":sys.stdin.read()})' .
1292
- '.execute()["portable_data_hash"]'
1293
- );
1294
+ my $pid = open2($child_out, $child_in, 'python', '-c', q{
1295
+ import arvados
1296
+ import sys
1297
+ print (arvados.api("v1").collections().
1298
+ create(body={"manifest_text": sys.stdin.read()}).
1299
+ execute(num_retries=int(sys.argv[1]))["portable_data_hash"])
1300
+ }, retry_count());
1294
1301
 
1295
1302
  my $task_idx = -1;
1303
+ my $manifest_size = 0;
1296
1304
  for (@jobstep)
1297
1305
  {
1298
1306
  ++$task_idx;
1299
- next unless exists $_->{'arvados_task'}->{'output'};
1300
1307
  my $output = $_->{'arvados_task'}->{output};
1301
- if ($output !~ /^[0-9a-f]{32}(\+\S+)*$/)
1302
- {
1303
- print $child_in $output;
1304
- }
1305
- elsif (defined (my $outblock = fetch_block ($output)))
1306
- {
1307
- print $child_in $outblock;
1308
+ next if (!defined($output));
1309
+ my $next_write;
1310
+ if ($output =~ /^[0-9a-f]{32}(\+\S+)*$/) {
1311
+ $next_write = fetch_block($output);
1312
+ } else {
1313
+ $next_write = $output;
1308
1314
  }
1309
- else
1310
- {
1315
+ if (defined($next_write)) {
1316
+ if (!defined(syswrite($child_in, $next_write))) {
1317
+ # There's been an error writing. Stop the loop.
1318
+ # We'll log details about the exit code later.
1319
+ last;
1320
+ } else {
1321
+ $manifest_size += length($next_write);
1322
+ }
1323
+ } else {
1311
1324
  my $uuid = $_->{'arvados_task'}->{'uuid'};
1312
1325
  Log (undef, "Error retrieving '$output' output by task $task_idx ($uuid)");
1313
1326
  $main::success = 0;
1314
1327
  }
1315
1328
  }
1316
- $child_in->close;
1329
+ close($child_in);
1330
+ Log(undef, "collated output manifest text to send to API server is $manifest_size bytes with access tokens");
1317
1331
 
1318
1332
  my $joboutput;
1319
1333
  my $s = IO::Select->new($child_out);
1320
1334
  if ($s->can_read(120)) {
1321
- sysread($child_out, $joboutput, 64 * 1024 * 1024);
1322
- chomp($joboutput);
1323
- # TODO: Ensure exit status == 0.
1335
+ sysread($child_out, $joboutput, 1024 * 1024);
1336
+ waitpid($pid, 0);
1337
+ if ($?) {
1338
+ Log(undef, "output collection creation exited " . exit_status_s($?));
1339
+ $joboutput = undef;
1340
+ } else {
1341
+ chomp($joboutput);
1342
+ }
1324
1343
  } else {
1325
1344
  Log (undef, "timed out while creating output collection");
1345
+ foreach my $signal (2, 2, 2, 15, 15, 9) {
1346
+ kill($signal, $pid);
1347
+ last if waitpid($pid, WNOHANG) == -1;
1348
+ sleep(1);
1349
+ }
1326
1350
  }
1327
- # TODO: kill $pid instead of waiting, now that we've decided to
1328
- # ignore further output.
1329
- waitpid($pid, 0);
1351
+ close($child_out);
1330
1352
 
1331
1353
  return $joboutput;
1332
1354
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arvados-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20150224142231
4
+ version: 0.1.20150227192315
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arvados Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-24 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: arvados
@@ -178,7 +178,7 @@ dependencies:
178
178
  - - "<"
179
179
  - !ruby/object:Gem::Version
180
180
  version: 1.0.0
181
- description: Arvados command line tools, git commit 18ddae75beb91b0792ad34a9b4996316715e67b7
181
+ description: Arvados command line tools, git commit 62fea2a463eb0d8c3aef84a56ba84561a196666b
182
182
  email: gem-dev@curoverse.com
183
183
  executables:
184
184
  - arv