Skip to content

Commit

Permalink
Remove --doc-filter option from CLI. (#795)
Browse files Browse the repository at this point in the history
* Remove --doc-filter from CLI.

* Minor docstring improvements.

* Remove --doc-filter tests.

* Update changelog.
  • Loading branch information
bdice committed Aug 30, 2022
1 parent c7a233a commit e4c75d3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 79 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Removed
- The ``--workspace`` option for the command line ``job`` subcommand (#752).
- The ability to call ``Project.workspace``, it is strictly a property now (#752).
- ``ProjectSchema.__call__``, ``ProjectSchema.detect`` (#752).
- The ``--doc-filter`` option for several command line subcommands (#613, #795).

Version 1
=========
Expand Down
84 changes: 15 additions & 69 deletions signac/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from . import get_project, init_project
from .common import config
from .common.configobj import Section, flatten_errors
from .contrib.filterparse import _add_prefix, parse_filter_arg
from .contrib.filterparse import parse_filter_arg
from .contrib.import_export import _SchemaPathEvaluationError, export_jobs
from .contrib.utility import _add_verbosity_argument, _print_err, _query_yes_no
from .core.utility import _safe_relpath
Expand Down Expand Up @@ -135,7 +135,7 @@ def _open_job_by_id(project, job_id):

def find_with_filter_or_none(args):
"""Return a filtered subset of jobs or None."""
if args.job_id or args.filter or args.doc_filter:
if args.job_id or args.filter:
return find_with_filter(args)
else:
return None
Expand All @@ -144,15 +144,13 @@ def find_with_filter_or_none(args):
def find_with_filter(args):
"""Return a filtered subset of jobs."""
if getattr(args, "job_id", None):
if args.filter or args.doc_filter:
if args.filter:
raise ValueError("Can't provide both 'job-id' and filter arguments!")
else:
return args.job_id

project = get_project()
filter_ = parse_filter_arg(args.filter) or {}
if args.doc_filter:
filter_.update(_add_prefix("doc.", parse_filter_arg(args.doc_filter)))
if not filter_:
filter_ = None
return project._find_job_ids(filter=filter_)
Expand All @@ -168,7 +166,7 @@ def main_job(args):
try:
statepoint = json.loads(sp)
except ValueError:
_print_err(f"Error while reading statepoint: '{sp}'")
_print_err(f"Error while reading state point: '{sp}'")
raise
job = project.open_job(statepoint)
if args.create:
Expand Down Expand Up @@ -903,7 +901,7 @@ def main():
nargs="?",
default="-",
type=str,
help="The job's statepoint in JSON format. Omit this argument to read from STDIN.",
help="The job's state point in JSON format. Omit this argument to read from STDIN.",
)
parser_job.add_argument(
"-w",
Expand All @@ -927,7 +925,7 @@ def main():

parser_statepoint = subparsers.add_parser(
"statepoint",
description="Print the statepoint(s) corresponding to one or more job ids.",
description="Print the state point(s) corresponding to one or more job ids.",
)
parser_statepoint.add_argument(
"job_id",
Expand Down Expand Up @@ -993,14 +991,7 @@ def main():
"--filter",
type=str,
nargs="+",
help="Limit the diff to jobs matching this state point filter.",
)
parser_diff.add_argument(
"-d",
"--doc-filter",
type=str,
nargs="+",
help="Show documents of jobs matching this document filter.",
help="Limit the diff to jobs matching the filter.",
)
parser_diff.set_defaults(func=main_diff)

Expand Down Expand Up @@ -1043,14 +1034,7 @@ def main():
"--filter",
type=str,
nargs="+",
help="Show documents of jobs matching this state point filter.",
)
parser_document.add_argument(
"-d",
"--doc-filter",
type=str,
nargs="+",
help="Show documents of job matching this document filter.",
help="Show documents of jobs matching the filter.",
)
parser_document.set_defaults(func=main_document)

Expand Down Expand Up @@ -1121,10 +1105,7 @@ def main():
"filter",
type=str,
nargs="*",
help="A JSON encoded state point filter (key-value pairs).",
)
parser_find.add_argument(
"-d", "--doc-filter", type=str, nargs="+", help="A document filter."
help="Find jobs matching the filter.",
)
parser_find.add_argument(
"-s",
Expand Down Expand Up @@ -1207,14 +1188,7 @@ def main():
"--filter",
type=str,
nargs="+",
help="Limit the view to jobs matching this state point filter.",
)
selection_group.add_argument(
"-d",
"--doc-filter",
type=str,
nargs="+",
help="Limit the view to jobs matching this document filter.",
help="Limit the view to jobs matching the filter.",
)
selection_group.add_argument(
"-j",
Expand Down Expand Up @@ -1260,14 +1234,7 @@ def main():
"--filter",
type=str,
nargs="+",
help="Detect schema only for jobs that match the state point filter.",
)
selection_group.add_argument(
"-d",
"--doc-filter",
type=str,
nargs="+",
help="Detect schema only for jobs that match the document filter.",
help="Detect schema only for jobs matching the filter.",
)
selection_group.add_argument(
"-j",
Expand Down Expand Up @@ -1297,21 +1264,14 @@ def main():
"--filter",
type=str,
nargs="+",
help="Reduce selection to jobs that match the given filter.",
)
selection_group.add_argument(
"-d",
"--doc-filter",
type=str,
nargs="+",
help="Reduce selection to jobs that match the given document filter.",
help="Reduce selection to jobs matching the filter.",
)
selection_group.add_argument(
"-j",
"--job-id",
type=str,
nargs="+",
help="Reduce selection to jobs that match the given job ids.",
help="Reduce selection to jobs matching the given job ids.",
)
parser_shell.set_defaults(func=main_shell)

Expand Down Expand Up @@ -1479,14 +1439,7 @@ def main():
"--filter",
type=str,
nargs="+",
help="Only synchronize jobs that match the state point filter.",
)
selection_group.add_argument(
"-d",
"--doc-filter",
type=str,
nargs="+",
help="Only synchronize jobs that match the document filter.",
help="Only synchronize jobs matching the filter.",
)
selection_group.add_argument(
"-j",
Expand Down Expand Up @@ -1562,14 +1515,7 @@ def main():
"--filter",
type=str,
nargs="+",
help="Limit the jobs to export to those matching the state point filter.",
)
selection_group.add_argument(
"-d",
"--doc-filter",
type=str,
nargs="+",
help="Limit the jobs to export to those matching this document filter.",
help="Limit the jobs to export to those matching the filter.",
)
selection_group.add_argument(
"-j",
Expand Down
10 changes: 0 additions & 10 deletions tests/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ def test_view_incomplete_path_spec(self):
)
assert "duplicate paths" in err

@pytest.mark.filterwarnings("ignore:The doc_filter argument is deprecated")
def test_find(self):
self.call("python -m signac init".split())
project = signac.Project()
Expand Down Expand Up @@ -267,15 +266,6 @@ def test_find(self):
job.document["a"] = job.statepoint()["a"]
job.document["b"] = job.statepoint()["a"] + 1

for i in range(3):
assert (
self.call(
"python -m signac find --doc-filter".split()
+ ['{"a": ' + str(i) + "}"]
).strip()
== next(iter(project.find_jobs({"a": i}))).id
)

for i in range(3):
assert (
self.call(
Expand Down

0 comments on commit e4c75d3

Please sign in to comment.