Commit 2ea7e1d
authored
Improve output from list/describe actions on indexes and collections (#387)
## 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
<img alt="Screenshot 2024-08-28 at 1 38 27 PM"
src="https://github.com/user-attachments/assets/a7931ebe-ffd9-4197-be26-aa030592e62d">

### After
<img width="706" alt="Screenshot 2024-08-28 at 1 29 00 PM"
src="https://github.com/user-attachments/assets/5c47e1db-19d3-44e7-bed9-bed27f823d02">


## 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)
- [X] None of the above: UX improvement, but should be no functional
change1 parent 1d0b686 commit 2ea7e1d
File tree
5 files changed
+29
-6
lines changed- pinecone
- control
- models
5 files changed
+29
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | 12 | | |
16 | 13 | | |
17 | 14 | | |
18 | 15 | | |
19 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments