pbs 2.1.0 → 2.2.0

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: 76a57e8e24fb6fba02e681f2d9dd2ada214d09f3
4
- data.tar.gz: 04edfbd44cc1fbf2558f0c26ce6677e8d4fa8fef
3
+ metadata.gz: 5aa7c0ba8a56376aab5103ebb4eebf0d16f52119
4
+ data.tar.gz: 753cc32ca3fe38b919016f055e8c583e253d4285
5
5
  SHA512:
6
- metadata.gz: b5a98efcdb34c5679c078fbf6a151d9babb108ff3090b5517295b5d0a8c8f6f8676bbed1c2808c5e0369cb308f6b3013f87289822ae35e539509df9f8191583d
7
- data.tar.gz: 0f32ca27b52b5afc182df01cb9a7d23581bbe69cb2e28eb096426b5a49f6d0db20209fd15d3c9af9ed74c15d2736f1b0557eab39d29b8c964c62688f95b8442d
6
+ metadata.gz: f19d0e62442fe802557dd8ddbef4e002f1e593739004e3bdd5147e5c1bedde46a522a4da560388b3cc087df4e7bbfc3a2595f096438e3d2234143a0fdebde346
7
+ data.tar.gz: 83743aa12d21569bb311c34aa9ef86f02804b309ee4a0e1ed1f25a1e7e36f0296ec85188ca423ae4e40a893b7ba279c7fc6a193215b04451eef410e85f8b7f23
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,9 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.2
5
+ before_install: gem install bundler -v 1.7.8
6
+ notifications:
7
+ email:
8
+ on_success: never
9
+ on_failure: always
@@ -1,41 +1,59 @@
1
- ## Unreleased
1
+ # Changelog
2
2
 
3
- ## 2.1.0 (2017-06-02)
3
+ All notable changes to this project will be documented in this file.
4
4
 
5
- Features:
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
7
 
7
- - added helpful scripts to setup and launch console
8
- - provide support to get status of selected jobs on batch server
8
+ ## [Unreleased]
9
9
 
