bitfab 0.62.7 → 0.63.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.
@@ -2,13 +2,15 @@
2
2
 
3
3
  require "json"
4
4
  require "open3"
5
+ require "rbconfig"
5
6
  require "tempfile"
6
7
 
7
8
  module Bitfab
8
9
  module CloudReplayCli
9
- HELP = "Direct GitHub replay: --cloud PIPELINE --trace-ids UUID[,UUID] [--registry PATH] [--max-concurrency 1..32] [--cloud-include FILE] [--cloud-dry-run] [--cloud-detach] [--cloud-request-id UUID] [--cloud-timeout MINUTES] [--cloud-check] [--fail-on-error] [replay options such as --name, --dataset-ids, --attempts, or --resume, passed to the replay on the runner]. Lifecycle: --cloud-status|--cloud-watch|--cloud-cancel|--cloud-cleanup UUID. Setup: --cloud-init [--config FILE] (creates a setup or updates it in place), --cloud-secrets --env-file FILE [NAME ...]. Requires git, gh auth login, Python 3.10+, and bitfab:setup cloud."
10
+ HINT = "Add --cloud to run the same replay on GitHub Actions; bitfab-replay --cloud --help explains it."
10
11
 
11
12
  HELPER = File.expand_path("cloudReplay.py", __dir__)
13
+ REPLAY_EXECUTABLE = File.expand_path("../../exe/bitfab-replay", __dir__)
12
14
 
13
15
  module_function
14
16
 
@@ -17,13 +19,13 @@ module Bitfab
17
19
  end
18
20
 
19
21
  def run(argv:, stdout:, stderr:, helper: HELPER)
20
- if argv.include?("--help") || argv.include?("-h")
21
- stdout.puts HELP
22
- return {}
23
- end
22
+ env = {
23
+ "BITFAB_REPLAY_COMMAND" => JSON.generate([RbConfig.ruby, REPLAY_EXECUTABLE]),
24
+ "BITFAB_SDK_LANGUAGE" => "ruby"
25
+ }
24
26
  Tempfile.create("bitfab-cloud-output") do |file|
25
27
  result_status = nil
26
- Open3.popen3("python3", helper, *argv) do |input, output_stream, error_stream, thread|
28
+ Open3.popen3(env, "python3", helper, *argv) do |input, output_stream, error_stream, thread|
27
29
  input.close
28
30
  reader = Thread.new { IO.copy_stream(output_stream, file) }
29
31
  error_stream.each_line { |line| stderr.write(line) }
@@ -36,6 +38,10 @@ module Bitfab
36
38
  stdout.puts result_output unless result_output.strip.empty?
37
39
  raise ArgumentError, "Cloud replay failed. See diagnostics; use the execution UUID to recover a dispatched job."
38
40
  end
41
+ if argv.include?("--help") || argv.include?("-h")
42
+ stdout.write result_output
43
+ return {}
44
+ end
39
45
  result = JSON.parse(result_output)
40
46
  stdout.puts JSON.pretty_generate(result)
41
47
  result
@@ -262,7 +262,7 @@ module Bitfab
262
262
  # same org and trace function or the server rejects the replay
263
263
  def start_replay(trace_function_key, limit, trace_ids: nil, code_change_description: nil,
264
264
  code_change_files: nil, experiment_group_id: nil, name: nil, notes: nil, metadata: nil, include_db_branch_lease: false, dataset_ids: nil,
265
- grader_ids: nil, db_branch_settings: nil, attempts: 1, only_with_assertions: false, judge_assertions: false, include_original_metadata: false, experimental_selective_replay: nil)
265
+ grader_ids: nil, db_branch_settings: nil, attempts: 1, only_with_assertions: false, skip_assertion_judging: false, include_original_metadata: false, experimental_selective_replay: nil)
266
266
  payload = {
267
267
  "traceFunctionKey" => trace_function_key
268
268
  }
@@ -288,7 +288,7 @@ module Bitfab
288
288
  payload["graderIds"] = grader_ids unless grader_ids.nil?
