Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve formatting of job results in CLI command #34

Merged
merged 5 commits into from Jun 16, 2022

Conversation

Mandrenkov
Copy link
Collaborator

Context:

NumPy arrays are currently displayed as strings in the output of xcc job get "<Job ID>" --result commands. Consequently,

  • Syntax highlighting for job results is misleading.
  • Newline characters are not honoured during rendering.
  • Large arrays are prone to exceeding the width of the terminal window.

For example,

xcc job get "919e84c9-01fd-4ba7-b2b3-7c1bdec49dd4" --result

yields

{
    "output": [
        "[[0 0 0 0 0 0 0 0]\n [0 1 0 1 0 0 0 1]\n [0 0 1 2 0 0 0 1]\n [1 1 0 2 2 0 0 1]\n [0 0 1 0 1 0 0 0]\n [1 0 1 2 0 1 0 0]\n [0 0 0 1 0 0 0 0]\n [0 0 0 0 0 0 0 0]\n [0 1 0 2 0 0 0 1]\n [0 1 1 1 3 1 1 0]\n [0 0 0 1 0 0 1 1]\n [0 0 0 0 0 1 1 0]\n [0 0 0 1 0 1 0 1]\n [0 0 1 0 0 0 0 0]\n [0 1 0 0 2 0 1 1]\n [0 0 0 1 1 0 0 1]\n [0 0 0 0 1 0 1 0]\n [2 0 0 0 0 0 0 0]\n [1 1 1 0 2 0 0 2]\n [0 0 0 1 0 0 0 1]]"
    ]
}

Description of the Change:

  • Used pformat() to format NumPy arrays within the output of the xcc job get "<Job ID>" --result command.
  • The example in the Context section now shows:
{
    "output": [[[0, 0, 0, 0, 0, 0, 0, 0],
                [0, 1, 0, 1, 0, 0, 0, 1],
                [0, 0, 1, 2, 0, 0, 0, 1],
                [1, 1, 0, 2, 2, 0, 0, 1],
                [0, 0, 1, 0, 1, 0, 0, 0],
                [1, 0, 1, 2, 0, 1, 0, 0],
                [0, 0, 0, 1, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0, 0],
                [0, 1, 0, 2, 0, 0, 0, 1],
                [0, 1, 1, 1, 3, 1, 1, 0],
                [0, 0, 0, 1, 0, 0, 1, 1],
                [0, 0, 0, 0, 0, 1, 1, 0],
                [0, 0, 0, 1, 0, 1, 0, 1],
                [0, 0, 1, 0, 0, 0, 0, 0],
                [0, 1, 0, 0, 2, 0, 1, 1],
                [0, 0, 0, 1, 1, 0, 0, 1],
                [0, 0, 0, 0, 1, 0, 1, 0],
                [2, 0, 0, 0, 0, 0, 0, 0],
                [1, 1, 1, 0, 2, 0, 0, 2],
                [0, 0, 0, 1, 0, 0, 0, 1]]]
}

Benefits:

  • Job results are displayed in a richer and more compact format which lends itself better to visual parsing.

Possible Drawbacks:

None.

Related GitHub Issues:

Resolves #33.

@Mandrenkov Mandrenkov marked this pull request as ready for review June 15, 2022 19:03
Copy link

@thisac thisac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Much nicer to have this output. 🚀

xcc/commands.py Show resolved Hide resolved
.github/CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Paul Finlay <50180049+doctorperceptron@users.noreply.github.com>
@Mandrenkov Mandrenkov merged commit 34594f2 into main Jun 16, 2022
@Mandrenkov Mandrenkov deleted the sc-212160-job-result-formatting branch June 16, 2022 13:21
Copy link
Contributor

@jwoehr jwoehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @Mandrenkov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xcc job --result output is not user friendly
4 participants