bitfab 0.63.2 → 0.64.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.
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "json"
4
- require "open3"
5
4
  require "rbconfig"
6
- require "tempfile"
7
5
 
8
6
  module Bitfab
9
7
  module CloudReplayCli
@@ -18,34 +16,21 @@ module Bitfab
18
16
  argv.any? { |arg| arg == "--cloud" || arg.start_with?("--cloud-") }
19
17
  end
20
18
 
21
- def run(argv:, stdout:, stderr:, helper: HELPER)
19
+ def run(argv:, helper: HELPER)
22
20
  env = {
23
21
  "BITFAB_REPLAY_COMMAND" => JSON.generate([RbConfig.ruby, REPLAY_EXECUTABLE]),
24
22
  "BITFAB_SDK_LANGUAGE" => "ruby"
25
23
  }
26
- Tempfile.create("bitfab-cloud-output") do |file|
27
- result_status = nil
28
- Open3.popen3(env, "python3", helper, *argv) do |input, output_stream, error_stream, thread|
29
- input.close
30
- reader = Thread.new { IO.copy_stream(output_stream, file) }
31
- error_stream.each_line { |line| stderr.write(line) }
32
- reader.join
33
- result_status = thread.value
34
- end
35
- file.rewind
36
- result_output = file.read
37
- unless result_status.success?
38
- stdout.puts result_output unless result_output.strip.empty?
39
- raise ArgumentError, "Cloud replay failed. See diagnostics; use the execution UUID to recover a dispatched job."
40
- end
41
- if argv.include?("--help") || argv.include?("-h")
42
- stdout.write result_output
43
- return {}
44
- end
45
- result = JSON.parse(result_output)
46
- stdout.puts JSON.pretty_generate(result)
47
- result
24
+ pid = Process.spawn(env, "python3", helper, *argv)
25
+ begin
26
+ _, status = Process.wait2(pid)
27
+ rescue Interrupt
28
+ retry
48
29
  end
30
+ status.exitstatus || ((status.termsig == Signal.list["INT"]) ? 130 : 1)
31
+ rescue Errno::ENOENT
32
+ warn "Cloud replay needs Python 3.10+ on PATH as python3"
33
+ 1
49
34
  end
50
35
  end
51
36
  end
@@ -12,7 +12,6 @@ module Bitfab
12
12
  module_function
13
13
 
14
14
  def run(argv: ARGV, stdout: $stdout, stderr: $stderr, registry_loader: nil)
15
- return CloudReplayCli.run(argv:, stdout:, stderr:) if CloudReplayCli.cloud?(argv)
16
15
  registry_path, replay_argv = parse(argv)
17
16
  loader = registry_loader || method(:load_registry)
18
17
  registry = loader.call(registry_path)
@@ -26,7 +25,8 @@ module Bitfab
26
25
  end
27
26
 
28
27
  def main(argv: ARGV, stdout: $stdout, stderr: $stderr)
29
- if (argv.include?("--help") || argv.include?("-h")) && !argv.include?("--registry") && !CloudReplayCli.cloud?(argv)
28
+ return CloudReplayCli.run(argv:) if CloudReplayCli.cloud?(argv)
29
+ if (argv.include?("--help") || argv.include?("-h")) && !argv.include?("--registry")
30
30
  stdout.puts HELP
31
31
  return 0
32
32
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitfab
4
- VERSION = "0.63.2"
4
+ VERSION = "0.64.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitfab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.63.2
4
+ version: 0.64.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvest Team