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 Jan 4, 2022
1 parent 327472d commit e6f50c8
Showing 1 changed file with 0 additions and 91 deletions.
91 changes: 0 additions & 91 deletions signac/contrib/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,97 +82,6 @@ def get_indexes(root):
)


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, DeprecationWarning)
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 e6f50c8

Please sign in to comment.