bitfab 0.58.4 → 0.59.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/datasets.rb +39 -10
- 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: 0f71ead77c070efe05df2af12495ef411048fd0164655e0f1fbe11a5457b518c
|
|
4
|
+
data.tar.gz: 4e9a222f559e2977366ecf411f97429db22f89d1aca6b8b6de767b982594f8ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 406d7de1521d252c335432fa44c04fd7f3e11f0992281388d8939140ab05b5b055cb3cd5a4dc6bf30cfba15a40795f7c1f21782d989bbbebd1abeac62e5ff7fc
|
|
7
|
+
data.tar.gz: 9e80632bfc746766ffd6011ceb45848a2875590e29b2f9c983b4c4ed344b722c310a15a760b6d4bd99045357f9def49b08904bb53618ad0dedbf5b33c2c4cffe
|
data/lib/bitfab/datasets.rb
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Bitfab
|
|
4
|
+
class GraderRerunError < StandardError
|
|
5
|
+
attr_reader :run
|
|
6
|
+
|
|
7
|
+
def initialize(message, run:)
|
|
8
|
+
super(message)
|
|
9
|
+
@run = run
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class GraderRerunTimeoutError < GraderRerunError; end
|
|
14
|
+
|
|
4
15
|
# Dataset operations for the authenticated organization, reached as
|
|
5
16
|
# `client.datasets`. A dataset is a named bucket of traces scoped to one
|
|
6
17
|
# trace function. Experiments replay against it and its graders score its
|
|
@@ -8,7 +19,8 @@ module Bitfab
|
|
|
8
19
|
# string keys matching the HTTP API ("traceCount", "addedTraceIds", ...).
|
|
9
20
|
class Datasets
|
|
10
21
|
DEFAULT_RERUN_TIMEOUT_SECONDS = 90
|
|
11
|
-
|
|
22
|
+
RERUN_POLL_INTERVAL_SECONDS = 1.0
|
|
23
|
+
private_constant :RERUN_POLL_INTERVAL_SECONDS
|
|
12
24
|
TERMINAL_RERUN_STATUSES = ["completed", "errored"].freeze
|
|
13
25
|
|
|
14
26
|
def initialize(http_client)
|
|
@@ -86,22 +98,21 @@ module Bitfab
|
|
|
86
98
|
end
|
|
87
99
|
|
|
88
100
|
# Re-run graders over every trace in the dataset. Defaults to every
|
|
89
|
-
# assigned grader, and an unassigned id is rejected.
|
|
90
|
-
#
|
|
91
|
-
#
|
|
92
|
-
#
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
# assigned grader, and an unassigned id is rejected. Blocks until the run
|
|
102
|
+
# completes and returns it. Raises GraderRerunError when the run errors and
|
|
103
|
+
# GraderRerunTimeoutError when it is still going after `timeout` seconds.
|
|
104
|
+
# The run keeps going on Bitfab after a timeout. A request matching an
|
|
105
|
+
# in-flight run joins it.
|
|
106
|
+
def rerun_graders(dataset_id, grader_ids: nil, timeout: DEFAULT_RERUN_TIMEOUT_SECONDS)
|
|
95
107
|
payload = grader_ids.nil? ? {} : {"graderIds" => grader_ids}
|
|
96
108
|
started = @http_client.request(dataset_path(dataset_id, "/rerunGraders"), payload)
|
|
97
|
-
return started unless wait
|
|
98
|
-
|
|
99
109
|
deadline = monotonic_now + timeout
|
|
100
110
|
run = started["run"]
|
|
101
111
|
while !TERMINAL_RERUN_STATUSES.include?(run["status"]) && monotonic_now < deadline
|
|
102
|
-
sleep(
|
|
112
|
+
sleep(RERUN_POLL_INTERVAL_SECONDS)
|
|
103
113
|
run = get_grader_rerun(dataset_id, run_id: run["id"]) || run
|
|
104
114
|
end
|
|
115
|
+
settle_grader_rerun(dataset_id, run, timeout)
|
|
105
116
|
{"run" => run, "joinedExisting" => started["joinedExisting"]}
|
|
106
117
|
end
|
|
107
118
|
|
|
@@ -114,6 +125,24 @@ module Bitfab
|
|
|
114
125
|
|
|
115
126
|
private
|
|
116
127
|
|
|
128
|
+
def settle_grader_rerun(dataset_id, run, timeout)
|
|
129
|
+
case run["status"]
|
|
130
|
+
when "completed"
|
|
131
|
+
nil
|
|
132
|
+
when "errored"
|
|
133
|
+
raise GraderRerunError.new(
|
|
134
|
+
"Grader re-run on dataset #{dataset_id} errored: #{run["error"] || "no reason recorded"}",
|
|
135
|
+
run:
|
|
136
|
+
)
|
|
137
|
+
else
|
|
138
|
+
raise GraderRerunTimeoutError.new(
|
|
139
|
+
"Grader re-run #{run["id"]} on dataset #{dataset_id} is still #{run["status"]} after #{timeout} seconds. " \
|
|
140
|
+
"It keeps going on Bitfab. Read it later with get_grader_rerun(#{dataset_id.inspect}, run_id: #{run["id"].inspect}).",
|
|
141
|
+
run:
|
|
142
|
+
)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
117
146
|
def dataset_path(dataset_id, suffix = "")
|
|
118
147
|
"/api/sdk/datasets/#{URI.encode_www_form_component(dataset_id)}#{suffix}"
|
|
119
148
|
end
|
data/lib/bitfab/version.rb
CHANGED