arvados-cli 0.1.20140923135850 → 0.1.20140926103149

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: acfc7601dd83c33e9e36b8233f044d63d0e02cdd
4
- data.tar.gz: b1d2648d61458d5444c60260b74c9cc8ff3eadc8
3
+ metadata.gz: 26facb80c3af8730d8fe511b7188731d52b9053a
4
+ data.tar.gz: 676006432891b6a1d4f095e477c32e0446b59b58
5
5
  SHA512:
6
- metadata.gz: 19e0072bee82406f8976bdf8933efb88d14eb3f1ebbb0b2bc422341efc19eddeea5121487d9ff562a89fe53fd561fbe295ebe339d1537281474a69b3dedbae74
7
- data.tar.gz: 8b41780591b24138a9bd09fc69b3f25f85565938646a32af0746caed8ac4491acbba6023c507f3ab884723ed2ac65353a4058bfb3a0f5e6e5fe70b03530c9eee
6
+ metadata.gz: a10a16cdf53c89ec339d1710c45560d405000f26fa49d318f3e9fb5c90432ba03fe30e241b73b2b9d984f0994829025f672a14ff9bdedd530db409a29a8a53d9
7
+ data.tar.gz: 7009db6afc4c040b60ba0a7a87ae8d9d7ddc861ed331d75e2d35f10384c2d25b5ade9296213f5630fc6f57e2564de427d5c321173eca9361572291e27fce1bfa
@@ -509,7 +509,7 @@ class WhRunPipelineInstance
509
509
  # the job's current state")
510
510
  c_already_finished = (c[:job] &&
511
511
  c[:job][:uuid] &&
512
- !c[:job][:success].nil?)
512
+ ["Complete", "Failed", "Cancelled"].include?(c[:job][:state]))
513
513
  if !c[:job] and
514
514
  c[:script_parameters].select { |pname, p| p.is_a? Hash and p[:output_of]}.empty?
515
515
  # No job yet associated with this component and is component inputs
@@ -526,6 +526,7 @@ class WhRunPipelineInstance
526
526
  :owner_uuid => owner_uuid,
527
527
  :is_locked_by_uuid => (@options[:run_jobs_here] ? owner_uuid : nil),
528
528
  :submit_id => my_submit_id,
529
+ :state => (if @options[:run_jobs_here] then "Running" else "Queued" end)
529
530
  }, {
530
531
  # This is the right place to put these attributes when
531
532
  # dealing with new API servers.
@@ -546,7 +547,7 @@ class WhRunPipelineInstance
546
547
  end
547
548
  end
548
549
 
549
- if c[:job] and c[:run_in_process] and c[:job][:success].nil?
550
+ if c[:job] and c[:run_in_process] and not ["Complete", "Failed", "Cancelled"].include? c[:job][:state]
550
551
  report_status
551
552
  begin
552
553
  require 'open3'
@@ -575,21 +576,18 @@ class WhRunPipelineInstance
575
576
  debuglog "Interrupted (#{e}). Failing job.", 0
576
577
  $arv.job.update(uuid: c[:job][:uuid],
577
578
  job: {
578
- finished_at: Time.now,
579
- running: false,
580
- success: false
579
+ state: "Failed"
581
580
  })
582
581
  end
583
582
  end
584
583
 
585
584
  if c[:job] and c[:job][:uuid]
586
- if (c[:job][:running] or
587
- not (c[:job][:finished_at] or c[:job][:cancelled_at]))
588
- # Job is running so update copy of job record
585
+ if ["Running", "Queued"].include?(c[:job][:state])
586
+ # Job is running (or may be soon) so update copy of job record
589
587
  c[:job] = JobCache.get(c[:job][:uuid])
590
588
  end
591
589
 
592
- if c[:job][:success]
590
+ if c[:job][:state] == "Complete"
593
591
  # Populate script_parameters of other components waiting for
594
592
  # this job
595
593
  @components.each do |c2name, c2|
@@ -654,12 +652,14 @@ class WhRunPipelineInstance
654
652
  end
655
653
  end
656
654
  end
657
- elsif c[:job][:running] ||
658
- (!c[:job][:started_at] && !c[:job][:cancelled_at])
655
+ elsif c[:job][:state] == "Running"
659
656
  # Job is still running
660
657
  moretodo = true
661
- elsif c[:job][:cancelled_at]
658
+ elsif c[:job][:state] == "Cancelled"
662
659
  debuglog "component #{cname} job #{c[:job][:uuid]} cancelled."
660
+ moretodo = false
661
+ elsif c[:job][:state] == "Failed"
662
+ moretodo = false
663
663
  end
664
664
  end
665
665
  end
@@ -686,21 +686,12 @@ class WhRunPipelineInstance
686
686
  end
687
687
  end
688
688
 
689
- ended = 0
690
- succeeded = 0
691
- failed = 0
692
- @components.each do |cname, c|
693
- if c[:job]
694
- if c[:job][:finished_at] or c[:job][:cancelled_at] or (c[:job][:running] == false and c[:job][:success] == false)
695
- ended += 1
696
- if c[:job][:success] == true
697
- succeeded += 1
698
- elsif c[:job][:success] == false or c[:job][:cancelled_at]
699
- failed += 1
700
- end
701
- end
702
- end
703
- end
689
+ c_in_state = @components.values.group_by { |c|
690
+ c[:job] and c[:job][:state]
691
+ }
692
+ succeeded = c_in_state["Complete"].count
693
+ failed = c_in_state["Failed"].count + c_in_state["Cancelled"].count
694
+ ended = succeeded + failed
704
695
 
705
696
  success = (succeeded == @components.length)
706
697
 
@@ -766,20 +757,18 @@ class WhRunPipelineInstance
766
757
  @components.each do |cname, c|
767
758
  jstatus = if !c[:job]
768
759
  "-"
769
- elsif c[:job][:running]
770
- "#{c[:job][:tasks_summary].inspect}"
771
- elsif c[:job][:success]
772
- c[:job][:output]
773
- elsif c[:job][:cancelled_at]
774
- "cancelled #{c[:job][:cancelled_at]}"
775
- elsif c[:job][:finished_at]
776
- "failed #{c[:job][:finished_at]}"
777
- elsif c[:job][:started_at]
778
- "started #{c[:job][:started_at]}"
779
- elsif c[:job][:is_locked_by_uuid]
780
- "starting #{c[:job][:started_at]}"
781
- else
782
- "queued #{c[:job][:created_at]}"
760
+ else case c[:job][:state]
761
+ when "Running"
762
+ "#{c[:job][:tasks_summary].inspect}"
763
+ when "Complete"
764
+ c[:job][:output]
765
+ when "Cancelled"
766
+ "cancelled #{c[:job][:cancelled_at]}"
767
+ when "Failed"
768
+ "failed #{c[:job][:finished_at]}"
769
+ when "Queued"
770
+ "queued #{c[:job][:created_at]}"
771
+ end
783
772
  end
784
773
  f.puts "#{cname.to_s.ljust namewidth} #{c[:job] ? c[:job][:uuid] : '-'.ljust(27)} #{jstatus}"
785
774
  end
data/bin/crunch-job CHANGED
@@ -161,6 +161,10 @@ if ($job_has_uuid)
161
161
  Log(undef, "Job is locked by " . $Job->{'is_locked_by_uuid'});
162
162
  exit EX_TEMPFAIL;
163
163
  }
