Skip to content

Yaml formatting with date-time values #723

@elenya-grant

Description

@elenya-grant

This came up in some peak-load management PRs (and was noted by @vijay092). In these PRs, there are two required control parameters that are supposed to be in date-time format as HH:MM:SS

peak_range:
   start: 12:00:00
   end: 20:00:00

When these are loaded with load_yaml(), the values are converted to seconds from midnight. Aka

config = load_yaml(filepath)
config["peak_range"]["start"] # this value is an integer of 43200
config["peak_range"]["end"] # this value is an integer of 72000

I think that two options to handle this are:

  • allow string formatting in the pre-commit for yaml files when values have :. This means that the yaml files would be able to look like:
peak_range:
   start: "12:00:00"
   end: "20:00:00"

OR

  • add something into load_yaml() that prevents this conversion. So that the yaml file values formatted as HH:MM:SS are loaded as strings. This stack overflow post may have some options for this

@jaredthomas68 - how did you handle this in your peak-load PR?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions