Skip to content

Leonlu2/inequality issue time value #1124

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

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from

Conversation

LeonLu2
Copy link
Collaborator

@LeonLu2 LeonLu2 commented Apr 6, 2023

closes #1085

Prerequisites:

  • Unless it is a documentation hotfix it should be merged against the dev branch
  • Branch is up-to-date with the branch to be merged with, i.e. dev
  • Build is successful
  • Code is cleaned up and formatted

Summary

  1. add inequality operators handler for time_values and issues in server
  2. add inequality tests in test_covidcast.py accordingly
  3. other minor changes

LeonLu2 added 3 commits April 5, 2023 17:27
2. add test in test_covidcast.py accordingly
3. refactor minor places
2. add test for inequality in issues
3. minor changes
@LeonLu2 LeonLu2 requested a review from krivard April 6, 2023 00:07
Copy link
Contributor

@krivard krivard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buncha questions to get through first

part = part[len(operator):]
if not part:
raise ValidationFailedException("missing parameter: date after the inequality operator")
return (inequality_operator,), part
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: using a length-1 tuple here feels weird

later on we're using the tuple type information to engage the inequalities logic instead of the range logic, so it's clearly needed, but it feels unsatisfying regardless

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @rzats do you have any ideas for how we can more clearly indicate that a date parameter value is an inequality? the return value from this function is read in the date span processing at _query.py:45, dates.py:125, and dates.py:147, where inequalities need to be handled differently from other kinds of spans.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I can see what this PR is going for and there might be a better way to handle the inequalities. Right now this is returning a single-element tuple to fit within the following type structure;

IntRange: TypeAlias = Union[Tuple[int, int], int]
TimeValues: TypeAlias = Sequence[IntRange]

A clean solution would be to add a new type alias called IntStrRange which is a union of Tuple[int, int], int and a third type - either str if we just want to know what the inequality operator is or Tuple[str, int] if we want the date too.

TimeValues can then be replaced with a Sequence[IntStrRange], and we can then refactor the date span processing functions where TimeValues was previously used.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@krivard krivard self-requested a review April 13, 2023 21:20
Copy link
Contributor

@krivard krivard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Could merge as is but I'd like to hear Rostyslav's thoughts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Permit inequalities for issue, time_value
3 participants