10
- ## 2.0.4 (2017-03-28)
10
+ ## [2.2.0] - 2018-04-20
11
+ ### Added
12
+ - Added a `Batch#submit` method to submit directly with a `qsub` call.
13
+ [#29](https://github.com/OSC/pbs-ruby/issues/29)
14
+ - Add Travis CI support.
11
15
 
12
- Bugfixes:
16
+ ### Changed
17
+ - Changed the `CHANGELOG.md` formatting.
18
+ - Updated date in `LICENSE.txt`.
13
19
 
14
- - support reservation id for submitting job with `qsub`
15
- - added workaround for users who specify queue in batch script
20
+ ### Deprecated
21
+ - Deprecating the old submit methods `Batch#submit_string` and
22
+ `Batch#submit_script`.
16
23
 
17
- ## 2.0.3 (2016-11-04)
24
+ ## [2.1.0] - 2017-06-02
25
+ ### Added
26
+ - Added helpful scripts to setup and launch console.
27
+ - Provide support to get status of selected jobs on batch server.
18
28
 
19
- Bugfixes:
29
+ ## [2.0.4] - 2017-03-28
30
+ ### Fixed
31
+ - Support reservation id for submitting job with `qsub`.
32
+ - Added workaround for users who specify queue in batch script.
20
33
 
21
- - better support `qsub` CLI arguments
34
+ ## [2.0.3] - 2016-11-04
35
+ ### Fixed
36
+ - Better support `qsub` CLI arguments.
22
37
 
23
- ## 2.0.2 (2016-08-17)
38
+ ## [2.0.2] - 2016-08-17
39
+ ### Fixed
40
+ - Fixes Ruby version requirement to 2.2.0+.
24
41
 
25
- Bugfixes:
42
+ ### Removed
43
+ - Removes unused prefix directory option.
26
44
 
27
- - fixes Ruby version requirement to 2.2.0+
28
- - removes unused prefix directory option
45
+ ## [2.0.1] - 2016-08-10
46
+ ### Changed
47
+ - Batch object can be initialized with lib/bin directories.
29
48
 
30
- ## 2.0.1 (2016-08-10)
49
+ ## 2.0.0 - 2016-08-05
50
+ ### Added
51
+ - Initial release of 2.0.0!
31
52
 
32
- Features:
33
-
34
- - batch object can be initialized with lib/bin directories
35
-
36
- ## 2.0.0 (2016-08-05)
37
-
38
- Features:
39
-
40
- - initial release of v2.0.0
41
- - added a changelog
53
+ [Unreleased]: https://github.com/OSC/pbs-ruby/compare/v2.2.0...HEAD
54
+ [2.2.0]: https://github.com/OSC/pbs-ruby/compare/v2.1.0...v2.2.0
55
+ [2.1.0]: https://github.com/OSC/pbs-ruby/compare/v2.0.4...v2.1.0
56
+ [2.0.4]: https://github.com/OSC/pbs-ruby/compare/v2.0.3...v2.0.4
57
+ [2.0.3]: https://github.com/OSC/pbs-ruby/compare/v2.0.2...v2.0.3
58
+ [2.0.2]: https://github.com/OSC/pbs-ruby/compare/v2.0.1...v2.0.2
59
+ [2.0.1]: https://github.com/OSC/pbs-ruby/compare/v2.0.0...v2.0.1
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2016 Ohio Supercomputer Center
1
+ Copyright (c) 2014-2018 Ohio Supercomputer Center
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # PBS Ruby
2
2
 
3
+ [![Build Status](https://travis-ci.org/OSC/pbs-ruby.svg?branch=master)](https://travis-ci.org/OSC/pbs-ruby)
4
+ ![GitHub Release](https://img.shields.io/github/release/osc/pbs-ruby.svg)
5
+ [![GitHub License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)
6
+
3
7
  ## Description
4
8
 
5
9
  Ruby wrapper for the Torque C Library utilizing Ruby-FFI. This has been
@@ -239,3 +243,26 @@ job_id = b.submit_script("/path/to/script", headers: headers, resources: resourc
239
243
  # Get job info
240
244
  b.get_job(job_id)
241
245
  ```
246
+
247
+ ## Development
248
+
249
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
250
+ `bundle exec rspec spec` to run the tests. You can also run `bin/console` for
251
+ an interactive prompt that will allow you to experiment.
252
+
253
+ To install this gem onto your local machine, run `bundle exec rake install`. To
254
+ release a new version, update and commit the version number in `version.rb`,
255
+ and then run `bundle exec rake release`, which will create a git tag for the
256
+ version, push git commits and tags, and push the `.gem` file to
257
+ [rubygems.org](https://rubygems.org).
258
+
259
+ ## Contributing
260
+
261
+ Bug reports and pull requests are welcome on GitHub at
262
+ https://github.com/OSC/pbs-ruby.
263
+
264
+ ## License
265
+
266
+ The gem is available as open source under the terms of the [MIT License].
267
+
268
+ [MIT License]: https://opensource.org/licenses/MIT
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -319,6 +319,7 @@ module PBS
319
319
  # @param envvars [Hash] pbs environment variables
320
320
  # @param qsub [Boolean] whether use library or binary for submission
321
321
  # @return [String] the id of the job that was created
322
+ # @deprecated Use {#submit} instead.
322
323
  def submit_script(script, queue: nil, headers: {}, resources: {}, envvars: {}, qsub: true)
323
324
  send(qsub ? :qsub_submit : :pbs_submit, script.to_s, queue.to_s, headers, resources, envvars)
324
325
  end
@@ -327,6 +328,7 @@ module PBS
327
328
  # @param string [#to_s] script as a string
328
329
  # @param (see #submit_script)
329
330
  # @return [String] the id of the job that was created
331
+ # @deprecated Use {#submit} instead.
330
332
  def submit_string(string, **kwargs)
331
333
  Tempfile.open('qsub.') do |f|
332
334
  f.write string.to_s
@@ -335,6 +337,17 @@ module PBS
335
337
  end
336
338
  end
337
339
 
340
+ # Submit a script expanded as a string to the batch server
341
+ # @param content [#to_s] script as a string
342
+ # @param args [Array<#to_s>] arguments passed to `qsub` command
343
+ # @param env [Hash{#to_s => #to_s}] environment variables set
344
+ # @param chdir [#to_s, nil] working directory where `qsub` is called from
345
+ # @raise [Error] if `qsub` command exited unsuccessfully
346
+ # @return [String] the id of the job that was created
347
+ def submit(content, args: [], env: {}, chdir: nil)
348
+ call(:qsub, *args, env: env, stdin: content, chdir: chdir).strip
349
+ end
350
+
338
351
  private
339
352
  # Submit a script using Torque library
340
353
  def pbs_submit(script, queue, headers, resources, envvars)
@@ -428,5 +441,19 @@ module PBS
428
441
  raise PBS::Error, e unless s.success?
429
442
  o.chomp
430
443
  end
444
+
445
+ # Call a forked PBS command for a given host
446
+ def call(cmd, *args, env: {}, stdin: "", chdir: nil)
447
+ cmd = bin.join(cmd.to_s).to_s
448
+ args = args.map(&:to_s)
449
+ env = env.to_h.each_with_object({}) {|(k,v), h| h[k.to_s] = v.to_s}.merge({
450
+ "PBS_DEFAULT" => host,
451
+ "LD_LIBRARY_PATH" => %{#{lib}:#{ENV["LD_LIBRARY_PATH"]}}
452
+ })
453
+ stdin = stdin.to_s
454
+ chdir = chdir && chdir.to_s
455
+ o, e, s = Open3.capture3(env, cmd, *args, stdin_data: stdin, chdir: chdir)
456
+ s.success? ? o : raise(PBS::Error, e)
457
+ end
431
458
  end
432
459
  end
@@ -1,4 +1,4 @@
1
1
  module PBS
2
2
  # The current version of PBS
3
- VERSION = "2.1.0"
3
+ VERSION = "2.2.0"
4
4
  end
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "bundler", "~> 1.7"
26
26
  spec.add_development_dependency "rake", "~> 10.0"
27
27
  spec.add_development_dependency "pry", "~> 0.10"
28
+ spec.add_development_dependency "rspec", "~> 3.7"
28
29
  end
@@ -0,0 +1,136 @@
1
+ describe PBS::Batch do
2
+ subject(:batch) { described_class.new(host: host, lib: lib, bin: bin) }
3
+ let(:host) { double(to_s: "HOST") }
4
+ let(:bin) { double(to_s: "BIN") }
5
+ let(:lib) { double(to_s: "LIB") }
6
+
7
+ it { is_expected.to respond_to(:host) }
8
+ it { is_expected.to respond_to(:bin) }
9
+ it { is_expected.to respond_to(:lib) }
10
+ it { is_expected.to respond_to(:submit) }
11
+
12
+ describe "#host" do
13
+ it { expect(subject.host).to eq("HOST") }
14
+ end
15
+
16
+ describe "#bin" do
17
+ it { expect(subject.bin).to eq(Pathname.new("BIN")) }
18
+ end
19
+
20
+ describe "#lib" do
21
+ it { expect(subject.lib).to eq(Pathname.new("LIB")) }
22
+ end
23
+
24
+ describe "#submit" do
25
+ subject { batch.submit(content, args: args, env: env, chdir: chdir) }
26
+ let(:content) { double(to_s: "CONTENT") }
27
+ let(:args) { [] }
28
+ let(:env) { {} }
29
+ let(:chdir) { nil }
30
+
31
+ it "calls the qsub command" do
32
+ expect(Open3).to receive(:capture3).with(
33
+ {
34
+ "PBS_DEFAULT" => "HOST",
35
+ "LD_LIBRARY_PATH" => %{LIB:#{ENV["LD_LIBRARY_PATH"]}}
36
+ },
37
+ "BIN/qsub",
38
+ stdin_data: "CONTENT",
39
+ chdir: nil
40
+ ) do
41
+ [ "STDOUT", "STDERR", double(success?: true) ]
42
+ end
43
+
44
+ is_expected.to eq("STDOUT")
45
+ end
46
+
47
+ it "strips away whitespace from qsub output" do
48
+ expect(Open3).to receive(:capture3).with(any_args) do
49
+ [ "\t \nSTDOUT \n\t ", "STDERR", double(success?: true) ]
50
+ end
51
+
52
+ is_expected.to eq("STDOUT")
53
+ end
54
+
55
+ context "when environment variable specified" do
56
+ let(:env) { { double(to_s: "A") => double(to_s: "B") } }
57
+
58
+ it "calls the qsub command with that env var" do
59
+ expect(Open3).to receive(:capture3).with(
60
+ {
61
+ "PBS_DEFAULT" => "HOST",
62
+ "LD_LIBRARY_PATH" => %{LIB:#{ENV["LD_LIBRARY_PATH"]}},
63
+ "A" => "B"
64
+ },
65
+ "BIN/qsub",
66
+ stdin_data: "CONTENT",
67
+ chdir: nil
68
+ ) do
69
+ [ "STDOUT", "STDERR", double(success?: true) ]
70
+ end
71
+
72
+ is_expected.to eq("STDOUT")
73
+ end
74
+ end
75
+
76
+ context "when command line argument specified" do
77
+ let(:args) { [double(to_s: "a"), double(to_s: "b")] }
78
+
79
+ it "calls the qsub command with those arguments" do
80
+ expect(Open3).to receive(:capture3).with(
81
+ {
82
+ "PBS_DEFAULT" => "HOST",
83
+ "LD_LIBRARY_PATH" => %{LIB:#{ENV["LD_LIBRARY_PATH"]}}
84
+ },
85
+ "BIN/qsub",
86
+ "a",
87
+ "b",
88
+ stdin_data: "CONTENT",
89
+ chdir: nil
90
+ ) do
91
+ [ "STDOUT", "STDERR", double(success?: true) ]
92
+ end
93
+
94
+ is_expected.to eq("STDOUT")
95
+ end
96
+ end
97
+
98
+ context "when workding directory specified" do
99
+ let(:chdir) { double(to_s: "WORK_DIR") }
100
+
101
+ it "calls the qsub command in that working directory" do
102
+ expect(Open3).to receive(:capture3).with(
103
+ {
104
+ "PBS_DEFAULT" => "HOST",
105
+ "LD_LIBRARY_PATH" => %{LIB:#{ENV["LD_LIBRARY_PATH"]}}
106
+ },
107
+ "BIN/qsub",
108
+ stdin_data: "CONTENT",
109
+ chdir: "WORK_DIR"
110
+ ) do
111
+ [ "STDOUT", "STDERR", double(success?: true) ]
112
+ end
113
+
114
+ is_expected.to eq("STDOUT")
115
+ end
116
+ end
117
+
118
+ context "when qsub returns unsuccessfully" do
119
+ it "raises an error with stderr as message" do
120
+ expect(Open3).to receive(:capture3).with(
121
+ {
122
+ "PBS_DEFAULT" => "HOST",
123
+ "LD_LIBRARY_PATH" => %{LIB:#{ENV["LD_LIBRARY_PATH"]}}
124
+ },
125
+ "BIN/qsub",
126
+ stdin_data: "CONTENT",
127
+ chdir: nil
128
+ ) do
129
+ [ "STDOUT", "STDERR", double(success?: false) ]
130
+ end
131
+
132
+ expect { subject }.to raise_error(PBS::Error, "STDERR")
133
+ end
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,102 @@
1
+ require "pbs"
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
+ RSpec.configure do |config|
19
+ # rspec-expectations config goes here. You can use an alternate
20
+ # assertion/expectation library such as wrong or the stdlib/minitest
21
+ # assertions if you prefer.
22
+ config.expect_with :rspec do |expectations|
23
+ # This option will default to `true` in RSpec 4. It makes the `description`
24
+ # and `failure_message` of custom matchers include text for helper methods
25
+ # defined using `chain`, e.g.:
26
+ # be_bigger_than(2).and_smaller_than(4).description
27
+ # # => "be bigger than 2 and smaller than 4"
28
+ # ...rather than:
29
+ # # => "be bigger than 2"
30
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
+ end
32
+
33
+ # rspec-mocks config goes here. You can use an alternate test double
34
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
35
+ config.mock_with :rspec do |mocks|
36
+ # Prevents you from mocking or stubbing a method that does not exist on
37
+ # a real object. This is generally recommended, and will default to
38
+ # `true` in RSpec 4.
39
+ mocks.verify_partial_doubles = true
40
+ end
41
+
42
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
43
+ # have no way to turn it off -- the option exists only for backwards
44
+ # compatibility in RSpec 3). It causes shared context metadata to be
45
+ # inherited by the metadata hash of host groups and examples, rather than
46
+ # triggering implicit auto-inclusion in groups with matching metadata.
47
+ config.shared_context_metadata_behavior = :apply_to_host_groups
48
+
49
+ # The settings below are suggested to provide a good initial experience
50
+ # with RSpec, but feel free to customize to your heart's content.
51
+ =begin
52
+ # This allows you to limit a spec run to individual examples or groups
53
+ # you care about by tagging them with `:focus` metadata. When nothing
54
+ # is tagged with `:focus`, all examples get run. RSpec also provides
55
+ # aliases for `it`, `describe`, and `context` that include `:focus`
56
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
57
+ config.filter_run_when_matching :focus
58
+
59
+ # Allows RSpec to persist some state between runs in order to support
60
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
61
+ # you configure your source control system to ignore this file.
62
+ config.example_status_persistence_file_path = "spec/examples.txt"
63
+
64
+ # Limits the available syntax to the non-monkey patched syntax that is
65
+ # recommended. For more details, see:
66
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
67
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
68
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
69
+ config.disable_monkey_patching!
70
+
71
+ # This setting enables warnings. It's recommended, but in some cases may
72
+ # be too noisy due to issues in dependencies.
73
+ config.warnings = true
74
+
75
+ # Many RSpec users commonly either run the entire suite or an individual
76
+ # file, and it's useful to allow more verbose output when running an
77
+ # individual spec file.
78
+ if config.files_to_run.one?
79
+ # Use the documentation formatter for detailed output,
80
+ # unless a formatter has already been configured
81
+ # (e.g. via a command-line flag).
82
+ config.default_formatter = "doc"
83
+ end
84
+
85
+ # Print the 10 slowest examples and example groups at the
86
+ # end of the spec run, to help surface which specs are running
87
+ # particularly slow.
88
+ config.profile_examples = 10
89
+
90
+ # Run specs in random order to surface order dependencies. If you find an
91
+ # order dependency and want to debug it, you can fix the order by providing
92
+ # the seed, which is printed after each run.
93
+ # --seed 1234
94
+ config.order = :random
95
+
96
+ # Seed global randomization in this process using the `--seed` CLI option.
97
+ # Setting this allows you to use `--seed` to deterministically reproduce
98
+ # test failures related to randomization by passing the same `--seed` value
99
+ # as the one that triggered the failure.
100
+ Kernel.srand config.seed
101
+ =end
102
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
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-02 00:00:00.000000000 Z
11
+ date: 2018-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0.10'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.7'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.7'
75
89
  description: Ruby wrapper for the Torque C library utilizing Ruby-FFI. This has been
76
90
  successfully tested with Torque 4.2.10 and greater. Your mileage may vary.
77
91
  email:
@@ -81,6 +95,8 @@ extensions: []
81
95
  extra_rdoc_files: []
82
96
  files:
83
97
  - ".gitignore"
98
+ - ".rspec"
99
+ - ".travis.yml"
84
100
  - CHANGELOG.md
85
101
  - Gemfile
86
102
  - LICENSE.txt
@@ -95,6 +111,8 @@ files:
95
111
  - lib/pbs/torque.rb
96
112
  - lib/pbs/version.rb
97
113
  - pbs.gemspec
114
+ - spec/batch_spec.rb
115
+ - spec/spec_helper.rb
98
116
  homepage: https://github.com/OSC/pbs-ruby
99
117
  licenses:
100
118
  - MIT
@@ -115,9 +133,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
133
  version: '0'
116
134
  requirements: []
117
135
  rubyforge_project:
118
- rubygems_version: 2.4.5
136
+ rubygems_version: 2.4.5.4
119
137
  signing_key:
120
138
  specification_version: 4
121
139
  summary: Ruby gem that uses FFI to interface with Adaptive Computing's resource manager
122
140
  Torque
123
- test_files: []
141
+ test_files:
142
+ - spec/batch_spec.rb
143
+ - spec/spec_helper.rb