Skip to content

Conversation

jhamon
Copy link
Collaborator

@jhamon jhamon commented Aug 28, 2024

Problem

When running in notebooks, output from the list_indexes and list_collections commands created confusion because the __repr__ representation for these objects showed an object with a top-level key that implied the response should be interacted with like a dictionary. This expectation contradicts with the way the __iter__ implementations on these results objects are set up to enable iterating over results without drilling down.

The origin of the complexity here is that the backing APIs used to return simple arrays of names that could be easily iterated over, and earlier this year they become more fleshed out responses. Returning more data is useful in some situations, but in trying to smooth out the impact of the API change and maintain a similar way of interacting with the results, we accidentally opened up this inconsistency in the experience.

Solution

  • For these actions, migrate from output by pprint.pformat to json.dumps. For deeply nested objects, this produces a result that is easier to read.
  • Stop sorting keys alphabetically. The way they are returned from the API makes the most sense (name first).
  • Remove top-level keys from the printed output, which created wrong expectations about how to interact with the results object. Now list_indexes looks like an array, and you index into it like an array. Ditto for collections.

Before

Screenshot 2024-08-28 at 1 38 27 PM

Collections output

After

Screenshot 2024-08-28 at 1 29 00 PM

Screenshot 2024-08-28 at 1 42 05 PM

Screenshot 2024-08-28 at 3 28 44 PM

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: UX improvement, but should be no functional change

@jhamon jhamon marked this pull request as ready for review August 28, 2024 19:49
@jhamon jhamon requested a review from rohanshah18 August 28, 2024 19:50
Copy link
Contributor

@rohanshah18 rohanshah18 left a comment

Choose a reason for hiding this comment

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

Looks nice, LGTM!

@jhamon jhamon merged commit 2ea7e1d into main Aug 28, 2024
@jhamon jhamon deleted the jhamon/notebook-output-ux branch August 28, 2024 19:57
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.

2 participants