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

Allow multiple thresholds for measurements #1148

Merged
merged 5 commits into from
Feb 7, 2023

Conversation

joverlee521
Copy link
Contributor

@joverlee521 joverlee521 commented Feb 2, 2023

Description of proposed changes

Adds the ability to export multiple thresholds for the measurements JSON.

Note that this will produce measurements JSONs that will only have the
"thresholds" array but not the deprecated single "threshold" value. This
means the thresholds will not be displayed in Auspice v2.42.0 or lower
because Auspice still expects the single "threshold" value.

Testing

Added additional Cram test for multiple threshold values.

Checklist

  • Add a message in CHANGES.md summarizing the changes in this PR that are end user focused. Keep headers and formatting consistent with the rest of the file.

@joverlee521 joverlee521 requested a review from huddlej February 2, 2023 01:47
@codecov
Copy link

codecov bot commented Feb 2, 2023

Codecov Report

Base: 68.20% // Head: 68.17% // Decreases project coverage by -0.04% ⚠️

Coverage data is based on head (e9ddbcb) compared to base (ebdcd23).
Patch coverage: 20.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1148      +/-   ##
==========================================
- Coverage   68.20%   68.17%   -0.04%     
==========================================
  Files          63       63              
  Lines        6749     6752       +3     
  Branches     1653     1654       +1     
==========================================
  Hits         4603     4603              
- Misses       1838     1841       +3     
  Partials      308      308              
