Repository: iterative/dvc

Issue:
exp show: failing with rich==10.0.0
```console
$ dvc exp show
dvc exp show  -v
2021-03-29 11:30:45,071 DEBUG: Check for update is disabled.
2021-03-29 11:30:46,006 ERROR: unexpected error - 'int' object has no attribute 'max_width'
------------------------------------------------------------
Traceback (most recent call last):
  File "/home/saugat/repos/iterative/dvc/dvc/main.py", line 55, in main
    ret = cmd.run()
  File "/home/saugat/repos/iterative/dvc/dvc/command/experiments.py", line 411, in run
    measurement = table.__rich_measure__(console, SHOW_MAX_WIDTH)
  File "/home/saugat/venvs/dvc/env39/lib/python3.9/site-packages/rich/table.py", line 287, in __rich_measure__
    max_width = options.max_width
AttributeError: 'int' object has no attribute 'max_width'
------------------------------------------------------------
2021-03-29 11:30:47,022 DEBUG: Version info for developers:
DVC version: 2.0.11+f8c567 
---------------------------------
Platform: Python 3.9.2 on Linux-5.11.8-arch1-1-x86_64-with-glibc2.33
Supports: All remotes
Cache types: hardlink, symlink
Cache directory: ext4 on /dev/sda9
Caches: local
Remotes: https
Workspace directory: ext4 on /dev/sda9
Repo: dvc, git

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
```


This is also breaking our linter ([here](https://github.com/iterative/dvc/runs/2214172187?check_suite_focus=true#step:7:250
)) and tests as well due to the change in rich's internal API that we are using:
https://github.com/iterative/dvc/blob/1a25ebe3bd2eda4c3612e408fb503d64490fb56c/dvc/utils/table.py#L59




Discussion:
For now, I am keeping it to a range of `<10.0.0`.
You guys are so fast!
The exception in 10.0 is fixed in #5733, but there's still some other issue with latest rich that breaks our code for customizing rich's column collapse behavior (the issue actually starts in rich 9.13)

Using DVC 2.0.14 (the last version pinned to rich<10.0):

```
$ pip freeze|grep rich
rich==9.12.0
$ dvc exp show --no-pager
┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━┓
┃ Experiment    ┃ Created      ┃ avg_prec ┃ roc_auc ┃ prepare.split ┃ … ┃
┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━┩
│ workspace     │ -            │   0.6049 │ 0.95836 │ 0.2           │ … │
│ master        │ Mar 02, 2021 │  0.60405 │  0.9608 │ 0.2           │ … │
│ └── exp-2756f │ 04:02 PM     │  0.61049 │ 0.95689 │ 0.2           │ … │
└───────────────┴──────────────┴──────────┴─────────┴───────────────┴───┘
```


```
$ pip freeze|grep rich
rich==9.13.0
$ dvc exp show --no-pager
┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━┳┳┳┳┳┳┓
┃ Experiment    ┃ Created      ┃ avg_prec ┃ roc_auc ┃ prepare.split ┃┃┃┃┃┃┃
┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━╇╇╇╇╇╇┩
│ workspace     │ -            │   0.6049 │ 0.95836 │ 0.2           │││││││
│ master        │ Mar 02, 2021 │  0.60405 │  0.9608 │ 0.2           │││││││
│ └── exp-2756f │ 04:02 PM     │  0.61049 │ 0.95689 │ 0.2           │││││││
└───────────────┴──────────────┴──────────┴─────────┴───────────────┴┴┴┴┴┴┘
```


Resolving patch:
diff --git a/dvc/utils/table.py b/dvc/utils/table.py
--- a/dvc/utils/table.py
+++ b/dvc/utils/table.py
@@ -69,7 +69,7 @@ def _calculate_column_widths(
         last_collapsed = -1
         columns = cast(List[Column], self.columns)
         for i in range(len(columns) - 1, -1, -1):
-            if widths[i] == 1 and columns[i].collapse:
+            if widths[i] == 0 and columns[i].collapse:
                 if last_collapsed >= 0:
                     del widths[last_collapsed]
                     del columns[last_collapsed]


Test patch: