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

Move repository into sat #110

Merged
merged 8 commits into from
Jan 8, 2016
Merged

Move repository into sat #110

merged 8 commits into from
Jan 8, 2016

Conversation

cournape
Copy link
Contributor

@cournape cournape commented Jan 3, 2016

This PR implements a simplified Repository class to replace the enstaller one in simplesat:

  1. It works w/ any enstaller PackageMetadata subclass
  2. It only support the find_package* and update methods.
  3. Internally, the instance keeps a sorted list of package names to allow reproducible iteration over a repository, independently of the order in which packages have been added.

This is the penultimate PR to remove the dependency on enstaller. The last one will implement a leaner PackageMetadata class.

@johntyree

This Repository class is a simplified version of the one in enstaller.
It also improves on the enstaller one by supporting deterministic
iteration: for a given set of packages, iterating over the repository
will always yield the packages in the same order, independently of how
packages were added.
@cournape cournape added this to the 0.2 milestone Jan 3, 2016
@cournape cournape mentioned this pull request Jan 7, 2016
self._name_to_packages[package_metadata.name].append(package_metadata)
# Fixme: this should not be that costly as long as we don't have
# many versions for a given package.
self._name_to_packages[package_metadata.name].sort(
Copy link

Choose a reason for hiding this comment

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

What is the argument against making PackageMetadata orderable and using insort here too?

Copy link

Choose a reason for hiding this comment

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

Looking at the definition of PackageMetadata, the sorting would occur on (name, version, dependencies, python_tag), which I think would be acceptable here.

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 think I benchmarked that for small sequences, sorting every time is faster than calling insort, but let me check again since a lot of the code changed since.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so there is no measurable speed change in my limited test, but to work properly, it requires a change in PackageMetadata (as they are not orderable ATM). Since I will rewrite PackageMetadata to be in SAT, I would suggest to make that change then

@sjagoe
Copy link

sjagoe commented Jan 8, 2016

One question, otherwise LGTM


class Repository(object):
"""
A Repository is a set of package, and knows about which package it
Copy link
Contributor

Choose a reason for hiding this comment

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

"packages"

We also return a tuple instead of a list in find_packages, so that the
output is 'naturally' immutable.
@sjagoe
Copy link

sjagoe commented Jan 8, 2016

LGTM

cournape added a commit that referenced this pull request Jan 8, 2016
@cournape cournape merged commit 90ba02b into master Jan 8, 2016
@cournape cournape deleted the move_repository_into_sat branch January 8, 2016 15:11
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.

3 participants