Dvc: config.get(section, opt) doesnt coerce value to appropriate type

Created on 15 Jan 2020  路  2Comments  路  Source: iterative/dvc

config.get(section, opt) returns value as str when expects int

Steps for reproduce

  1. Add number value into config section
    [core] checksum_jobs = 10
    SECTION_CORE_CHECKSUM_JOBS: All(Coerce(int), Range(1))
  2. Run cli
  3. config.get returns str
    >>> from dvc.repo import Repo >>> r = Repo() >>> r.config.get('core', 'checksum_jobs') '10' # but expects to get 10 as int >>> r.config.config.get('core', {}).get('checksum_jobs') 10
    Please provide information about your setup
0.81.3+aec778
Linux (pip)
enhancement p3-nice-to-have

Most helpful comment

@JIoJIaJIu, this is because configobject is a wrapper of configparser.

ConfigObject has methods like .as_int() to work around this (unnecessary, in my opinion).
I would rethink the current Config implementation.

Referenc: ConfigObject docs

All 2 comments

@JIoJIaJIu, this is because configobject is a wrapper of configparser.

ConfigObject has methods like .as_int() to work around this (unnecessary, in my opinion).
I would rethink the current Config implementation.

Referenc: ConfigObject docs

The design of our Config object is not clear and simple) We discussed refactoring it with @efiop, but it is still waiting and we are working around things like that for now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dmpetrov picture dmpetrov  路  35Comments

drorata picture drorata  路  46Comments

kevin-hanselman picture kevin-hanselman  路  37Comments

shcheklein picture shcheklein  路  36Comments

danfischetti picture danfischetti  路  41Comments