From 648760dced81068c9dae9a7a0103a10d8a1e6289 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 15 Dec 2020 21:26:11 -0600 Subject: [PATCH] Document complexity of min_len_unique_id. (#434) * Add a note about the runtime complexity of min_len_unique_id. * Don't use min_len_unique_id in signac find. * Use min_len_unique_id if needed. * Update signac/contrib/project.py --- signac/__main__.py | 7 +++++-- signac/contrib/project.py | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/signac/__main__.py b/signac/__main__.py index 117d212fe..c29f4205f 100644 --- a/signac/__main__.py +++ b/signac/__main__.py @@ -373,7 +373,10 @@ def main_find(args): """Handle find subcommand.""" project = get_project() - len_id = max(6, project.min_len_unique_id()) + len_id = 6 + if args.one_line: + # Only get the project's minimum length of unique id if it is needed. + len_id = max(len_id, project.min_len_unique_id()) # --show = --sp --doc --pretty 3 # if --sp or --doc are also specified, those subsets of keys will be used @@ -387,7 +390,7 @@ def format_lines(cat, _id, s): if args.one_line: if isinstance(s, dict): s = json.dumps(s, sort_keys=True) - return _id[:len_id] + " " + cat + "\t" + s + return f"{_id[:len_id]} {cat}\t{s}" else: return pformat(s, depth=args.pretty) diff --git a/signac/contrib/project.py b/signac/contrib/project.py index 864394ee3..0d9fce619 100644 --- a/signac/contrib/project.py +++ b/signac/contrib/project.py @@ -410,6 +410,9 @@ def _check_schema_compatibility(self): def min_len_unique_id(self): """Determine the minimum length required for a job id to be unique. + This method's runtime scales with the number of jobs in the + workspace. + Returns ------- int