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

Do not append duplicates when using device_name parameter. #2850

Merged
merged 5 commits into from
Jan 3, 2019

Conversation

masci
Copy link
Contributor

@masci masci commented Jan 2, 2019

What does this PR do?

Avoids appending multiple times the same tag when the (deprecated) device_name param is used. This will also fix tests on master.

PR is marked as no-changelog because the commit that introduced the bug (#2822) hasn't been released yet.

Motivation

Avoid sending fatter payloads because of duplicates

Review checklist

  • PR has a meaningful title or PR has the no-changelog label attached
  • Feature or bugfix has tests
  • Git history is clean
  • If PR impacts documentation, docs team has been notified or an issue has been opened on the documentation repo
  • If PR adds a configuration option, it has been added to the configuration file.

zippolyte
zippolyte previously approved these changes Jan 2, 2019
gzussa
gzussa previously approved these changes Jan 2, 2019
normalized_tags = self._normalize_tags_type(tags)

return normalized_tags
return self._normalize_tags_type(out_tags)
Copy link
Contributor

Choose a reason for hiding this comment

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

To avoid double list creation, let's just revert to working commit here:

normalized_tags = self._normalize_tags_type(tags)
if device_name:
self._log_deprecation("device_name")
normalized_tags.append("device:{}".format(device_name))
return normalized_tags

Copy link
Contributor

Choose a reason for hiding this comment

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

It fixes CI for #2848

Copy link
Contributor

Choose a reason for hiding this comment

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

another solution could be

t = copy.deepcopy(tags)
if device_name:
    self._log_deprecation("device_name")
    t.append("device:{}".format(device_name))
normalized_tags = self._normalize_tags_type(t)
return normalized_tags```

Copy link
Contributor

Choose a reason for hiding this comment

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

@ofek The point is to also normalize the device tag, so we can't really go back to this

@masci masci dismissed stale reviews from gzussa and zippolyte via 09397b2 January 3, 2019 12:03
Copy link
Contributor

@gzussa gzussa left a comment

Choose a reason for hiding this comment

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

Thanks for this refactoring. I like it however names seems hard to grasp, especially for _normalize_type which is now a very generic method.

normalized_tags.append(tag)

return normalized_tags

def _normalize_type(self, data):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we rename this to reflect more what it does _encode_to_bytes or _to_bytes?

@codecov-io
Copy link

Codecov Report

Merging #2850 into master will decrease coverage by 7.48%.
The diff coverage is 81.57%.

@@            Coverage Diff             @@
##           master    #2850      +/-   ##
==========================================
- Coverage   84.48%   76.99%   -7.49%     
==========================================
  Files         630       50     -580     
  Lines       36958     3582   -33376     
  Branches     4416      414    -4002     
==========================================
- Hits        31223     2758   -28465     
+ Misses       4434      724    -3710     
+ Partials     1301      100    -1201

Copy link
Contributor

@gzussa gzussa left a comment

Choose a reason for hiding this comment

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

🥇

@gzussa gzussa mentioned this pull request Jan 3, 2019
5 tasks
@masci masci merged commit e4b43b1 into master Jan 3, 2019
@masci masci deleted the massi/device-name branch January 3, 2019 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants