Fix n_rounds is not an integer error
This fix explicitly converts n_rounds to int as it can be of float type if any of the operands are float. For example, when we set total_timesteps = 1e5. The float type gives an error on line 422 in range as it requires an integer.
Alternatively, we can also ensure that total_timesteps and gen_train_timesteps are integers by explicitly converting them if given in the scientific notation.
Codecov Report
Merging #564 (8d08355) into master (978f74f) will increase coverage by
0.00%. The diff coverage is100.00%.
@@ Coverage Diff @@
## master #564 +/- ##
=======================================
Coverage 97.58% 97.58%
=======================================
Files 87 87
Lines 8557 8566 +9
=======================================
+ Hits 8350 8359 +9
Misses 207 207
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/imitation/scripts/train_adversarial.py | 94.87% <100.00%> (+0.13%) |
:arrow_up: |
| .../imitation/scripts/train_preference_comparisons.py | 97.26% <100.00%> (+0.29%) |
:arrow_up: |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
The type signature says that total_timesteps should be an int, so it's really the caller's fault that it's passing a float in the first place.
How about making train_adversarial script do int(total_timesteps)? I think that should fix this issue and any others that are downstream of total_timesteps being the wrong type.
Alternatively we could do type validation in train_adversarial to force user to specify integer in config, e.g. int(1e5), but I feel OK about being a bit forgiving in the config format for brevity.
How about making
train_adversarialscript doint(total_timesteps)? I think that should fix this issue and any others that are downstream oftotal_timestepsbeing the wrong type.
That should also fix the error. As many of the config files use the scientific notation for total_timesteps, should I make this change in all of the script files like train_imitation, train_adversarial, train_preference_comparisons, etc?
That should also fix the error. As many of the config files use the scientific notation for total_timesteps, should I make this change in all of the script files like train_imitation, train_adversarial, train_preference_comparisons, etc?
Making the change in all the scripts sounds good to me, thanks!
Looks like this PR was abandoned. I took the liberty to implement what you agreed upon.
@AdamGleave would you review this?
Are no changes needed in
train_imitation.py?
No should have mentioned it. In train_imitation.py it is already cast to int.