How to use the signac.contrib.filterparse.parse_filter_arg function in signac

To help you get started, we’ve selected a few signac examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glotzerlab / signac / tests / test_find_command_line_interface.py View on Github external
def _parse(args):
        with open(os.devnull, 'w') as null:
            return parse_filter_arg(args, file=null)
github glotzerlab / signac / signac / __main__.py View on Github external
def find_with_filter(args):
    if getattr(args, 'job_id', None):
        if args.filter or args.doc_filter:
            raise ValueError("Can't provide both 'job-id' and filter arguments!")
        else:
            return args.job_id

    project = get_project()
    if hasattr(args, 'index'):
        index = _read_index(project, args.index)
    else:
        index = None

    f = parse_filter_arg(args.filter)
    df = parse_filter_arg(args.doc_filter)
    return get_project()._find_job_ids(index=index, filter=f, doc_filter=df)
github glotzerlab / signac / signac / __main__.py View on Github external
def find_with_filter(args):
    if getattr(args, 'job_id', None):
        if args.filter or args.doc_filter:
            raise ValueError("Can't provide both 'job-id' and filter arguments!")
        else:
            return args.job_id

    project = get_project()
    if hasattr(args, 'index'):
        index = _read_index(project, args.index)
    else:
        index = None

    f = parse_filter_arg(args.filter)
    df = parse_filter_arg(args.doc_filter)
    return get_project()._find_job_ids(index=index, filter=f, doc_filter=df)
github glotzerlab / signac-flow / flow / project.py View on Github external
def _select_jobs_from_args(self, args):
        "Select jobs with the given command line arguments ('-j/-f/--doc-filter')."
        if args.job_id and (args.filter or args.doc_filter):
            raise ValueError(
                "Cannot provide both -j/--job-id and -f/--filter or --doc-filter in combination.")

        if args.job_id:
            try:
                return [self.open_job(id=job_id) for job_id in args.job_id]
            except KeyError as error:
                raise LookupError("Did not find job with id {}.".format(error))
        else:
            filter_ = parse_filter_arg(args.filter)
            doc_filter = parse_filter_arg(args.doc_filter)
            return JobsCursor(self, filter_, doc_filter)
github glotzerlab / signac-flow / flow / project.py View on Github external
def _select_jobs_from_args(self, args):
        "Select jobs with the given command line arguments ('-j/-f/--doc-filter')."
        if args.job_id and (args.filter or args.doc_filter):
            raise ValueError(
                "Cannot provide both -j/--job-id and -f/--filter or --doc-filter in combination.")

        if args.job_id:
            try:
                return [self.open_job(id=job_id) for job_id in args.job_id]
            except KeyError as error:
                raise LookupError("Did not find job with id {}.".format(error))
        else:
            filter_ = parse_filter_arg(args.filter)
            doc_filter = parse_filter_arg(args.doc_filter)
            return JobsCursor(self, filter_, doc_filter)