Skip to content

NF: immutable packages#121

Merged
yarikoptic merged 7 commits intoReproNim:masterfrom
chaselgrove:nf-immutable-packages
Nov 20, 2017
Merged

NF: immutable packages#121
yarikoptic merged 7 commits intoReproNim:masterfrom
chaselgrove:nf-immutable-packages

Conversation

@chaselgrove
Copy link
Contributor

This PR makes DEBPackage immutable so they are hashable (and usable in sets -- my ultimate motivation :) ).

@codecov-io
Copy link

codecov-io commented Oct 13, 2017

Codecov Report

Merging #121 into master will decrease coverage by 0.15%.
The diff coverage is 90.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #121      +/-   ##
==========================================
- Coverage   72.49%   72.33%   -0.16%     
==========================================
  Files         116      116              
  Lines        7791     7791              
==========================================
- Hits         5648     5636      -12     
- Misses       2143     2155      +12
Impacted Files Coverage Δ
niceman/distributions/debian.py 90.14% <90.47%> (-0.99%) ⬇️
niceman/distributions/vcs.py 80% <0%> (-4.09%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ccba01c...66fe52d. Read the comment docs.

Copy link
Member

@yarikoptic yarikoptic left a comment

Choose a reason for hiding this comment

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

we were dreaming of doing that awhile back:
https://github.com/ReproNim/niceman/blob/a507746847a1466c4c4ac1e64197d77f5250ca81/niceman/distributions/debian.py#L73
but decided not to bother "for now", so may be it is time. I am not certain though that we wouldn't at some point need to introduce changes to existing ones, where copy wouldn't be way to go... but I guess until then, it is all ok.
I guess the tests in whatever you need sets of packages for would excercise this fact (immutability) so would fail if we happen to revert "by mistake" ;)

return None

# prep our pkg object:
# prep our pkg object:
Copy link
Member

Choose a reason for hiding this comment

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

why dedent?

source_version = attr.ib(default=None)
versions = attr.ib(default=None)
install_date = attr.ib(default=None)
version = attr.ib(default=None, hash=True)
Copy link
Member

Choose a reason for hiding this comment

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

it is hard(er) to differentiate between those with True or False. The default for hash seems to be True, so I would prefer if , hash=True ones were removed, then it would be easier to see which fields we consider not important

versions = attr.ib(default=None)
install_date = attr.ib(default=None)
version = attr.ib(default=None, hash=True)
architecture = attr.ib(default=None, hash=False)
Copy link
Member

Choose a reason for hiding this comment

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

there could be multiple instances of the package with the same name and version but different architecture

$> dpkg -l zlib1g:*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                 Version         Architecture    Description
+++-====================-===============-===============-==============================================
ii  zlib1g:amd64         1:1.2.8.dfsg-5  amd64           compression library - runtime
ii  zlib1g:i386          1:1.2.8.dfsg-5  i386            compression library - runtime

so should participate in the hashing

@yarikoptic
Copy link
Member

yarikoptic commented Oct 13, 2017

Also note that you would conflict in changes with #115, so might be better to wait for that one to get merged first (before working out other classes etc)

@rbuccigrossi
Copy link
Contributor

I merged #115 so this can proceed (though I will make a new pull request to resolve some review suggestions). GitHub claims that there are still no conflicts in this branch...

@rbuccigrossi
Copy link
Contributor

(I spoke too soon... as soon as I submitted the comment github noted some conflicts in this branch... sorry)

@chaselgrove
Copy link
Contributor Author

Updated in response to comments.

@yarikoptic
Copy link
Member

conflicts should be resolved before itcould be considered for merging

@yarikoptic
Copy link
Member

@chaselgrove ping

@yarikoptic
Copy link
Member

@chaselgrove ping ping

@chaselgrove
Copy link
Contributor Author

Fixed conflicts.

@yarikoptic yarikoptic merged commit 7f0d367 into ReproNim:master Nov 20, 2017
@chaselgrove chaselgrove deleted the nf-immutable-packages branch December 4, 2017 19:16
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.

4 participants