Skip to content

Datetime object in hydra config #2746

Answered by Jasha10
nilsleh asked this question in Q&A
Discussion options

You must be logged in to vote

@nilsleh yes, this is possible using _args_ to pass positional arguments to datetime.datetime.strptime:

my_class:
  _target_: myApp.MyClass
  time_range:
    - _target_: datetime.datetime.strptime
      _args_:
      - "2020-01-01"
      - "%Y-%m-%d"
    - _target_: datetime.datetime.strptime
      _args_:
        - "2020-05-01"
        - "%Y-%m-%d"

Docs on _args_: https://hydra.cc/docs/advanced/instantiate_objects/overview/

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nilsleh
Comment options

Answer selected by nilsleh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants