Skip to content

Commit

Permalink
Use flattened/limited dict for all formats
Browse files Browse the repository at this point in the history
  • Loading branch information
asmacdo committed Jan 21, 2025
1 parent 69a13cd commit eab6762
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/con_duct/suite/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
import yaml
from con_duct.__main__ import DUCT_OUTPUT_PREFIX, SummaryFormatter

LS_SUMMARY_FORMAT = (
"Command: {command}\n"
"\tWall Clock Time: {execution_summary[wall_clock_time]:.3f} sec\n"
"\tMemory Peak Usage (RSS): {execution_summary[peak_rss]!S}\n"
"\tVirtual Memory Peak Usage (VSZ): {execution_summary[peak_vsz]!S}\n"
"\tMemory Peak Percentage: {execution_summary[peak_pmem]:.2f!N}%\n"
"\tCPU Peak Usage: {execution_summary[peak_pcpu]:.2f!N}%\n"
)
LS_SUMMARY_FORMAT = {
"prefix": "Prefix: {value}",
"command": "\tCommand: {value}",
"exit_code": "\tExit Code {value!E}",
"wall_clock_time": "\tWall Clock Time: {value:.3f} sec",
"peak_rss": "\tMemory Peak Usage (RSS): {value!S}",
}


def load_duct_runs(info_files: List[str]) -> List[dict]:
Expand Down Expand Up @@ -80,16 +79,17 @@ def ls(args: argparse.Namespace) -> int:

if args.format == "summaries":
formatter = SummaryFormatter() # TODO enable_colors=self.colors)

Check warning on line 81 in src/con_duct/suite/ls.py

View check run for this annotation

Codecov / codecov/patch

src/con_duct/suite/ls.py#L81

Added line #L81 was not covered by tests
for data in run_data_list:
print(formatter.format(LS_SUMMARY_FORMAT, **data))
for row in output_rows:
for col, value in row.items():
print(formatter.format(LS_SUMMARY_FORMAT[col], value=value))

Check warning on line 84 in src/con_duct/suite/ls.py

View check run for this annotation

Codecov / codecov/patch

src/con_duct/suite/ls.py#L84

Added line #L84 was not covered by tests
elif args.format == "pyout":
pyout_ls(output_rows)

Check warning on line 86 in src/con_duct/suite/ls.py

View check run for this annotation

Codecov / codecov/patch

src/con_duct/suite/ls.py#L86

Added line #L86 was not covered by tests
elif args.format == "json":
print(json.dumps(run_data_list))
print(json.dumps(output_rows))

Check warning on line 88 in src/con_duct/suite/ls.py

View check run for this annotation

Codecov / codecov/patch

src/con_duct/suite/ls.py#L88

Added line #L88 was not covered by tests
elif args.format == "json_pp":
print(json.dumps(run_data_list, indent=True))
print(json.dumps(output_rows, indent=True))

Check warning on line 90 in src/con_duct/suite/ls.py

View check run for this annotation

Codecov / codecov/patch

src/con_duct/suite/ls.py#L90

Added line #L90 was not covered by tests
elif args.format == "yaml":
print(yaml.dump(run_data_list, default_flow_style=False))
print(yaml.dump(output_rows, default_flow_style=False))

Check warning on line 92 in src/con_duct/suite/ls.py

View check run for this annotation

Codecov / codecov/patch

src/con_duct/suite/ls.py#L92

Added line #L92 was not covered by tests
else:
raise RuntimeError(

Check warning on line 94 in src/con_duct/suite/ls.py

View check run for this annotation

Codecov / codecov/patch

src/con_duct/suite/ls.py#L94

Added line #L94 was not covered by tests
f"Unexpected format encountered: {args.format}. This should have been caught by argparse.",
Expand Down

0 comments on commit eab6762

Please sign in to comment.