arvados-cli 0.1.20140328145218 → 0.1.20140328152103

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ef3ba3f60cc01742c9f52bee400efc3e6705767
4
- data.tar.gz: 245e35a548db02e6221fd57a56c84617e6894e99
3
+ metadata.gz: 272f81448344f725c7753fa314ab58ae28ec24c5
4
+ data.tar.gz: 7a27f7396a43a06a5660fb8c97caa961397a5d34
5
5
  SHA512:
6
- metadata.gz: 1d95f401575b6d180e088515b4233fa79df2c48588f92524714a82301e7a4dac97584bdfeb88ebcc6d579b12784b493c9ef62d7cca8d501d45bd8fa2f8683960
7
- data.tar.gz: a4a31e06ebd662fc54b5fe351b1c857d4c84bdfced15cc12ec260ebff309c483fc04e1b0aa51c4429ff21474071af18950f67bf63c40f172c77d9d90ac242edb
6
+ metadata.gz: 4f27db74f753bc33b61ebba0e549a0e5db2e8f51a4ffd2c4c6dffed69b03c7ff7d4883827411c0f73ec5fe0ab378b580b62a2abbfe398f82d993969d59ba7836
7
+ data.tar.gz: 24828a815587cb7888261add2c88046002358aa9c00830227899c1f0165bbaf33f6eff8413dd8e750bcda7a7fa34895fe0754a23f5754b80b6fb5170831d92f7
@@ -74,6 +74,7 @@ $arvados_api_token = ENV['ARVADOS_API_TOKEN'] or
74
74
  abort "#{$0}: fatal: ARVADOS_API_TOKEN environment variable not set."
75
75
 
76
76
  begin
77
+ require 'arvados'
77
78
  require 'rubygems'
78
79
  require 'json'
79
80
  require 'pp'
@@ -84,7 +85,7 @@ rescue LoadError => l
84
85
  abort <<-EOS
85
86
  #{$0}: fatal: #{l.message}
86
87
  Some runtime dependencies may be missing.
87
- Try: gem install pp google-api-client json trollop
88
+ Try: gem install arvados pp google-api-client json trollop
88
89
  EOS
89
90
  end
90
91
 
@@ -216,6 +217,7 @@ $client ||= Google::APIClient.
216
217
  :application_name => File.split($0).last,
217
218
  :application_version => $application_version.to_s)
218
219
  $arvados = $client.discovered_api('arvados', $arvados_api_version)
220
+ $arv = Arvados.new api_version: 'v1'
219
221
 
220
222
 
221
223
  class PipelineInstance
@@ -424,7 +426,12 @@ class WhRunPipelineInstance
424
426
  moretodo = false
425
427
  @components.each do |cname, c|
426
428
  job = nil
427
-
429
+ # Is the job satisfying this component already known to be
430
+ # finished? (Already meaning "before we query API server about
431
+ # the job's current state")
432
+ c_already_finished = (c[:job] &&
433
+ c[:job][:uuid] &&
434
+ !c[:job][:success].nil?)
428
435
  if !c[:job] and
429
436
  c[:script_parameters].select { |pname, p| p.is_a? Hash and p[:output_of]}.empty?
430
437
  # No job yet associated with this component and is component inputs
@@ -437,7 +444,8 @@ class WhRunPipelineInstance
437
444
  :minimum_script_version => c[:minimum_script_version],
438
445
  :exclude_script_versions => c[:exclude_minimum_script_versions],
439
446
  :nondeterministic => c[:nondeterministic],
440
- :no_reuse => @options[:no_reuse]})
447
+ :no_reuse => @options[:no_reuse],
448
+ :output_is_persistent => c[:output_is_persistent] || false})
441
449
  if job
442
450
  debuglog "component #{cname} new job #{job[:uuid]}"
443
451
  c[:job] = job
@@ -450,7 +458,7 @@ class WhRunPipelineInstance
450
458
  if (c[:job][:running] or
451
459
  not (c[:job][:finished_at] or c[:job][:cancelled_at]))
452
460
  # Job is running so update copy of job record
453
- c[:job] = JobCache.get(c[:job][:uuid])
461
+ c[:job] = JobCache.get(c[:job][:uuid])
454
462
  end
455
463
 
456
464
  if c[:job][:success]
@@ -465,6 +473,43 @@ class WhRunPipelineInstance
465
473
  end
466
474
  end
467
475
  end
476
+ unless c_already_finished
477
+ # This is my first time discovering that the job
478
+ # succeeded. (At the top of this loop, I was still
479
+ # waiting for it to finish.)
480
+ if c[:output_is_persistent]
481
+ # I need to make sure a resources/wants link is in
482
+ # place to protect the output from garbage
483
+ # collection. (Normally Crunch does this for me, but
484
+ # here I might be reusing the output of someone else's
485
+ # job and I need to make sure it's understood that the
486
+ # output is valuable to me, too.)
487
+ wanted = c[:job][:output]
488
+ debuglog "checking for existing persistence link for #{wanted}"
489
+ @my_user_uuid ||= $arv.user.current[:uuid]
490
+ links = $arv.link.list(limit: 1,
491
+ filters:
492
+ [%w(link_class = resources),
493
+ %w(name = wants),
494
+ %w(tail_uuid =) + [@my_user_uuid],
495
+ %w(head_uuid =) + [wanted]
496
+ ])[:items]
497
+ if links.any?
498
+ debuglog "link already exists, uuid #{links.first[:uuid]}"
499
+ else
500
+ newlink = $arv.link.create link: \
501
+ {
502
+ link_class: 'resources',
503
+ name: 'wants',
504
+ tail_kind: 'arvados#user',
505
+ tail_uuid: @my_user_uuid,
506
+ head_kind: 'arvados#collection',
507
+ head_uuid: wanted
508
+ }
509
+ debuglog "added link, uuid #{newlink[:uuid]}"
510
+ end
511
+ end
512
+ end
468
513
  elsif c[:job][:running] ||
469
514
  (!c[:job][:started_at] && !c[:job][:cancelled_at])
470
515
  # Job is still running
@@ -507,7 +552,7 @@ class WhRunPipelineInstance
507
552
  end
508
553
  end
509
554
  end
510
-
555
+
511
556
  if ended == @components.length or failed > 0
512
557
  @instance[:active] = false
513
558
  @instance[:success] = (succeeded == @components.length)
data/bin/crunch-job CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/perl
2
- # -*- mode: perl; perl-indent-level: 2; -*-
2
+ # -*- mode: perl; perl-indent-level: 2; indent-tabs-mode: nil; -*-
3
3
 
4
4
  =head1 NAME
5
5
 
@@ -766,6 +766,16 @@ if ($Job->{'output'})
766
766
  'uuid' => $Job->{'output'},
767
767
  'manifest_text' => $manifest_text,
768
768
  });
769
+ if ($Job->{'output_is_persistent'}) {
770
+ $arv->{'links'}->{'create'}->execute('link' => {
771
+ 'tail_kind' => 'arvados#user',
772
+ 'tail_uuid' => $User->{'uuid'},
773
+ 'head_kind' => 'arvados#collection',
774
+ 'head_uuid' => $Job->{'output'},
775
+ 'link_class' => 'resources',
776
+ 'name' => 'wants',
777
+ });
778
+ }
769
779
  };
770
780
  if ($@) {
771
781
  Log (undef, "Failed to register output manifest: $@");
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arvados-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20140328145218
4
+ version: 0.1.20140328152103
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arvados Authors
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: arvados
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: google-api-client
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -132,7 +146,7 @@ dependencies:
132
146
  - - "~>"
133
147
  - !ruby/object:Gem::Version
134
148
  version: '0.8'
135
- description: This is the Arvados SDK CLI gem, git revision c6043720763ecad450078728e2a3c815c51148bc
149
+ description: This is the Arvados SDK CLI gem, git revision 64b24877bdb4b35938e8b691463b78073a4fd31d
136
150
  email: gem-dev@curoverse.com
137
151
  executables:
138
152
  - arv