Skip to content

Commit

Permalink
Merge pull request #148 from fgcz/release_bfabric_scripts
Browse files Browse the repository at this point in the history
Hot Fix: printing of YAML for parsing with shyaml #147
  • Loading branch information
leoschwarz authored Feb 17, 2025
2 parents a8c277a + e509b80 commit 82683ea
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 6 additions & 0 deletions bfabric_scripts/doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ Versioning currently follows `X.Y.Z` where

## \[Unreleased\]

## \[1.13.22\] - 2025-02-17

### Fixed

- Fix printing of YAML for parsing with shyaml, previously line breaks could have been introduced.

## \[1.13.21\] - 2025-02-11

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion bfabric_scripts/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "hatchling.build"
[project]
name = "bfabric_scripts"
description = "Python command line scripts for the B-Fabric API"
version = "1.13.21"
version = "1.13.22"

dependencies = [
"bfabric==1.13.20"
Expand Down
15 changes: 7 additions & 8 deletions bfabric_scripts/src/bfabric_scripts/cli/api/cli_api_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,18 @@ def render_output(results: list[dict[str, Any]], params: Params, client: Bfabric
results = [{k: x.get(k) for k in params.columns} for x in results]

if params.format == OutputFormat.JSON:
return json.dumps(results, indent=2)
result = json.dumps(results, indent=2)
elif params.format == OutputFormat.YAML:
return yaml.dump(results)
result = yaml.dump(results)
elif params.format == OutputFormat.TSV:
return flatten_relations(pl.DataFrame(results)).write_csv(separator="\t")
result = flatten_relations(pl.DataFrame(results)).write_csv(separator="\t")
else:
raise ValueError(f"output format {params.format} not supported")

# TODO check if we can add back colors (but it broke some stuff, because of forced line breaks, so be careful)
print(result)
return result


@app.default
@use_client
Expand All @@ -114,11 +118,6 @@ def read(params: Annotated[Params, cyclopts.Parameter(name="*")], *, client: Bfa
results = sorted(results, key=lambda x: x["id"])
console_out = Console()
output = render_output(results, params=params, client=client, console=console_out)
if output is not None:
if params.format == OutputFormat.TSV:
print(output)
else:
console_out.print(output)
if params.file:
if output is None:
logger.error("File output is not supported for the specified output format.")
Expand Down

0 comments on commit 82683ea

Please sign in to comment.