Impacted Files Coverage Δ
augur/measurements/export.py 29.52% <20.00%> (-0.87%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@joverlee521 joverlee521 force-pushed the multi-threshold-measurements branch from 9015dd3 to 3a0af9f Compare February 2, 2023 22:52
Comment on lines +210 to +213
# Convert deprecated single threshold value to list if "thresholds" not provided
single_threshold = collection_config.pop("threshold", None)
if single_threshold is not None and "thresholds" not in collection_config:
collection_config["thresholds"] = [single_threshold]
Copy link
Member

Choose a reason for hiding this comment

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

I'm not clear on the expected deprecation/support story here with regards to Auspice. There's no existing Auspice version that uses thresholds but with this Augur will only produce thresholds, thus making them talk past each other? It seems like this arrangement is likely to lead to harsh compatibility constraints, even once there is a release of Auspice that uses thresholds.

It seems to me that Augur could instead produce threshold as a single number when only one threshold is provided, thus only raising compatibility issues if multiple thresholds are actually provided. Then any existing usage with a single threshold (i.e. all uses of it currently, right?) won't have any compatibility issues with Augur and Auspice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, @huddlej and I had a brief conversation about this in Slack.

My thought here is that we will want to drop the deprecated threshold key as some point, so might as well do it now when there aren't that many (known) users of the command/feature.

Copy link
Member

Choose a reason for hiding this comment

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

continuing this discussion in another thread (probably shouldn't have split the two ideas in the first place)

Comment on lines +92 to +103
"thresholds": {
"description": "Numeric measurement thresholds to be displayed as solid grey lines across subplots. Optional -- if not provided, no threshold will be displayed.",
"type": "array",
"minItems": 1,
"items": {
"description": "A numeric measurement threshold value.",
"type": "number"
}
},
"threshold": {
"description": "A numeric measurement threshold to be displayed as a single grey line shared across subplots. Optional -- if not provided, no threshold will be displayed",
"deprecated": true,
"description": "DEPRECATED - A numeric measurement threshold to be displayed as a single grey line shared across subplots. Will be ignored if 'thresholds' is provided.",
Copy link
Member

Choose a reason for hiding this comment

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

Instead of deprecating one key and adding another, did you consider making the existing threshold key take either a single number or an array of numbers? This doesn't solve the compatibility issue with Auspice, but it does simplify the schema a bit.

I guess it does mean that Auspice may barf on threshold: […] instead of merely ignoring thresholds: […]. Not entirely sure how gracefully it'd handle that type change, but I think it'd work out because of the type test for whether to display the toggle or not and that x1/x2 for the SVG line would get set to NaN.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered it at first, but thought having two separate keys would make deprecating the single value thresholds easier to explain.

Copy link
Member

@tsibley tsibley Feb 7, 2023

Choose a reason for hiding this comment

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

(from another comment)

My thought here is that we will want to drop the deprecated threshold key as some point

Ah, my thinking was that we wouldn't have to drop support for a single int and would indefinitely accept both a single value and list of values, e.g., threshold: x and threshold: [x, y, z].

Per my other comment, Augur would then continue to produce threshold: x when only a single value is given.

This combination maximizes compatibility without much effort on our part.

IMO, the "deprecation" of threshold vs. thresholds is unfortunate, because it's not really a deprecation, it's a removal: after version X, Augur won't produce it and thus if you have older Auspice, you're stuck on the Augur version prior to X (or stuck twiddling the final JSON manually).

Marks the previous single value threshold as deprecated, but is still
supported. The single value threshold will be ignored if the multiple
value thresholds array is provided.
Updates the option `--threshold` to accept multiple values.
If a single "threshold" value is provided via the `--collection-config`,
it will be converted to a "thresholds" array in the measurements JSON.

Note, that this will produce measurements JSONs that will only have the
"thresholds" array but not the deprecated single "threshold" value. This
means the thresholds will not be displayed in Auspice v2.42.0 or lower
because Auspice still expects the single "threshold" value.
The default argparse abbreviation matching¹ allows us to update the
option to `--thresholds` to match the key in the produced JSON while
still supporting the previous single `--threshold` option.

Updated one of the Cram tests to use the plural form while leaving the
others in their original singular form to ensure both work as expected.

¹ https://docs.python.org/3.7/library/argparse.html#argument-abbreviations-prefix-matching
Copy link
Contributor

@huddlej huddlej left a comment

Choose a reason for hiding this comment

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

Thank you for all of your work on this, @joverlee521! This looks good to me with a minor text edit exception mentioned below. I agree with @tsibley that there could be some painful version mismatches between Augur and Auspice, but I'm slightly ok with this because:

  1. we will at least release this change as a major/breaking release of Augur
  2. new Auspice will gracefully handle older measurements JSONs we've already generated and the new ones
  3. when there is a mismatch where old Auspice gets thresholds from new Augur, the thresholds will completely disappear from the measurements panel which is an easier bug to detect than somehow falling back to one threshold to display, etc.

The first two points should mean that anyone who uses the Docker image or managed Conda environment won't notice anything when they upgrade. The users who will experience this most will be folks like many on our team who have "ambient" installations of both Augur and Auspice and who will need to remember to update both. Maybe to support these folks, we should include a specific note in the CHANGES of this PR's major release that users will want to update Auspice at the same time they update to Augur 21.0.0.

Reflect the change that the `--show-threshold` option will apply to
one or multiple thresholds.
Copy link
Member

@tsibley tsibley left a comment

Choose a reason for hiding this comment

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

Added a few responses up thread and a few thoughts below, but none blocking. 👍 for merge at will.

To @huddlej's comments:

we will at least release this change as a major/breaking release of Augur

It's a good practice, and useful for some downstream folks, but most of the time major versions for breaking changes is probably really only cover for "well, we told you it would break". ;-)

The first two points should mean that anyone who uses the Docker image or managed Conda environment won't notice anything when they upgrade.

This is a good point, esp. as we've pushed more people to those managed runtimes. It's a good mitigation.

Maybe to support these folks, we should include a specific note in the CHANGES of this PR's major release that users will want to update Auspice at the same time they update to Augur 21.0.0.

That'd be great!

@joverlee521 joverlee521 force-pushed the multi-threshold-measurements branch from 9eec326 to e9ddbcb Compare February 7, 2023 20:05
@joverlee521
Copy link
Contributor Author

Rebased onto master and added entry to changelog specify that users will need to update to Auspice v2.43.0 for thresholds to be properly displayed.

@joverlee521 joverlee521 merged commit 03a9188 into master Feb 7, 2023
@joverlee521 joverlee521 deleted the multi-threshold-measurements branch February 7, 2023 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

3 participants