Skip to content

exp run: date values are not treated as strings #5868

@phipsgabler

Description

@phipsgabler

Bug Report

Description

Parameters to be stored in a JSON file that are ISO dates (yyyy-mm-dd) are automatically treated as date values by exp run, it seems -- which then errors when writing them to JSON.

Reproduce

Clone this test repo and try the following:

$ dvc repro dostuff --force  # originally, the parameter is "2021-01-01"
Running stage 'dostuff':                                              
> python dostuff.py
Param is: 2021-01-01
Use `dvc push` to send your updates to remote storage.  
              
$ dvc exp run -S params.json:testparam="2021" # set to something else -- works
Running stage 'dostuff':                                              
> python dostuff.py
Param is: 2021
Updating lock file 'dvc.lock'                                         
...

$ dvc exp run -S params.json:testparam="2021-02-01" # set to a date -- fails
ERROR: unexpected error - Object of type date is not JSON serializable
...

Both 2021 and 2021-02 work and are parsed as an integer and a string, respectively.

Expected

Things should not be parsed as dates when I didn't say so; or at least, if they are parsed, this should work. Otherwise, I'd expect everything to be passed as an uninterpreted string.

Environment information

Output of dvc doctor:

DVC version: 2.0.18 (deb)
---------------------------------
Platform: Python 3.8.9 on Linux-5.4.0-72-generic-x86_64-with-glibc2.4
Supports: All remotes
Cache types: <https://error.dvc.org/no-dvc-cache>
Caches: local
Remotes: None
Workspace directory: ext4 on /dev/mapper/vg0-root
Repo: dvc, git

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions