bitfab 0.63.3 → 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.
- checksums.yaml +4 -4
- data/lib/bitfab/cloudReplay.py +663 -757
- data/lib/bitfab/cloud_replay_cli.rb +10 -43
- data/lib/bitfab/replay_cli.rb +2 -2
- data/lib/bitfab/version.rb +1 -1
- metadata +1 -1
|
@@ -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,52 +16,21 @@ module Bitfab
|
|
|
18
16
|
argv.any? { |arg| arg == "--cloud" || arg.start_with?("--cloud-") }
|
|
19
17
|
end
|
|
20
18
|
|
|
21
|
-
def run(argv:,
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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 = parse_result(result_output, stdout)
|
|
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
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
commands.each { |line| stdout.puts line.chomp }
|
|
54
|
-
stdout.flush
|
|
55
|
-
(rest.length - 1).downto(0) do |start|
|
|
56
|
-
next unless rest[start].start_with?("{")
|
|
57
|
-
begin
|
|
58
|
-
result = JSON.parse(rest[start..].join)
|
|
59
|
-
return result if result.is_a?(Hash)
|
|
60
|
-
rescue JSON::ParserError
|
|
61
|
-
next
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
text = rest.join
|
|
65
|
-
stdout.puts text unless text.strip.empty?
|
|
66
|
-
raise ArgumentError, "Cloud replay did not print a JSON result; its output is above"
|
|
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
|
|
67
34
|
end
|
|
68
35
|
end
|
|
69
36
|
end
|
data/lib/bitfab/replay_cli.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
data/lib/bitfab/version.rb
CHANGED