bitfab 0.31.0 → 0.32.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/replay.rb +7 -6
- data/lib/bitfab/replay_environment.rb +30 -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: 6c30821c7a2d174dacfae3c40d838cf9b37d2f71e07be3b95aa385507cd26867
|
|
4
|
+
data.tar.gz: f041e1f63eedc9397c55d70f635ca75d0f365c7b6a970f943b6a282bcc4b10e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8427f0d34ca1fbafcbd1d8582da7d24fba552635e23fdc9cba0a5afe1198a3f0f712c1c7c3a25b4229abc441c8fc4057bc7bb284f6e830173213d4194410d699
|
|
7
|
+
data.tar.gz: e4472dd0149b0a604439da779a5bae825f8313b41f2270701ab77b1ee46baf286c636d6022ce0df65cbca995525a0a53418ba4f2d839db582be7a17be41c9c15
|
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,
|
|
117
|
+
adapt_inputs: nil, mock_override: nil, environment: 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:,
|
|
123
123
|
on_progress:
|
|
124
124
|
)
|
|
125
125
|
end
|
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,
|
|
139
|
+
adapt_inputs: nil, mock_override: nil, environment: 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
|
|
@@ -205,7 +205,7 @@ module Bitfab
|
|
|
205
205
|
include_db_branch_lease:,
|
|
206
206
|
dataset_id:,
|
|
207
207
|
grader_ids:,
|
|
208
|
-
db_branch_settings: db_branch_settings(
|
|
208
|
+
db_branch_settings: db_branch_settings(environment)
|
|
209
209
|
)
|
|
210
210
|
test_run_id = replay_data["testRunId"]
|
|
211
211
|
test_run_url = replay_data["testRunUrl"]
|
|
@@ -320,7 +320,7 @@ module Bitfab
|
|
|
320
320
|
CC_MAX_FILE_BYTES = 500_000
|
|
321
321
|
CC_MAX_TOTAL_BYTES = 2_000_000
|
|
322
322
|
|
|
323
|
-
# Convert the
|
|
323
|
+
# Convert the environment's branch options to the wire shape, or nil when
|
|
324
324
|
# nothing was set. Dropping the key entirely keeps the request identical to
|
|
325
325
|
# what older SDKs send.
|
|
326
326
|
#
|
|
@@ -328,12 +328,13 @@ module Bitfab
|
|
|
328
328
|
# ceiling in Neon Compute Units (equal values pin the size, keeping items
|
|
329
329
|
# comparable); :warmup_sql is appended to the branch's readiness check so it
|
|
330
330
|
# warms the cache before the replayed function sees the lease.
|
|
331
|
-
def db_branch_settings(
|
|
331
|
+
def db_branch_settings(environment)
|
|
332
|
+
db_branch = environment&.db_branch
|
|
332
333
|
return nil if db_branch.nil? || db_branch.empty?
|
|
333
334
|
|
|
334
335
|
# Symbol or string keys, matching normalize_code_change_files: a hash
|
|
335
|
-
#
|
|
336
|
-
# branch on the mirror's defaults with no error to notice.
|
|
336
|
+
# assembled from JSON or YAML would otherwise be read as empty, leaving
|
|
337
|
+
# the branch on the mirror's defaults with no error to notice.
|
|
337
338
|
min_cu = db_branch[:min_cu] || db_branch["min_cu"]
|
|
338
339
|
max_cu = db_branch[:max_cu] || db_branch["max_cu"]
|
|
339
340
|
warmup_sql = db_branch[:warmup_sql] || db_branch["warmup_sql"]
|
|
@@ -16,10 +16,40 @@ module Bitfab
|
|
|
16
16
|
# context, so each in-flight replay item sees its own per-trace values even
|
|
17
17
|
# when the SDK runs items across worker threads.
|
|
18
18
|
#
|
|
19
|
+
# The constructor takes how each branch should be sized and warmed. That
|
|
20
|
+
# lives here rather than on the replay arguments because the settings only
|
|
21
|
+
# mean anything for a replay that has an environment.
|
|
22
|
+
#
|
|
19
23
|
# Internally the resolved per-item state is a DB branch lease (the SDK <->
|
|
20
24
|
# server protocol term). We expose its useful fields directly here so
|
|
21
25
|
# customer code never sees the word.
|
|
22
26
|
class ReplayEnvironment
|
|
27
|
+
# The branch settings this environment was constructed with, as a
|
|
28
|
+
# symbol-keyed hash, readable anywhere. Every other reader reports the
|
|
29
|
+
# lease the server resolved and is therefore replay-only.
|
|
30
|
+
attr_reader :db_branch
|
|
31
|
+
|
|
32
|
+
# @param min_cu [Numeric, nil] autoscaling floor for the branch's compute,
|
|
33
|
+
# in Neon Compute Units (0.25 to 56). Omit to keep the mirror project's
|
|
34
|
+
# own default. Raise it when the mirror is provisioned smaller than the
|
|
35
|
+
# database it stands in for, so replay latency reflects your code rather
|
|
36
|
+
# than a cold, undersized branch.
|
|
37
|
+
# @param max_cu [Numeric, nil] autoscaling ceiling, in Neon Compute Units.
|
|
38
|
+
# Equal to +min_cu+ pins the size, which keeps items comparable:
|
|
39
|
+
# otherwise a later item can run against an endpoint that already scaled
|
|
40
|
+
# up and post a better number for the same code.
|
|
41
|
+
# @param warmup_sql [String, nil] SQL that warms the branch's cache. The
|
|
42
|
+
# server appends it to the branch's readiness check, so it runs BEFORE
|
|
43
|
+
# your method sees the lease and its time is not charged to the replayed
|
|
44
|
+
# call. Invalid SQL fails the lease rather than silently leaving the
|
|
45
|
+
# branch cold.
|
|
46
|
+
def initialize(min_cu: nil, max_cu: nil, warmup_sql: nil)
|
|
47
|
+
@db_branch = {}
|
|
48
|
+
@db_branch[:min_cu] = min_cu unless min_cu.nil?
|
|
49
|
+
@db_branch[:max_cu] = max_cu unless max_cu.nil?
|
|
50
|
+
@db_branch[:warmup_sql] = warmup_sql unless warmup_sql.nil?
|
|
51
|
+
end
|
|
52
|
+
|
|
23
53
|
# The per-trace branch URL for the item currently being replayed.
|
|
24
54
|
# Raises if read outside a replay item.
|
|
25
55
|
def database_url
|
data/lib/bitfab/version.rb
CHANGED