164
+ if ($Job->{'state'} ne 'Queued') {
165
+ Log(undef, "Job state is " . $Job->{'state'} . ", but I can only start queued jobs.");
166
+ exit EX_TEMPFAIL;
167
+ }
164
168
  if ($Job->{'success'} ne undef) {
165
169
  Log(undef, "Job 'success' flag (" . $Job->{'success'} . ") is not null");
166
170
  exit EX_TEMPFAIL;
@@ -287,9 +291,7 @@ if ($job_has_uuid)
287
291
  Log(undef, "Error while updating / locking job, exiting ".EX_TEMPFAIL);
288
292
  exit EX_TEMPFAIL;
289
293
  }
290
- $Job->update_attributes('started_at' => scalar gmtime,
291
- 'running' => 1,
292
- 'success' => undef,
294
+ $Job->update_attributes('state' => 'Running',
293
295
  'tasks_summary' => { 'failed' => 0,
294
296
  'todo' => 1,
295
297
  'running' => 0,
@@ -876,12 +878,14 @@ Log (undef, "finish");
876
878
  save_meta();
877
879
 
878
880
  if ($job_has_uuid) {
879
- $Job->update_attributes('running' => 0,
880
- 'success' => $collated_output && $main::success,
881
- 'finished_at' => scalar gmtime)
881
+ if ($collated_output && $main::success) {
882
+ $Job->update_attributes('state' => 'Complete')
883
+ } else {
884
+ $Job->update_attributes('state' => 'Failed')
885
+ }
882
886
  }
883
887
 
884
- exit ($Job->{'success'} ? 1 : 0);
888
+ exit ($Job->{'state'} != 'Complete' ? 1 : 0);
885
889
 
886
890
 
887
891
 
@@ -1033,12 +1037,16 @@ sub check_refresh_wanted
1033
1037
  my $Job2 = $arv->{'jobs'}->{'get'}->execute('uuid' => $jobspec);
1034
1038
  for my $attr ('cancelled_at',
1035
1039
  'cancelled_by_user_uuid',
1036
- 'cancelled_by_client_uuid') {
1040
+ 'cancelled_by_client_uuid',
1041
+ 'state') {
1037
1042
  $Job->{$attr} = $Job2->{$attr};
1038
1043
  }
1039
- if ($Job->{'cancelled_at'}) {
1040
- Log (undef, "Job cancelled at " . $Job->{cancelled_at} .
1041
- " by user " . $Job->{cancelled_by_user_uuid});
1044
+ if ($Job->{'state'} ne "Running") {
1045
+ if ($Job->{'state'} eq "Cancelled") {
1046
+ Log (undef, "Job cancelled at " . $Job->{'cancelled_at'} . " by user " . $Job->{'cancelled_by_user_uuid'});
1047
+ } else {
1048
+ Log (undef, "Job state unexpectedly changed to " . $Job->{'state'});
1049
+ }
1042
1050
  $main::success = 0;
1043
1051
  $main::please_freeze = 1;
1044
1052
  }
@@ -1336,9 +1344,11 @@ sub croak
1336
1344
  sub cleanup
1337
1345
  {
1338
1346
  return if !$job_has_uuid;
1339
- $Job->update_attributes('running' => 0,
1340
- 'success' => 0,
1341
- 'finished_at' => scalar gmtime);
1347
+ if ($Job->{'state'} eq 'Cancelled') {
1348
+ $Job->update_attributes('finished_at' => scalar gmtime);
1349
+ } else {
1350
+ $Job->update_attributes('state' => 'Failed');
1351
+ }
1342
1352
  }
1343
1353
 
1344
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.20140923135850
4
+ version: 0.1.20140926103149
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arvados Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-23 00:00:00.000000000 Z
11
+ date: 2014-09-26 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 59607e4635868117051d77aa4a84fa9f689c52e7
181
+ description: Arvados command line tools, git commit 2861857a87d4c40924f783862ee09e91cec0b96f
182
182
  email: gem-dev@curoverse.com
183
183
  executables:
184
184
  - arv