diff --git a/src/con_duct/suite/ls.py b/src/con_duct/suite/ls.py index f24a246..f3a12fc 100644 --- a/src/con_duct/suite/ls.py +++ b/src/con_duct/suite/ls.py @@ -6,13 +6,18 @@ import re from typing import Any, Dict, List, Optional from packaging.version import Version +from con_duct.__main__ import DUCT_OUTPUT_PREFIX, SummaryFormatter try: import pyout # type: ignore except ImportError: pyout = None -import yaml -from con_duct.__main__ import DUCT_OUTPUT_PREFIX, SummaryFormatter + +try: + import yaml # type: ignore +except ImportError: + yaml = None + lgr = logging.getLogger(__name__) @@ -72,10 +77,14 @@ def load_duct_runs( f"is below minimum schema version {MINIMUM_SCHEMA_VERSION}." ) continue - if eval_filter is not None and not (eval_results := eval( - eval_filter, _flatten_dict(this), dict(re=re) - )): - lgr.debug("Filtering out %s due to filter results matching: %s", this, eval_results) + if eval_filter is not None and not ( + eval_results := eval(eval_filter, _flatten_dict(this), dict(re=re)) + ): + lgr.debug( + "Filtering out %s due to filter results matching: %s", + this, + eval_results, + ) continue loaded.append(this) @@ -179,6 +188,8 @@ def ls(args: argparse.Namespace) -> int: elif args.format == "json_pp": print(json.dumps(output_rows, indent=2)) elif args.format == "yaml": + if yaml is None: + raise RuntimeError("Install PyYaml yaml output") plain_rows = [dict(row) for row in output_rows] print(yaml.dump(plain_rows, default_flow_style=False)) else: