bitfab 0.51.0 → 0.51.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ece2db3c44be909ec097e539479143d0c4138663809c26a05a968076e681066
4
- data.tar.gz: 6d68e352c7e484586147d1700998de7936fe904c5d04cabfe07df80e302104b1
3
+ metadata.gz: 3dd6fa16ae3ff5f26d94f6b86f9fa702129cfb502e3f94b293e383d107d1c0de
4
+ data.tar.gz: 220cdb686e1a5522fdcd9579e897f60b0896360583b49615006f0489723c6d21
5
5
  SHA512:
6
- metadata.gz: bbb4750e80b63864d612592e1bebaac664463059e2d139fe7d556f68ce73b46868001daa54391d1a4562767a2e7e16355fdb8eefc89c64ace8f864dffffce86b
7
- data.tar.gz: 02d731c682b787b8233a1c9a43135fc8b6d17d5959806ff65bec3be9979dbda95d1bfb6d01373b427405a5fb9fccd976c87706d8d488ea7733fe70ab0f8fa15b
6
+ metadata.gz: cf75d4072ac82e17312f40f86c1a0e54c3a60a019818695507a5d53cfc1bfb15db6e705ad6a971c6e77abd67b4b752e180457d483b5f42becc52167323784dd9
7
+ data.tar.gz: 8857e35745377b128479948ec4622ef2223f3876015f03e161ac80e43f61ec1c1556cb4d4839dd174c35afba9b3e1fbfcbd0c4da69766b80cd593cd8caf96c07
data/lib/bitfab/client.rb CHANGED
@@ -95,9 +95,12 @@ module Bitfab
95
95
  # @param limit [Integer, nil] maximum number of traces to replay (default: 5;
96
96
  # maximum: 5,000). Ignored when trace_ids or a dataset is passed because
97
97
  # either source already determines how many traces replay. Supplying
98
- # trace_ids also emits a warning.
99
- # @param trace_ids [Array<String>, nil] optional list of trace IDs to replay (max 100),
100
- # mutually exclusive with dataset_id and dataset_ids
98
+ # trace_ids also emits a warning. To replay part of a dataset selection,
99
+ # name the members to run in trace_ids rather than bounding it here.
100
+ # @param trace_ids [Array<String>, nil] optional list of trace IDs to replay (max 100).
101
+ # Passed alongside dataset_id or dataset_ids it pins which members of that
102
+ # selection replay, and the server rejects any ID none of those datasets
103
+ # contains
101
104
  # @param max_concurrency [Integer, nil] max threads for parallel replay (default: 10)
102
105
  # @param code_change_description [String, nil] optional rationale for the
103
106
  # code change being tested in this replay (stored on the experiment).
@@ -112,10 +115,12 @@ module Bitfab
112
115
  # replay runs into a single experiment batch
113
116
  # @param dataset_ids [Array<String>, nil] optional UUIDs of the datasets this
114
117
  # replay runs against, for benchmarking one method against several corpora
115
- # in a single run; mutually exclusive with dataset_id
118
+ # in a single run; mutually exclusive with dataset_id. Passing trace_ids
119
+ # alongside it narrows the run to those members
116
120
  # @param dataset_id [String, nil] optional UUID of the dataset this replay
117
- # runs against, mutually exclusive with trace_ids and stored on the
118
- # resulting experiment for durable attribution
121
+ # runs against, mutually exclusive with dataset_ids and stored on the
122
+ # resulting experiment for durable attribution. Alone it replays the
123
+ # dataset's full membership, and with trace_ids only those members
119
124
  # @param grader_ids [Array<String>, nil] optional UUIDs of graders attached
120
125
  # directly to this experiment, graded as the union with the dataset's
121
126
  # runnable graders at completion; each must be an active/live grader in the
data/lib/bitfab/replay.rb CHANGED
@@ -206,12 +206,14 @@ module Bitfab
206
206
  # replay runs into a single experiment batch
207
207
  # @param dataset_id [String, nil] optional UUID of the dataset this replay
208
208
  # runs against, stored on the resulting experiment for durable attribution;
209
- # mutually exclusive with dataset_ids
209
+ # mutually exclusive with dataset_ids. Alone it replays the dataset's full
210
+ # membership, and with trace_ids it replays only those members
210
211
  # @param dataset_ids [Array<String>, nil] optional UUIDs of the datasets this
211
212
  # replay runs against, for benchmarking one method against several corpora
212
213
  # in a single run; mutually exclusive with dataset_id. The run replays the
213
214
  # union of their traces, graded by the union of their graders, and is
214
- # attributed to every one of them
215
+ # attributed to every one of them. Passing trace_ids alongside it narrows
216
+ # the run to those members
215
217
  # @param grader_ids [Array<String>, nil] optional UUIDs of graders attached
216
218
  # directly to this experiment, graded as the union with the dataset's
217
219
  # runnable graders at completion; each must be an active/live grader in the
@@ -267,10 +269,6 @@ module Bitfab
267
269
  end
268
270
  end
269
271
  resolved_dataset_ids = resolve_dataset_ids(dataset_id, dataset_ids)
270
- if trace_ids && resolved_dataset_ids
271
- raise ArgumentError,
272
- "trace_ids and dataset_ids select different replay sources and cannot be used together."
273
- end
274
272
  if limit && trace_ids
275
273
  warn "Bitfab: limit is ignored when trace_ids is passed: the explicit trace ID list already " \
276
274
  "determines how many traces replay."
@@ -81,8 +81,26 @@ module Bitfab
81
81
 
82
82
  # Argument parsing and output for the SDK-owned replay command.
83
83
  module ReplayCli
84
+ MAX_PINNED_TRACE_IDS = 100
85
+
84
86
  module_function
85
87
 
88
+ def pinned_dataset_members(client, dataset_ids, limit)
89
+ members = dataset_ids.flat_map { |dataset_id|
90
+ client.datasets.list_traces(dataset_id).fetch("traceIds")
91
+ }.uniq.sort
92
+ return nil if limit >= members.length
93
+
94
+ if limit > MAX_PINNED_TRACE_IDS
95
+ raise ArgumentError,
96
+ "Bounding a dataset replay to #{limit} names one trace ID per replayed item, and " \
97
+ "a replay accepts at most #{MAX_PINNED_TRACE_IDS}. Drop the limit to replay " \
98
+ "every selected dataset in full."
99
+ end
100
+
101
+ members.first(limit)
102
+ end
103
+
86
104
  def run(registry, argv: ARGV, stdout: $stdout, stderr: $stderr)
87
105
  args = parse(registry, argv.dup)
88
106
  registration = registry.fetch(args.fetch(:pipeline))
@@ -108,20 +126,25 @@ module Bitfab
108
126
  end
109
127
 
110
128
  if args[:trace_ids]
111
- options.delete(:limit)
112
129
  options.delete(:dataset_ids)
113
130
  options[:trace_ids] = args[:trace_ids]
114
131
  elsif args[:dataset_ids]
115
132
  options.delete(:trace_ids)
116
- options.delete(:limit)
117
- elsif args[:limit]
118
- options.delete(:trace_ids)
119
- options.delete(:dataset_ids)
120
- options[:limit] = args[:limit]
121
- elsif options[:trace_ids] || selected_dataset_ids
122
- options.delete(:limit)
133
+ end
134
+
135
+ bound = args[:limit] || options[:limit]
136
+ options.delete(:limit)
137
+ bounded_dataset_ids = args[:dataset_ids] || options[:dataset_ids]
138
+
139
+ if options[:trace_ids]
140
+ options[:trace_ids] = options[:trace_ids].first(bound) if bound
141
+ elsif bounded_dataset_ids
142
+ if bound
143
+ pinned = pinned_dataset_members(registration.client, bounded_dataset_ids, bound)
144
+ options[:trace_ids] = pinned if pinned
145
+ end
123
146
  else
124
- options[:limit] = options.fetch(:limit, 10)
147
+ options[:limit] = bound || 10
125
148
  end
126
149
 
127
150
  %i[name max_concurrency experiment_group_id dataset_ids grader_ids mock].each do |key|
@@ -179,7 +202,10 @@ module Bitfab
179
202
  args = {}
180
203
  parser = OptionParser.new do |options|
181
204
  options.banner = "Usage: bitfab-replay <#{registry.names.join("|")}> [options]"
182
- options.on("--limit N", Integer) { |value| args[:limit] = positive_integer("--limit", value) }
205
+ options.on("--limit N", Integer,
206
+ "How many traces to replay. It bounds a trace ID or dataset selection instead of replacing it") do |value|
207
+ args[:limit] = positive_integer("--limit", value)
208
+ end
183
209
  options.on("--trace-ids IDS") { |value| args[:trace_ids] = comma_separated("--trace-ids", value) }
184
210
  options.on("--name NAME") { |value| args[:name] = value }
185
211
  options.on("--concurrency N", Integer) do |value|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitfab
4
- VERSION = "0.51.0"
4
+ VERSION = "0.51.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.51.0
4
+ version: 0.51.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvest Team