Skip to content

PrettyTables.jl v3#3510

Merged
bkamins merged 22 commits intoJuliaData:mainfrom
ronisbr:pretty_tables_v3
Sep 4, 2025
Merged

PrettyTables.jl v3#3510
bkamins merged 22 commits intoJuliaData:mainfrom
ronisbr:pretty_tables_v3

Conversation

@ronisbr
Copy link
Copy Markdown
Member

@ronisbr ronisbr commented Aug 27, 2025

The PR updates the support in DataFrames.jl to PrettyTables.jl v3. I’ve also updated the API call and the tests. As we can see from the tests, the output changes are minor. For the user, the printed version of DataFrames.jl should look exactly the same except in very edge cases.

@bkamins I reviewed the list of open display-related issues, and I can address some of them. However, this migration is currently blocking some internal workflows because we can’t use DataFrames with PrettyTables v3 simultaneously. Could we please merge this support, and then I’ll handle the remaining issues?

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Aug 27, 2025

With the latest commit, the tests are passing locally and the documentation is building just fine (locally also).

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Aug 27, 2025

Btw, after the suggestion of @nhz2 , I could compare the time to print the first DataFrames.jl in v2 and v3. We had an improvement here!

Version 2:

julia> @time using DataFrames
  0.338423 seconds (522.48 k allocations: 37.232 MiB, 10.71% gc time, 3.79% compilation time)

julia> df = DataFrame(A = 1:5, B = 1:5);

julia> @time show(df)
5×2 DataFrame
 Row │ A      B
     │ Int64  Int64
─────┼──────────────
   11      1
   22      2
   33      3
   44      4
   55      5  0.170112 seconds (651.53 k allocations: 35.599 MiB, 6.81% gc time, 99.55% compilation time: 40% of which was recompilation)

Version 3:

julia> @time using DataFrames
  0.354778 seconds (556.40 k allocations: 39.779 MiB, 8.14% gc time, 3.70% compilation time)

julia> df = DataFrame(A = 1:5, B = 1:5);

julia> @time show(df)
5×2 DataFrame
 Row │ A      B
     │ Int64  Int64
─────┼──────────────
   11      1
   22      2
   33      3
   44      4
   55      5  0.116783 seconds (288.77 k allocations: 17.764 MiB, 13.69% gc time, 99.56% compilation time)

@bkamins
Copy link
Copy Markdown
Member

bkamins commented Aug 27, 2025

Thank you.

  1. Regarding other issues - yes, let's do them later
  2. Can you please rebase the PR to current main (this should resolve failing tests on nightly)
  3. As for test failures on Julia 1.6 - can you please quickly have a look what could be the reason?

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Aug 27, 2025

Hi @bkamins !

  1. Regarding other issues - yes, let's do them later

OK!

  1. Can you please rebase the PR to current main (this should resolve failing tests on nightly)

Done!

  1. As for test failures on Julia 1.6 - can you please quickly have a look what could be the reason?

The issue arises because PrettyTables.jl no longer supports Julia 1.6. To minimize the maintenance burden, I’ve decided to always support the current version and the LTS version. Hence, for the 1.6 tests, the system is using PrettyTables v2, which results in test failures. Is this a problem?

@bkamins
Copy link
Copy Markdown
Member

bkamins commented Aug 28, 2025

Regarding failing tests on 1.6. Thank you for the insight.
We should do one of the two things:

  1. Have test to be conditional on PrettyTables.jl version (just like code). This is preferable. (and I hope easy, as we have old tests in place).
  2. Turn off display tests if PrettyTables.jl version is less than 3 (this is second best).

The reason is that otherwise we will have a constant problem that tests in 1.6 fail and it will be more difficult to detect the reason.

Would any of these solutions work with you? Thank you!

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Aug 28, 2025

Hi @bkamins !

Ok! Here’s what I did: I copied the entire file for PrettyTables.jl v2 and added a flag to select which version to include in the tests.

For show.jl and io.jl, this is clearly the best option because the entire file contains display tests. However, for the other two files, the display tests are scattered throughout the file. Therefore, I decided to take this easier approach to make things clear when we stop supporting PrettyTables.jl v2.

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Aug 28, 2025

Just for curiosity, why DataFrames.jl is still supporting Julia 1.6? It will not be updated anymore and we are not testing against 1.10, which is what people would use for LTS?

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Aug 28, 2025

@bkamins Done! Test are now passing in Julia 1.6.

@bkamins
Copy link
Copy Markdown
Member

bkamins commented Aug 29, 2025

@ronisbr - thank you for working on this. I will be back to work on Monday and review the PR.

Regarding 1.6 support - it was a decision made a year ago with @nalimilan as a precaution. @nalimilan - maybe indeed we can change to 1.10 now?

@nalimilan
Copy link
Copy Markdown
Member

nalimilan commented Aug 29, 2025

