Skip to content

Commit c46a34d

Browse files
committed
modify the callback test to allow for cross machine serialization
1 parent 2d3e321 commit c46a34d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

python/interpret-core/tests/glassbox/ebm/test_ebm.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,16 +1305,17 @@ def test_reorder_classes_strings():
13051305

13061306
def test_callbacks():
13071307
def callback_generator(minutes):
1308-
import time
1309-
end_time = None
1310-
def callback(bag_index, step_index, progress, metric):
1311-
nonlocal end_time
1312-
if end_time is None:
1313-
end_time = time.monotonic() + minutes * 60.0
1314-
return False
1315-
else:
1316-
return time.monotonic() > end_time
1317-
return callback
1308+
class Callback:
1309+
def __init__(self, minutes):
1310+
self.minutes = minutes
1311+
def __call__(self, bag_index, step_index, progress, metric):
1312+
import time
1313+
if not hasattr(self, 'end_time'):
1314+
self.end_time = time.monotonic() + self.minutes * 60.0
1315+
return False
1316+
else:
1317+
return time.monotonic() > self.end_time
1318+
return Callback(minutes)
13181319

13191320
X, y, names, types = make_synthetic(output_type="float", n_samples=10000)
13201321

0 commit comments

Comments
 (0)