Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter: Support relative dates for --min-date and --max-date #740

Merged
merged 5 commits into from
Apr 11, 2022

Commits on Apr 6, 2022

  1. filter: Add support for relative dates in --min-date and --max-date

    The relative dates are parsed by `numeric_date` which uses datetime.date.today() to translate the relative date to an absolute date.
    
    Relative dates are positive duration values following the ISO 8601 duration syntax
    e.g. `--min-date 1Y2W5D` for 1 year, 2 weeks and 5 days ago or `--max-date 1D` for yesterday
    
    This also adds a package dependency `isodate` to parse the duration string.
    benjaminotter authored and victorlin committed Apr 6, 2022
    Configuration menu
    Copy the full SHA
    873a70a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    eafadef View commit details
    Browse the repository at this point in the history
  3. Error on invalid --min-date/--max-date

    The previous change to support relative dates also refactored so that an invalid date does not raise any error, which is unwanted.
    Prior to that change, there was one try/catch so treetime.utils.numeric_date would handle all these invalid dates.
    
    Explicitly raising from augur.filter.numeric_date is one step in a better direction, though still not a good solution since argparse does not expose these errors.
    More: https://stackoverflow.com/q/38340252
    victorlin committed Apr 6, 2022
    Configuration menu
    Copy the full SHA
    6a88293 View commit details
    Browse the repository at this point in the history

Commits on Apr 7, 2022

  1. Improve error message for invalid dates

    - Expose the invalid date error message using argparse.ArgumentTypeError
    - Split out the text describing supported dates into a constant variable, since it is used in 3 places now
    victorlin committed Apr 7, 2022
    Configuration menu
    Copy the full SHA
    a2ac8e5 View commit details
    Browse the repository at this point in the history

Commits on Apr 11, 2022

  1. Symmetrically test relative dates for --min-date/--max-date

    Previously, some tests for --max-date were not done for --min-date and vice-versa.
    Added tests and re-ordered so that similar tests are adjacent.
    victorlin committed Apr 11, 2022
    Configuration menu
    Copy the full SHA
    29a5a65 View commit details
    Browse the repository at this point in the history