History: allow floating point step numbers
Before this we threw an exception on them. TensorFlow just applies `int()` to
step numbers. That seems kind of wrong, but it'd be good if we at least don't
crash. We now print a warning if we round the step number.
Fixes
@@ -125,12 +125,20 @@ class History(object):
if not self.batched:
self._write()
else:
- if not isinstance(step, numbers.Integral):
+ if not isinstance(step, numbers.Number):
raise wandb.Error(
- "Step must be an integer, not {}".format(step))
- elif step < self._steps:
+ "Step must be a number, not {}".format(step))
+ else:
+ if step != round(step):
+ # tensorflow just applies `int()`. seems a little crazy.
+ wandb.termwarn('Non-integer history step: {}; rounding.'.format(step))
+
+ # the backend actually handles floats right now. seems a bit weird to let those through though.
+ step = int(round(step))
+
+ if step < self._steps:
wandb.termwarn(
- "Adding to old History rows isn't currently supported. Step {} < {} dropping: {}".format(step, self._steps, row))
+ "Adding to old History rows isn't currently supported. Step {} < {}; dropping {}.".format(step, self._steps, row))
return
elif step == self._steps:
pass