289
289
  payload["attempts"] = attempts if attempts > 1
290
290
  payload["onlyWithAssertions"] = true if only_with_assertions
291
- payload["judgeAssertions"] = true if judge_assertions
291
+ payload["judgeAssertions"] = true unless skip_assertion_judging
292
292
  payload["includeOriginalMetadata"] = true if include_original_metadata
293
293
  payload["experimentalSelectiveReplay"] = experimental_selective_replay if experimental_selective_replay
294
294
  payload["dbBranchSettings"] = db_branch_settings unless db_branch_settings.nil?
data/lib/bitfab/replay.rb CHANGED
@@ -144,6 +144,8 @@ module Bitfab
144
144
  CODE_CHANGE_UNSET = Object.new.freeze
145
145
  PERSISTENCE_TIMEOUT_SECONDS = 30.0
146
146
  PERSISTENCE_POLL_SECONDS = 0.1
147
+ JUDGE_ASSERTIONS_DEPRECATION = "judge_assertions is deprecated. Assertion judging is on by default; " \
148
+ "pass skip_assertion_judging: true (--skip-assertion-judging) to turn it off."
147
149
 
148
150
  module_function
149
151
 
@@ -282,9 +284,10 @@ module Bitfab
282
284
  # deprecated aliases :test_run_id and :test_run_url carrying the same values
283
285
  def run(client, receiver, method_name, trace_function_key:, limit: nil, trace_ids: nil, name: nil, notes: nil, metadata: nil,
284
286
  concurrency: nil, max_concurrency: ReplayConcurrency::UNSET, code_change_description: CODE_CHANGE_UNSET, code_change_files: CODE_CHANGE_UNSET, experiment_group_id: nil,
285
- dataset_id: nil, dataset_ids: nil, grader_ids: nil, mock: "marked", attempts: ReplayConcurrency::UNSET, only_with_assertions: false, judge_assertions: false, dry_run: false,
287
+ dataset_id: nil, dataset_ids: nil, grader_ids: nil, mock: "marked", attempts: ReplayConcurrency::UNSET, only_with_assertions: false, skip_assertion_judging: false, judge_assertions: nil, dry_run: false,
286
288
  adapt_inputs: nil, mock_override: nil, db_branch: nil, on_item_start: nil, on_item_finish: nil, on_progress: nil,
287
289
  on_experiment_start: nil, experimental_selective_replay: nil)
290
+ skip_assertion_judging = resolve_skip_assertion_judging(skip_assertion_judging, judge_assertions)
288
291
  concurrency_options = ReplayConcurrency.resolve(concurrency, attempts, max_concurrency)
289
292
  attempts = concurrency_options.attempts
290
293
  max_concurrency = concurrency_options.max_concurrency
@@ -387,7 +390,7 @@ module Bitfab
387
390
  grader_ids:,
388
391
  attempts:,
389
392
  only_with_assertions:,
390
- judge_assertions:,
393
+ skip_assertion_judging:,
391
394
  include_original_metadata: !adapt_inputs.nil?,
392
395
  db_branch_settings: resolved_db_branch_settings,
393
396
  **(experimental_selective_replay ? {experimental_selective_replay: SelectiveReplay.wire_options(experimental_selective_replay)} : {})
@@ -566,6 +569,13 @@ module Bitfab
566
569
  CC_MAX_FILE_BYTES = 500_000
567
570
  CC_MAX_TOTAL_BYTES = 2_000_000
568
571
 
572
+ def resolve_skip_assertion_judging(skip_assertion_judging, judge_assertions)
573
+ return skip_assertion_judging if judge_assertions.nil?
574
+
575
+ Bitfab.warn_once("judge-assertions-deprecated", JUDGE_ASSERTIONS_DEPRECATION)
576
+ skip_assertion_judging || judge_assertions == false
577
+ end
578
+
569
579
  def resolve_dataset_ids(dataset_id, dataset_ids)
570
580
  if dataset_id && dataset_ids
571
581
  raise ArgumentError,
