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

update: default no longer returning RETIRED devices from get_devices #796

Merged
merged 4 commits into from
Nov 15, 2023

Conversation

krneta
Copy link
Contributor

@krneta krneta commented Nov 13, 2023

Issue #, if available:
#448

Description of changes:

Testing done:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@krneta krneta requested a review from kshitijc November 13, 2023 18:27
@krneta krneta requested a review from a team as a code owner November 13, 2023 18:27
Copy link

codecov bot commented Nov 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7f28109) 100.00% compared to head (8dea875) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #796   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          129       129           
  Lines         8372      8374    +2     
  Branches      1865      1866    +1     
=========================================
+ Hits          8372      8374    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@krneta krneta requested a review from ajberdy November 13, 2023 18:58
Comment on lines 572 to 574
statuses (Optional[list[str]]): device status list, default is `None`. When `None`
is used, RETIRED devices will not be returned. To include RETIRED devices in
the results, add `RETIRED` to the list passed to this parameter.
Copy link
Contributor

Choose a reason for hiding this comment

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

We typically state the default semantically used, even if the function signature has =None. Here, I believe the default is ["ONLINE", "OFFLINE"]. We can add a note in the doc string that the default behavior is to filter out "RETIRED"

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 am generally not a fan of listing this stuff out here since it can more easily go out-of-date (like if we add another state). Then, for users of older versions of the BDK, it would actually be wrong as it would return more than those two.

Copy link
Contributor

Choose a reason for hiding this comment

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

The docs are versioned by release, so I'm not sure I see the issue. The doc string is wrong for older versions of the bdk regardless; I think it's just a question of the phrasing here

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see what you mean by listing stuff out. Would it be better to just add a new parameter filter_retired=True that kicks in when statuses is None to separate the logic?

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, butI think it would be confusing to add a parameter that can have a direct opposite effect of another parameter (ie. have a filter_retired=True and statuses=["RETIRED"])

Copy link
Contributor

Choose a reason for hiding this comment

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

I see that "default is None" is consistent with the other doc strings. I don't love how the argument doc strings don't actually specify the default behavior, just the default value of the parameter.

I'd prefer to see these called out as filters explicitly, maybe even just changing "device name list, default is None" to "device name filter, default is None". Then we could clarify statuses like "device status filter, default is None. When None is used, RETIRED devices will not be returned. To include RETIRED devices in the results, use a filter including "RETIRED" for this parameter."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call

Comment on lines +650 to +651
if statuses is None and result["deviceStatus"] == "RETIRED":
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I missing something, or does this not actually impact the search_devices call? Does this fix our time issue? It looks like it still gets every device but then filters after; is this a limitation of the search devices api?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does fix our time issue. Even though the API returns all values, we will filter our the retired ones. This means that when we actually do get_device for all returned devices, we will be doing many fewer calls.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah that's the piece I was missing, that makes sense if get_device is what's taking a long time

ajberdy
ajberdy previously approved these changes Nov 13, 2023
Copy link
Contributor

@ajberdy ajberdy left a comment

Choose a reason for hiding this comment

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

Approved with some doc nits, feel free to take or leave

@krneta
Copy link
Contributor Author

krneta commented Nov 14, 2023

Approved with some doc nits, feel free to take or leave

Done.

provider_names (Optional[list[str]]): provider name list, default is `None`
statuses (Optional[list[str]]): device status filter, default is `None`. When `None`
is used, RETIRED devices will not be returned. To include RETIRED devices in
the results, use a filter that includes `RETIRED` for this parameter.
Copy link
Contributor

Choose a reason for hiding this comment

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

Smallest nit: in this context we mean the string "RETIRED", unless we have an enum somewhere defining RETIRED

ajberdy
ajberdy previously approved these changes Nov 14, 2023
Copy link
Contributor

@ajberdy ajberdy left a comment

Choose a reason for hiding this comment

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

Looks good! Smallest optional nit

ajberdy
ajberdy previously approved these changes Nov 14, 2023
@krneta krneta requested review from kshitijc and removed request for kshitijc November 14, 2023 21:51
@krneta krneta merged commit f1a549a into main Nov 15, 2023
22 checks passed
@krneta krneta deleted the get_devices branch November 15, 2023 18:00
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.

2 participants