Ah, this is indeed a difficult decision. I tend to favor keeping support for old versions as usually the burden isn't that high. But in the current case the fact that PrettyTables doesn't support 1.6 indeed leads to a lot of code duplication in DataFrames (and we've never supported two versions of a dependency in the past). Maybe we can require 1.10 now as it's already relatively old.

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Aug 29, 2025

@ronisbr - thank you for working on this. I will be back to work on Monday and review the PR.

Awesome!

Ah, this is indeed a difficult decision. I tend to favor keeping support for old versions as usually the burden isn't that high. But in the current case the fact that PrettyTables doesn't support 1.6 indeed leads to a lot of code duplication in DataFrames (and we've never supported two versions of a dependency in the past). Maybe we can require 1.10 now as it's already relatively old.

So, if I understood correctly, I need to retain support for both versions 2 and 3 within the code during the transition of the Julia ecosystem to version 3. However, I should remove all the duplicated tests that were specifically designed for Julia 1.6, correct?

@bkamins
Copy link
Copy Markdown
Member

bkamins commented Sep 1, 2025

OK. So let us do the following:

  1. In this PR require Julia 1.10 for DataFrames.jl upcoming release
  2. Change CI to test against Julia 1.10.
  3. Remove unneeded changes for 1.6 (but keep what is needed for 1.10 to pass)

Later I will do a separate PR, that will clean up code base of technological debt we keep to have 1.6 support.

@ronisbr - would that work with you? Thank you!

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Sep 1, 2025

@ronisbr - would that work with you? Thank you!

Perfect! I will do that!

@nalimilan
Copy link
Copy Markdown
Member

Better not add a compat bound if it's not really necessary to use DataFrames, as some packages do not yet support CategoricalArrays 1.0, which means some users won't get the new DataFrames release. Anyway the compat bound shouldn't be needed to get the latest version for tests.

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Sep 1, 2025

@nalimilan CategoricalArrays v1.0 was launched on August 1st. Is there any problem using "0.10.0, 1" as compat bounds? Otherwise, it is obtaining v0.10.8 and the docs are failing.

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Sep 1, 2025

Btw, there is some really strange. DataFrames requires CategoricalArrays 0.10. However, the documentation build processing is using 1.0.1 (https://github.com/JuliaData/DataFrames.jl/actions/runs/17277010295/job/49036139753#step:5:58) I think it should not be possible.

In this PR, it is obtaining the expected version (v0.10.8). That's why the latest commit should fix the build process.

@nalimilan
Copy link
Copy Markdown
Member

Ah OK, I always forget that CategoricalArrays is only a test dependency for DataFrames. So requiring version 1 should be OK, it shouldn't affect users.


# printed height always matches desired height, above a reasonable minimum
for a in 1:50, b in 1:50, h in 15:40
for a in 1:50, b in 1:50, h in 17:40
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why do we start with 17 and not 15 here and below?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In PrettyTables.jl v2, I saw a bug where we would print a table without the line separating the header and the data. In v3, I decided to always print at least the column label (including the separation line). Hence, in this case, we have 2 more lines to display (two separation lines in two grouped data frames).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is it Ok or is it a problem? The difference is that we now have:

GroupedDataFrame with 2 groups based on key: x
First Group (10 rows): x = 1
 Row │ x
     │ Int64
─────┼───────
  ⋮  │   ⋮
10 rows omitted
⋮
Last Group (10 rows): x = 2
 Row │ x
     │ Int64
─────┼───────
  ⋮  │   ⋮
10 rows omitted

instead of:

GroupedDataFrame with 2 groups based on key: x
First Group (10 rows): x = 1
 Row │ x
     │ Int64
  ⋮  │   ⋮
10 rows omitted
⋮
Last Group (10 rows): x = 2
 Row │ x
     │ Int64
  ⋮  │   ⋮
10 rows omitted

The previous version was confusing because you do not know if you have more header lines or not.

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Sep 1, 2025

Hi @bkamins !

I fixed all your suggestions except for that about the number of lines.

@bkamins
Copy link
Copy Markdown
Member

bkamins commented Sep 1, 2025

@nalimilan - looks good to me. Can you also please have a look at this PR before merging? codecov problems are due to PrettyTables.jl v2 support that is not invoked. Thank you!

@nalimilan
Copy link
Copy Markdown
Member

Sorry for the misunderstanding, but if we keep supporting PrettyTables 2, couldn't we keep supporting Julia 1.6? One big advantage of this is that we would continue testing the compat code. Having so much code that isn't tested at all isn't great.

@juliohm
Copy link
Copy Markdown
Contributor

juliohm commented Sep 2, 2025

Jumping in because this PR is blocking various updates downstream...

couldn't we keep supporting Julia 1.6? One big advantage of this is that we would continue testing the compat code. Having so much code that isn't tested at all isn't great.

My understanding is that everyone already moved to LTS, and that after this PR is merged @bkamins will clean up the source code further to remove uncovered lines.

@nhz2
Copy link
Copy Markdown

nhz2 commented Sep 2, 2025

You could try using https://github.com/julia-actions/julia-downgrade-compat to test that.

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Sep 2, 2025

Sorry for the misunderstanding, but if we keep supporting PrettyTables 2, couldn't we keep supporting Julia 1.6?

IMHO supporting Julia 1.6 is not good. In this case, we are testing against a version probably very few people are using and not testing against what a lot of people are using (LTS). Adding code to support both PrettyTables.jl v2 and v3 for now is important because, as @nhz2 mentioned, it will take sometime for people to upgrade their packages. In this case, we can avoid some problems for the community.

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Sep 2, 2025

Ah! Btw, the only code that will not be tested in this version are two functions to display DataFrames (in text and html). Notice that those functions have remaining almost unchanged since the initial PR to add support for PrettyTables.jl.

EDIT: By the way, I am not against only supporting PrettyTables.jl v3! At least, it will make people upgrade faster :D

@nhz2
Copy link
Copy Markdown

nhz2 commented Sep 2, 2025

Only supporting v3 is fine in theory, but in practice, it will likely create weird issues where people end up using super old versions of packages due to how Pkg.jl decides to resolve compat conflicts. For example, if someone wants to install the latest CUDA.jl and DataFrames.jl, Pkg.jl might decide to resolve the conflict by installing the latest DataFrames.jl, and then CUDA.jl from 2023 before it added PrettyTables.jl as a dep.

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Sep 2, 2025

Only supporting v3 is fine in theory, but in practice, it will likely create JuliaIO/ZipArchives.jl#60 where people end up using super old versions of packages due to how Pkg.jl decides to resolve compat conflicts. For example, if someone wants to install the latest CUDA.jl and DataFrames.jl, Pkg.jl might decide to resolve the conflict by installing the latest DataFrames.jl, and then CUDA.jl from 2023 before it added PrettyTables.jl as a dep.

Makes sense! In this case, IMHO, the way to go is what we have currently in this PR: supporting PrettyTables.jl v2 for those cases and drop support for Julia 1.6.

@juliohm
Copy link
Copy Markdown
Contributor

juliohm commented Sep 2, 2025

@nalimilan BTW CategoricalArrays.jl specifies Julia v1.6, but relies on package extensions (weakdeps) in its Project.toml, which are only available in Julia v1.9 and later versions. You might think it supports Julia v1.6, but it shouldn't.

@bkamins
Copy link
Copy Markdown
Member

bkamins commented Sep 2, 2025

supporting PrettyTables.jl v2 for those cases and drop support for Julia 1.6.

Yes - this is what I had in mind. The coverage failure - as @ronisbr mentions - is in the "old" code that was essentially untouched. At some point we will remove it (and this is the reason why I asked @ronisbr to add a comment about removal of v2 support in the future).

@nalimilan
Copy link
Copy Markdown
Member

Fine with me. I'm not super happy to have untested code, but I guess that's OK since it's old code and we'll remove it at some point.

@nalimilan BTW CategoricalArrays.jl specifies Julia v1.6, but relies on package extensions (weakdeps) in its Project.toml, which are only available in Julia v1.9 and later versions. You might think it supports Julia v1.6, but it shouldn't.

@juliohm CategoricalArrays uses Requires.jl on Julia 1.6. It's tested by CI so I guess it works. I think it was important to release 1.0 on Julia 1.6 as otherwise a package that would want to support 1.6 for some reason couldn't move to that major version easily.

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Sep 3, 2025

Hi @nalimilan !

Fine with me. I'm not super happy to have untested code, but I guess that's OK since it's old code and we'll remove it at some point.

Awesome! Yes, we will probably remove it very quickly!

@bkamins maybe we are ready to merge? My next step will be to close the issues and add the LaTeX backend.

@bkamins
Copy link
Copy Markdown
Member

bkamins commented Sep 3, 2025

We are ready to merge from my perspective. But let me wait for @nalimilan to approve the PR, as this is a major change, so I prefer to wait for it rather to rush with merging.

Thank you for working on it!

@bkamins bkamins merged commit fe224cb into JuliaData:main Sep 4, 2025
6 of 8 checks passed
@bkamins
Copy link
Copy Markdown
Member

bkamins commented Sep 4, 2025

@ronisbr - thank you for a massive and excellent work. Now - as discussed let us work on open things related to display. If you feel that something is not doable or too hard to do please comment in the open issues and I will close them (or re-scope). Thank you!

@ronisbr
Copy link
Copy Markdown
Member Author

ronisbr commented Sep 4, 2025

@ronisbr - thank you for a massive and excellent work. Now - as discussed let us work on open things related to display. If you feel that something is not doable or too hard to do please comment in the open issues and I will close them (or re-scope). Thank you!

Awesome! Yes, I will do that! Thanks @bkamins

@juliohm
Copy link
Copy Markdown
Contributor

juliohm commented Sep 5, 2025 via email

@bkamins
Copy link
Copy Markdown
Member

bkamins commented Sep 5, 2025

We will make this release soon.

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.

5 participants