bitfab 0.30.1 → 0.31.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/client.rb +2 -2
- data/lib/bitfab/http_client.rb +2 -1
- data/lib/bitfab/replay.rb +40 -4
- data/lib/bitfab/replay_environment.rb +8 -0
- data/lib/bitfab/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d85c35718e6138d5095d4d20278fdac5f3c6f31858684622cb3a68bad6b5416
|
|
4
|
+
data.tar.gz: 1de8519b600a8ea4a29593a82f938669d8aa9e9ec616c95102c0abe6d06045c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c6d45ca5bbaedfd2a162e2d05c4bef6da21b31c482db91d5539fb46b79be936aa4600e2ea5d0875ecf0e608907ee92a028660edbcd08dc367ce942003658538
|
|
7
|
+
data.tar.gz: db3e762b1ce6b7cb60f4996f4642d6e2a3d5e6a7e6b886a14c319b98ae198f0f210e7af857fda35c53d4e2a49339283ae929f6338d1bae3f64f9be6b97023acc
|
data/lib/bitfab/client.rb
CHANGED
|
@@ -114,12 +114,12 @@ module Bitfab
|
|
|
114
114
|
# @return [Hash] with :items, :test_run_id, :test_run_url
|
|
115
115
|
def replay(receiver, method_name, trace_function_key:, limit: nil, trace_ids: nil, max_concurrency: 10,
|
|
116
116
|
name: nil, code_change_description: nil, code_change_files: nil, experiment_group_id: nil, dataset_id: nil, grader_ids: nil, mock: "marked",
|
|
117
|
-
adapt_inputs: nil, mock_override: nil, environment: nil, on_progress: nil)
|
|
117
|
+
adapt_inputs: nil, mock_override: nil, environment: nil, db_branch: nil, on_progress: nil)
|
|
118
118
|
Replay.run(
|
|
119
119
|
self, receiver, method_name,
|
|
120
120
|
trace_function_key:, limit:, trace_ids:, name:, max_concurrency:,
|
|
121
121
|
code_change_description:, code_change_files:, experiment_group_id:, dataset_id:, grader_ids:, mock:, adapt_inputs:,
|
|
122
|
-
mock_override:, environment:,
|
|
122
|
+
mock_override:, environment:, db_branch:,
|
|
123
123
|
on_progress:
|
|
124
124
|
)
|
|
125
125
|
end
|
data/lib/bitfab/http_client.rb
CHANGED
|
@@ -118,7 +118,7 @@ module Bitfab
|
|
|
118
118
|
# same org and trace function or the server rejects the replay
|
|
119
119
|
def start_replay(trace_function_key, limit, trace_ids: nil, code_change_description: nil,
|
|
120
120
|
code_change_files: nil, experiment_group_id: nil, name: nil, include_db_branch_lease: false, dataset_id: nil,
|
|
121
|
-
grader_ids: nil)
|
|
121
|
+
grader_ids: nil, db_branch_settings: nil)
|
|
122
122
|
payload = {
|
|
123
123
|
"traceFunctionKey" => trace_function_key
|
|
124
124
|
}
|
|
@@ -133,6 +133,7 @@ module Bitfab
|
|
|
133
133
|
payload["includeDbBranchLease"] = true if include_db_branch_lease
|
|
134
134
|
payload["datasetId"] = dataset_id unless dataset_id.nil?
|
|
135
135
|
payload["graderIds"] = grader_ids unless grader_ids.nil?
|
|
136
|
+
payload["dbBranchSettings"] = db_branch_settings unless db_branch_settings.nil?
|
|
136
137
|
|
|
137
138
|
# When DB branching is on, the server resolves a Neon preview branch per
|
|
138
139
|
# item (snapshot + restore + poll), which can run several seconds each.
|
data/lib/bitfab/replay.rb
CHANGED
|
@@ -136,7 +136,7 @@ module Bitfab
|
|
|
136
136
|
def run(client, receiver, method_name, trace_function_key:, limit: nil, trace_ids: nil, name: nil,
|
|
137
137
|
max_concurrency: 10, code_change_description: nil, code_change_files: nil, experiment_group_id: nil,
|
|
138
138
|
dataset_id: nil, grader_ids: nil, mock: "marked",
|
|
139
|
-
adapt_inputs: nil, mock_override: nil, environment: nil, on_progress: nil)
|
|
139
|
+
adapt_inputs: nil, mock_override: nil, environment: nil, db_branch: nil, on_progress: nil)
|
|
140
140
|
unless MOCK_STRATEGIES.include?(mock.to_s)
|
|
141
141
|
raise ArgumentError, "Invalid mock strategy '#{mock}'. Must be one of: #{MOCK_STRATEGIES.join(", ")}"
|
|
142
142
|
end
|
|
@@ -204,7 +204,8 @@ module Bitfab
|
|
|
204
204
|
experiment_group_id:,
|
|
205
205
|
include_db_branch_lease:,
|
|
206
206
|
dataset_id:,
|
|
207
|
-
grader_ids
|
|
207
|
+
grader_ids:,
|
|
208
|
+
db_branch_settings: db_branch_settings(db_branch)
|
|
208
209
|
)
|
|
209
210
|
test_run_id = replay_data["testRunId"]
|
|
210
211
|
test_run_url = replay_data["testRunUrl"]
|
|
@@ -319,6 +320,31 @@ module Bitfab
|
|
|
319
320
|
CC_MAX_FILE_BYTES = 500_000
|
|
320
321
|
CC_MAX_TOTAL_BYTES = 2_000_000
|
|
321
322
|
|
|
323
|
+
# Convert the caller's +db_branch+ options to the wire shape, or nil when
|
|
324
|
+
# nothing was set. Dropping the key entirely keeps the request identical to
|
|
325
|
+
# what older SDKs send.
|
|
326
|
+
#
|
|
327
|
+
# Keys: :min_cu and :max_cu are the branch compute's autoscaling floor and
|
|
328
|
+
# ceiling in Neon Compute Units (equal values pin the size, keeping items
|
|
329
|
+
# comparable); :warmup_sql is appended to the branch's readiness check so it
|
|
330
|
+
# warms the cache before the replayed function sees the lease.
|
|
331
|
+
def db_branch_settings(db_branch)
|
|
332
|
+
return nil if db_branch.nil? || db_branch.empty?
|
|
333
|
+
|
|
334
|
+
# Symbol or string keys, matching normalize_code_change_files: a hash
|
|
335
|
+
# loaded from JSON or YAML would otherwise be read as empty, leaving the
|
|
336
|
+
# branch on the mirror's defaults with no error to notice.
|
|
337
|
+
min_cu = db_branch[:min_cu] || db_branch["min_cu"]
|
|
338
|
+
max_cu = db_branch[:max_cu] || db_branch["max_cu"]
|
|
339
|
+
warmup_sql = db_branch[:warmup_sql] || db_branch["warmup_sql"]
|
|
340
|
+
|
|
341
|
+
settings = {}
|
|
342
|
+
settings["minCu"] = min_cu unless min_cu.nil?
|
|
343
|
+
settings["maxCu"] = max_cu unless max_cu.nil?
|
|
344
|
+
settings["warmupSql"] = warmup_sql unless warmup_sql.nil?
|
|
345
|
+
settings.empty? ? nil : settings
|
|
346
|
+
end
|
|
347
|
+
|
|
322
348
|
# Auto-capture the code change to attach when the caller passed none. Lives
|
|
323
349
|
# in replay() (the one call guaranteed to run on every replay) so it works no
|
|
324
350
|
# matter how the replay was launched. Precedence: a BITFAB_CODE_CHANGE_PATH
|
|
@@ -599,9 +625,19 @@ module Bitfab
|
|
|
599
625
|
# (only when include_db_branch_lease was sent). Release it in the +ensure+
|
|
600
626
|
# below so any raise (span fetch, mock-tree build, or the replayed
|
|
601
627
|
# method) frees the Neon resource. Items whose source trace had no
|
|
602
|
-
# snapshot ref
|
|
603
|
-
#
|
|
628
|
+
# snapshot ref arrive without a lease (env.active? is false), and
|
|
629
|
+
# replaying those against the live database is correct.
|
|
604
630
|
lease = include_db_branch_lease ? server_item["dbBranchLease"] : nil
|
|
631
|
+
# A resolve that was ATTEMPTED and failed is different: the caller asked
|
|
632
|
+
# for a branch, so running their method against live data would produce a
|
|
633
|
+
# result that looks valid and is not. Fail the item instead, loudly.
|
|
634
|
+
lease_error = include_db_branch_lease ? server_item["dbBranchLeaseError"] : nil
|
|
635
|
+
if lease_error
|
|
636
|
+
raise "Replay requested a database branch for trace #{original_trace_id} but it " \
|
|
637
|
+
"could not be resolved (#{lease_error["code"]}): #{lease_error["message"]}. " \
|
|
638
|
+
"The method was not run, because replaying it against the live database would " \
|
|
639
|
+
"produce a result that looks valid but did not use the historical data you asked for."
|
|
640
|
+
end
|
|
605
641
|
|
|
606
642
|
span = http_client.get_external_span(original_span_id)
|
|
607
643
|
item_data = extract_span_data(span)
|
|
@@ -44,6 +44,13 @@ module Bitfab
|
|
|
44
44
|
require_snapshot[:read_only]
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
# The branch's region, e.g. "aws-us-east-1". A compute runs in its
|
|
48
|
+
# project's region, so a replay runner elsewhere pays that round trip on
|
|
49
|
+
# every query.
|
|
50
|
+
def region
|
|
51
|
+
require_snapshot[:region]
|
|
52
|
+
end
|
|
53
|
+
|
|
47
54
|
# The historical trace ID that produced the input for this replay item.
|
|
48
55
|
def trace_id
|
|
49
56
|
require_snapshot.fetch(:trace_id)
|
|
@@ -95,6 +102,7 @@ module Bitfab
|
|
|
95
102
|
expires_at: lease["expiresAt"],
|
|
96
103
|
provider_console_url: lease["providerConsoleUrl"],
|
|
97
104
|
read_only: lease["readOnly"],
|
|
105
|
+
region: lease["region"],
|
|
98
106
|
trace_id:
|
|
99
107
|
}
|
|
100
108
|
end
|
data/lib/bitfab/version.rb
CHANGED