Skip to content

Disable automatic conversion of date strings in from_dotlist #95

@shuki-hpcnt

Description

@shuki-hpcnt

Issue

When instantiating OmegaConf from from_dotlist, yaml loader tries to convert date-formatted strings into date type, therefore raises error when validating the type of values.

 OmegaConf.from_dotlist(["my_date=2019-11-11"])

>>>

.../site-packages/omegaconf/config.py in _prepare_value_to_add(self, key, value)
    448         if not Config.is_primitive_type(value):
    449             full_key = self.get_full_key(key)
--> 450             raise ValueError("key {}: {} is not a primitive type".format(full_key, type(value).__name__))
    451
    452         if self._get_flag('readonly'):

ValueError: key my_date: date is not a primitive type

This error also blocks the overriding of configuration values by using cli arguments in hydra.

Potential workaround

Could be solved by removing implicit timestamp resolvers in default yaml.SafeLoader.
(Related stackoverflow: https://stackoverflow.com/questions/34667108/ignore-dates-and-times-while-parsing-yaml)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions