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!

Resolving patch:
diff --git a/dvc/command/experiments.py b/dvc/command/experiments.py
--- a/dvc/command/experiments.py
+++ b/dvc/command/experiments.py
@@ -408,7 +408,9 @@ def run(self):
                 # NOTE: rich does not have native support for unlimited width
                 # via pager. we override rich table compression by setting
                 # console width to the full width of the table
-                measurement = table.__rich_measure__(console, SHOW_MAX_WIDTH)
+                console_options = console.options
+                console_options.max_width = SHOW_MAX_WIDTH
+                measurement = table.__rich_measure__(console, console_options)
                 console._width = (  # pylint: disable=protected-access
                     measurement.maximum
                 )
diff --git a/dvc/utils/table.py b/dvc/utils/table.py
--- a/dvc/utils/table.py
+++ b/dvc/utils/table.py
@@ -8,6 +8,7 @@
 if TYPE_CHECKING:
     from rich.console import (
         Console,
+        ConsoleOptions,
         JustifyMethod,
         OverflowMethod,
         RenderableType,
@@ -56,7 +57,7 @@ def add_column(  # pylint: disable=arguments-differ
         self.columns.append(column)
 
     def _calculate_column_widths(
-        self, console: "Console", max_width: int
+        self, console: "Console", options: "ConsoleOptions"
     ) -> List[int]:
         """Calculate the widths of each column, including padding, not
         including borders.
@@ -64,7 +65,7 @@ def _calculate_column_widths(
         Adjacent collapsed columns will be removed until there is only a single
         truncated column remaining.
         """
-        widths = super()._calculate_column_widths(console, max_width)
+        widths = super()._calculate_column_widths(console, options)
         last_collapsed = -1
         columns = cast(List[Column], self.columns)
         for i in range(len(columns) - 1, -1, -1):
@@ -73,14 +74,14 @@ def _calculate_column_widths(
                     del widths[last_collapsed]
                     del columns[last_collapsed]
                     if self.box:
-                        max_width += 1
+                        options.max_width += 1
                     for column in columns[last_collapsed:]:
                         column._index -= 1
                 last_collapsed = i
                 padding = self._get_padding_width(i)
                 if (
                     columns[i].overflow == "ellipsis"
-                    and (sum(widths) + padding) <= max_width
+                    and (sum(widths) + padding) <= options.max_width
                 ):
                     # Set content width to 1 (plus padding) if we can fit a
                     # single unicode ellipsis in this column
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -83,7 +83,7 @@ def run(self):
     "pygtrie==2.3.2",
     "dpath>=2.0.1,<3",
     "shtab>=1.3.4,<2",
-    "rich>=9.0.0,<10",
+    "rich>=10.0.0",
     "dictdiffer>=0.8.1",
     "python-benedict>=0.21.1",
     "pyparsing==2.4.7",


Test patch: