Skip to content

Commit

Permalink
Remove unused JobSearchIndex class. (#587)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdice authored and vyasr committed Oct 30, 2022
1 parent 3d4d1f4 commit 4b6e1f2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 91 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Removed
- The cite.py module (#594).
- The following types of exceptions: ``AuthenticationError``, ``ExportError`, ``FetchError``, ``PermissionsError`` (#595, #596).
- All MongoDB database functionality, including the ``db`` subpackage, the ``connection``, ``crypt``, and ``host`` submodules in the ``common`` subpackage, and all associated configuration information (#576, #596).
- The ``JobSearchIndex`` class (#587).

Version 1
=========
Expand Down
91 changes: 0 additions & 91 deletions signac/contrib/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,97 +98,6 @@ def __call__(self):
return self


class JobSearchIndex:
"""Search for specific jobs with filters.
The JobSearchIndex allows to search for job_ids,
that are part of an index, which match specific
state point filters or job document filters.
Parameters
----------
index :
A document index.
_trust : bool
Whether to skip document validation on insertion into the internal
Collection (Default value = False).
"""

@deprecated(
deprecated_in="1.8",
removed_in="2.0",
current_version=__version__,
details="The JobSearchIndex class is deprecated.",
)
def __init__(self, index, _trust=False):
self._collection = Collection(index, _trust=_trust)

def __len__(self):
return len(self._collection)

def _resolve_statepoint_filter(self, q):
"""Resolve state point based on filter.
Parameters
----------
q : dict
Filter used for state point selection.
Yields
------
str
Filtered state point.
"""
for key, value in q.items():
if key in ("$and", "$or"):
if not isinstance(value, list) or isinstance(value, tuple):
raise ValueError(
"The argument to a logical operator must be a sequence (e.g. a list)!"
)
yield key, [dict(self._resolve_statepoint_filter(i)) for i in value]
else:
yield f"statepoint.{key}", value

def find_job_ids(self, filter=None, doc_filter=None):
"""Find job ids from a state point or document filter.
Parameters
----------
filter : dict
A mapping of key-value pairs that all indexed job state points are
compared against (Default value = None).
doc_filter : dict
A mapping of key-value pairs that all indexed job documents are
compared against (Default value = None).
Returns
-------
list
List of job ids matching the provided filter(s).
Raises
------
TypeError
If the filters are not JSON serializable.
ValueError
If the filters are invalid.
RuntimeError
If the filters are not supported
by the index.
"""
if filter:
filter = dict(self._resolve_statepoint_filter(filter))
if doc_filter:
filter.update(doc_filter)
elif doc_filter:
warnings.warn(DOC_FILTER_WARNING, FutureWarning)
filter = doc_filter
return self._collection._find(filter)


class _ProjectConfig(Config):
r"""Extends the project config to make it immutable.
Expand Down

0 comments on commit 4b6e1f2

Please sign in to comment.