@@ -7,7 +7,7 @@ module Bitfab
7
7
  # Installed command that loads a project-owned registry module.
8
8
  module ReplayCommand
9
9
  USAGE = "Usage: bitfab-replay --registry <path> <pipeline> [replay options]"
10
- HELP = "#{USAGE}\nRun bitfab-replay --registry <path> --help to list replay options.\n#{CloudReplayCli::HELP}"
10
+ HELP = "#{USAGE}\nRun bitfab-replay --registry <path> --help to list replay options.\n#{CloudReplayCli::HINT}"
11
11
 
12
12
  module_function
13
13
 
@@ -26,7 +26,7 @@ module Bitfab
26
26
  end
27
27
 
28
28
  def main(argv: ARGV, stdout: $stdout, stderr: $stderr)
29
- if (argv.include?("--help") || argv.include?("-h")) && !argv.include?("--registry")
29
+ if (argv.include?("--help") || argv.include?("-h")) && !argv.include?("--registry") && !CloudReplayCli.cloud?(argv)
30
30
  stdout.puts HELP
31
31
  return 0
32
32
  end
@@ -21,7 +21,7 @@ module Bitfab
21
21
  OPTION_NAMES = %i[
22
22
  limit trace_ids name notes metadata concurrency max_concurrency code_change_description
23
23
  code_change_files experiment_group_id dataset_id dataset_ids grader_ids mock
24
- mock_override adapt_inputs db_branch attempts only_with_assertions judge_assertions dry_run on_item_finish
24
+ mock_override adapt_inputs db_branch attempts only_with_assertions skip_assertion_judging judge_assertions dry_run on_item_finish
25
25
  ].freeze
26
26
 
27
27
  def initialize
@@ -140,6 +140,7 @@ module Bitfab
140
140
  def run(registry, argv: ARGV, stdout: $stdout, stderr: $stderr)
141
141
  args = parse(registry, argv.dup)
142
142
  return SeedCli.run(registry, argv:, stdout:, stderr:) if args[:seed] || args[:from_trace]
143
+ stderr.puts "Bitfab: #{Replay::JUDGE_ASSERTIONS_DEPRECATION}" if args[:judge_assertions]
143
144
 
144
145
  registration = registry.fetch(args.fetch(:pipeline))
145
146
  options = registration.options.dup
@@ -188,7 +189,7 @@ module Bitfab
188
189
  options[:limit] = bound || 10
189
190
  end
190
191
 
191
- %i[name notes metadata max_concurrency experiment_group_id dataset_ids grader_ids mock attempts only_with_assertions judge_assertions dry_run].each do |key|
192
+ %i[name notes metadata max_concurrency experiment_group_id dataset_ids grader_ids mock attempts only_with_assertions skip_assertion_judging dry_run].each do |key|
192
193
  options[key] = args[key] unless args[key].nil?
193
194
  end
194
195
 
@@ -325,8 +326,9 @@ module Bitfab
325
326
  options.on("--grader-ids IDS") { |value| args[:grader_ids] = comma_separated("--grader-ids", value) }
326
327
  options.on("--attempts N", Integer) { |value| args[:attempts] = positive_integer("--attempts", value) }
327
328
  options.on("--only-with-assertions") { args[:only_with_assertions] = true }
328
- options.on("--judge-assertions",
329
- "Judge each replay's approved assertions as it finishes (costs model calls)") { args[:judge_assertions] = true }
329
+ options.on("--skip-assertion-judging",
330
+ "Don't judge approved assertions on each replay; judging is on by default and costs model calls") { args[:skip_assertion_judging] = true }
331
+ options.on("--judge-assertions", "Deprecated: judging is on by default") { args[:judge_assertions] = true }
330
332
  options.on("--dry-run") { args[:dry_run] = true }
331
333
  options.on("--fail-on-error",
332
334
  "Exit 1 after printing the result when any replayed item errored. " \
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitfab
4
- VERSION = "0.62.7"
4
+ VERSION = "0.63.1"
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.62.7
4
+ version: 0.63.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvest Team