Closed as not planned
Description
Bug Report
dvc exp run --set-param lr=0.000001
Here's the error:
Traceback (most recent call last):
File "/Users/milecia/Repos/checkpoints-tutorial/train.py", line 123, in <module>
main()
File "/Users/milecia/Repos/checkpoints-tutorial/train.py", line 110, in main
train(model, x_batch, y_batch, params["lr"], params["weight_decay"])
File "/Users/milecia/Repos/checkpoints-tutorial/train.py", line 45, in train
optimizer = torch.optim.Adam(model.parameters(), lr=lr,
File "/Users/milecia/Repos/checkpoints-tutorial/.venv/lib/python3.9/site-packages/torch/optim/adam.py", line 36, in __init__
if not 0.0 <= lr:
TypeError: '<=' not supported between instances of 'float' and 'str'
Description
The problem is that the yaml
library only supports yaml 1.1 when DVC uses yaml1.2. This issue seems to happen when exponents are generated.
The data science community and the Python ecosystem in general is stuck in YAML1.1. We could try to be compatible by generating exponents with the dot at least, that way we could be compatible on both sides. I am not sure how straightforward the fix this will be though. (and this should only affect --set-param
, not the dvc.lock and yaml files).
Reproduce
- Go to the checkpoints tutorial repo
- Replace
from ruamel.yaml import YAML
withimport yaml
- Replace these 2 lines
yaml=YAML(typ='safe') params = yaml.load(f)
withparams = yaml.safe_load(f)
- dvc exp run --set-param lr=0.000001
- The
lr
in params.yaml should be updated to an exponent and you get the error above
Expected
Running dvc exp run --set-param lr=0.000001
should start running the experiment with the new lr
Environment information
Output of dvc doctor
:
DVC version: 2.1.0 (brew)
---------------------------------
Platform: Python 3.9.4 on macOS-11.3-x86_64-i386-64bit
Supports: azure, gdrive, gs, http, https, s3, ssh, oss, webdav, webdavs