Skip to content

Commit

Permalink
Document complexity of min_len_unique_id. (#434)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bdice authored Dec 16, 2020
1 parent 93f4788 commit 648760d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions signac/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions signac/contrib/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 648760d

Please sign in to comment.