ood_core 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa0b9b86a34c8968e6903b35e81a835c9fd6c595
4
- data.tar.gz: 6f6cb53b9d3e4afe6e027b29bf52a77e5b8f146b
3
+ metadata.gz: ec6f497f2c284f0ff82e4523a4deb37eee2cb9e7
4
+ data.tar.gz: 3d8c7a43d9b35fcc5b6e6f29ae58d7f1b5192f71
5
5
  SHA512:
6
- metadata.gz: 133a7548725f986cab0eb69cd36bee91b28d38ff7bda87511d3c88bff582e6f595db3bbe8f1179530cefd9bd71a5385e41120963055bc6dc048a1b9c078e1290
7
- data.tar.gz: e1d76582d175f7f72f442d0d1c6bbe4df7dedb969415970331f726da88d6dceeea6141af7aec922cc27985f2790f082049db8e52194b078ccce413dd8261e7c0
6
+ metadata.gz: a0d8048e7402f17dfd4d9f7504adbe23c142f4a0c6e3100b4ae4ce5feadbd24e9c7430ac19dee00b7e3127f328c3227e5051c4d41abb64025c02a662dcd09c20
7
+ data.tar.gz: 53c70e68d490a1a196d0caab502f0040b7765582e52b39cbd8ca036112c39f6d933fd48f7957d8fd3e63ffdd19a3b492ebc00147396ca5306f4baf8ba411b84b
data/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.1] - 2017-09-08
11
+
12
+ ### Fixed
13
+
14
+ - fix crash when calling `Adapters::Lsf#info(id:)` with "invalid" id
15
+ - optimize `Adapters::Lsf#info_where_owner` by using `bjobs -u $USER` when a single user is specified
16
+
10
17
  ## [0.1.0] - 2017-07-17
11
18
 
12
19
  ### Changed
@@ -77,7 +84,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
84
 
78
85
  - Initial release!
79
86
 
80
- [Unreleased]: https://github.com/OSC/ood_core/compare/v0.1.0...HEAD
87
+ [Unreleased]: https://github.com/OSC/ood_core/compare/v0.1.1...HEAD
88
+ [0.1.1]: https://github.com/OSC/ood_core/compare/v0.1.0...v0.1.1
81
89
  [0.1.0]: https://github.com/OSC/ood_core/compare/v0.0.5...v0.1.0
82
90
  [0.0.5]: https://github.com/OSC/ood_core/compare/v0.0.4...v0.0.5
83
91
  [0.0.4]: https://github.com/OSC/ood_core/compare/v0.0.3...v0.0.4
@@ -19,6 +19,8 @@ module OodCore
19
19
 
20
20
  module Adapters
21
21
  class Lsf < Adapter
22
+ using Refinements::ArrayExtensions
23
+
22
24
  # @api private
23
25
  attr_reader :batch, :helper
24
26
 
@@ -102,6 +104,23 @@ module OodCore
102
104
  raise JobAdapterError, e.message
103
105
  end
104
106
 
107
+ # Retrieve info for all of the owner's jobs from the resource manager
108
+ # @raise [JobAdapterError] if something goes wrong getting job info
109
+ # @return [Array<Info>] information describing submitted jobs
110
+ # @see Adapter#info_where_owner
111
+ def info_where_owner(owner)
112
+ owners = Array.wrap(owner).map(&:to_s)
113
+ if owners.count > 1
114
+ super
115
+ elsif owners.count == 0
116
+ []
117
+ else
118
+ batch.get_jobs_for_user(owners.first).map { |v| info_for_batch_hash(v) }
119
+ end
120
+ rescue Batch::Error => e
121
+ raise JobAdapterError, e.message
122
+ end
123
+
105
124
  # Retrieve job status from resource manager
106
125
  # @param id [#to_s] the id of the job
107
126
  # @raise [JobAdapterError] if something goes wrong getting job status
@@ -30,8 +30,11 @@ class OodCore::Job::Adapters::Lsf::Batch
30
30
  # @raise [Error] if `bjobs` command exited unsuccessfully
31
31
  # @return [Array<Hash>] list of details for jobs
32
32
  def get_jobs
33
- #TODO: split into get_all_jobs, get_my_jobs
34
- args = bjobs_default_args
33
+ get_jobs_for_user("all")
34
+ end
35
+
36
+ def get_jobs_for_user(user)
37
+ args = %W( -u #{user} -a -w -W )
35
38
  parse_bjobs_output(call("bjobs", *args))
36
39
  end
37
40
 
@@ -40,15 +43,10 @@ class OodCore::Job::Adapters::Lsf::Batch
40
43
  # @raise [Error] if `bjobs` command exited unsuccessfully
41
44
  # @return [Hash] details of specified job
42
45
  def get_job(id:)
43
- args = bjobs_default_args
44
- args << id.to_s
46
+ args = %W( -a -w -W #{id.to_s} )
45
47
  parse_bjobs_output(call("bjobs", *args)).first
46
48
  end
47
49
 
48
- def bjobs_default_args
49
- %w( -u all -a -w -W )
50
- end
51
-
52
50
  # status fields available from bjobs
53
51
  def fields
54
52
  %i(id user status queue from_host exec_host name submit_time
@@ -57,9 +55,11 @@ class OodCore::Job::Adapters::Lsf::Batch
57
55
 
58
56
  # helper method
59
57
  def parse_bjobs_output(response)
60
- return [] if response =~ /No job found/ || response.nil?
58
+ return [] if response.nil? || response.strip.empty?
61
59
 
62
60
  lines = response.split("\n")
61
+ raise Error, "bjobs output in different format than expected: #{lines.inspect}" unless lines.count > 1
62
+
63
63
  columns = lines.shift.split
64
64
 
65
65
  validate_bjobs_output_columns(columns)
@@ -1,4 +1,4 @@
1
1
  module OodCore
2
2
  # The current version of {OodCore}
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ood_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Nicklas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-17 00:00:00.000000000 Z
11
+ date: 2017-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ood_support