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
resolve #5610 add PrefixData, SubdirData, and PackageCacheData to conda/api.py #6922
Changes from 5 commits
73063d5
2fdedd5
9ee23b1
36fb4d6
586973a
f688050
bfed74b
22c72f2
f233fcf
87fa42f
8db7a2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,110 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
from .core.solve import Solver # NOQA | ||
Solver = Solver # lgtm [py/redundant-assignment] | ||
from .common.constants import NULL | ||
from .core.package_cache_data import PackageCacheData as _PackageCacheData | ||
from .core.prefix_data import PrefixData as _PrefixData | ||
from .core.solve import Solver as _Solver, DepsModifier as _DepsModifier | ||
from .core.subdir_data import SubdirData as _SubdirData | ||
from .models.channel import Channel | ||
|
||
|
||
DepsModifier = _DepsModifier | ||
|
||
|
||
class Solver(object): | ||
|
||
def __init__(self, prefix, channels, subdirs=(), specs_to_add=(), specs_to_remove=()): | ||
self._internal = _Solver(prefix, channels, subdirs, specs_to_add, specs_to_remove) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will only work for interactive scripting but we could do at least self.solve_final_state.__doc__ = self._internal.solve_final_state.__doc__ |
||
|
||
def solve_final_state(self, deps_modifier=NULL, prune=NULL, ignore_pinned=NULL, | ||
force_remove=NULL): | ||
return self._internal.solve_final_state(deps_modifier, prune, ignore_pinned, | ||
force_remove) | ||
|
||
def solve_for_diff(self, deps_modifier=NULL, prune=NULL, ignore_pinned=NULL, | ||
force_remove=NULL, force_reinstall=False): | ||
return self._internal.solve_for_diff(deps_modifier, prune, ignore_pinned, | ||
force_remove, force_reinstall) | ||
|
||
def solve_for_transaction(self, deps_modifier=NULL, prune=NULL, ignore_pinned=NULL, | ||
force_remove=NULL, force_reinstall=False): | ||
return self._internal.solve_for_transaction(deps_modifier, prune, ignore_pinned, | ||
force_remove, force_reinstall) | ||
|
||
|
||
class SubdirData(object): | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need a docstring here, that also explains why this |
||
def __init__(self, channel): | ||
assert isinstance(channel, Channel) | ||
assert channel.subdir | ||
assert not channel.package_filename | ||
self._internal = _SubdirData(channel) | ||
|
||
def query(self, package_ref_or_match_spec): | ||
return tuple(self._internal.query(package_ref_or_match_spec)) | ||
|
||
@staticmethod | ||
def query_all(channels, subdirs, package_ref_or_match_spec): | ||
return tuple(_SubdirData.query_all(channels, subdirs, package_ref_or_match_spec)) | ||
|
||
def iter_records(self): | ||
return self._internal.iter_records() | ||
|
||
def reload(self): | ||
self._internal = self._internal.reload() | ||
return self | ||
|
||
|
||
class PackageCacheData(object): | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
def __init__(self, pkgs_dir): | ||
self._internal = _PackageCacheData(pkgs_dir) | ||
|
||
def get(self, package_ref, default=NULL): | ||
return self._internal.get(package_ref, default) | ||
|
||
def query(self, package_ref_or_match_spec): | ||
return tuple(self._internal.query(package_ref_or_match_spec)) | ||
|
||
@staticmethod | ||
def query_all(package_ref_or_match_spec, pkgs_dirs=None): | ||
return tuple(_PackageCacheData.query_all(package_ref_or_match_spec, pkgs_dirs)) | ||
|
||
def iter_records(self): | ||
return self._internal.iter_records() | ||
|
||
@property | ||
def is_writable(self): | ||
return self._internal.is_writable | ||
|
||
@staticmethod | ||
def first_writable(pkgs_dirs=None): | ||
return PackageCacheData(_PackageCacheData.first_writable(pkgs_dirs).pkgs_dir) | ||
|
||
def reload(self): | ||
self._internal = self._internal.reload() | ||
return self | ||
|
||
|
||
class PrefixData(object): | ||
|
||
def __init__(self, prefix_path): | ||
self._internal = _PrefixData(prefix_path) | ||
|
||
def get(self, package_ref, default=NULL): | ||
return self._internal.get(package_ref.name, default) | ||
|
||
def query(self, package_ref_or_match_spec): | ||
return tuple(self._internal.query(package_ref_or_match_spec)) | ||
|
||
def iter_records(self): | ||
return self._internal.iter_records() | ||
|
||
@property | ||
def is_writable(self): | ||
return self._internal.is_writable | ||
|
||
def reload(self): | ||
self._internal = self._internal.reload() | ||
return self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a docstring here, that also explains why this
Solver
wrapper is needed, or intended for?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any recommendation on how to do this without duplicating everything that's already in the underlying
Solver
class? Plenty of nice docstrings here: https://github.com/conda/conda/blob/master/conda/core/solve.py#L52