[ANN] PrettyTables v3.0.0

You might also try using JULIA_CUDA_SOFT_MEMORY_LIMIT
and similar options.

Unfortunately the tests crash with --jobs=2 too.

Yes, this is quickly becoming off-topic. All I want is to update PrettyTables.jl in CUDA.jl. It is so annoying that CUDA.jl is blocking updates downstream…

CUDA.jl released a patch that bumped the version of PrettyTables.jl to v3, but apparently there is another issue with GPUCompiler.jl in the way:

] activate --temp
] add CUDA@v5.8.4
] add PrettyTables@v3.0
Resolving package versions...
ERROR: Unsatisfiable requirements detected for package GPUCompiler [61eb1bfa]:
 GPUCompiler [61eb1bfa] log:
 ├─possible versions are: 0.1.0 - 1.6.1 or uninstalled
 ├─restricted by compatibility requirements with CUDA [052768ef] to versions: [0.3.0 - 0.7.3, 0.8.1 - 0.10.0, 0.11.1 - 0.12.9, 0.13.3 - 0.21.4, 0.24.0 - 1.6.1]
 │ └─CUDA [052768ef] log:
 │   ├─possible versions are: 0.1.0 - 5.8.4 or uninstalled
 │   ├─restricted to versions * by project [8f28697a], leaving only versions: 0.1.0 - 5.8.4
 │   │ └─project [8f28697a] log:
 │   │   ├─possible versions are: 0.0.0 or uninstalled
 │   │   └─project [8f28697a] is fixed to version 0.0.0
 │   ├─restricted by julia compatibility requirements to versions: [2.3.0, 2.5.0 - 5.8.4] or uninstalled, leaving only versions: [2.3.0, 2.5.0 - 5.8.4]
 │   └─restricted by compatibility requirements with PrettyTables [08abe8d2] to versions: 0.1.0 - 4.4.2 or uninstalled, leaving only versions: [2.3.0, 2.5.0 - 4.4.2]
 │     └─PrettyTables [08abe8d2] log:
 │       ├─possible versions are: 0.1.0 - 3.0.10 or uninstalled
 │       └─restricted to versions 3.0 by an explicit requirement, leaving only versions: 3.0.0 - 3.0.10
 ├─restricted by julia compatibility requirements to versions: 0.23.0 - 1.6.1 or uninstalled, leaving only versions: 0.24.0 - 1.6.1
 └─restricted by compatibility requirements with CUDA [052768ef] to versions: [0.8.1 - 0.10.0, 0.11.1 - 0.12.9, 0.13.3 - 0.21.4] — no versions left
   └─CUDA [052768ef] log: see above

It did not: Switch to texthighlighter to unbreak profile (#2891) · JuliaGPU/CUDA.jl@29fa0ba · GitHub isn’t in CUDA.jl v5.8.4

Misread the commits, sorry.

Updated all GeoStats.jl modules successfully to PrettyTables.jl v3 :white_check_mark:

@Ronis_BR the title of the table in HTML output is disproportionally large:

This is what happens when the geospatial domain is more complicated:

Any way to reduce the size of the font for the title?

@Ronis_BR another issue after the update. PrettyTables.jl is throwing an error explicitly in Quarto builds as you can see here:

ERROR: EvaluationError: Encountered 3 errors during evaluation

Error 1 of 3
@ /home/juliohm/Desktop/geospatial-data-science-with-julia/01-geodata.qmd:205
MethodError: no method matching _html__print(::PrettyTables.PrintingSpec; is_stdout::Bool, column_label_titles::Vector{Union{Nothing, Vector{String}}}, highlighters::Vector{PrettyTables.HtmlHighlighter}, maximum_column_width::String, minify::Bool, stand_alone::Bool, style::PrettyTables.HtmlTableStyle{Vector{Pair{String, String}}, Vector{Pair{String, String}}}, table_class::String, table_div_class::String, top_left_string::String, wrap_table_in_div::Bool, header_alignment::Symbol)
This error has been manually thrown, explicitly, so the method may exist but be intentionally marked as unimplemented.

You can reproduce by updating the env in GitHub - JuliaEarth/geospatial-data-science-with-julia: Geospatial Data Science with Julia and typing quarto render.

You can change the default style of the title using HtmlTableStyle in the style keyword.

1 Like

For some reason (maybe macOS Tahoe), I am not able to install quarto. Can you provide a MWE to reproduce this bug?

Will try to produce a MWE tomorrow. It could be related to the previous workaround we had to do for printing DataFrames.jl:

There is no header_alignment keyword in PrettyTables.jl v3. It should be column_label_alignment.

2 Likes

When releasing a breaking version of a package, it’d be really helpful to the users to know what broke and how to adapt the code, a sort of upgrade guide. This is even more so important for somewhat popular packages. Release v3.0.0 · ronisbr/PrettyTables.jl · GitHub merely says

This new version contains many breaking changes. The API was almost entirely redesigned to improve the package maintainability and to add new features. Please, check the documentation for more details.

but as far as I could see the documentation doesn’t have anything about “if you used X in v2, you probably want to use Y in v3”. It’s really hard to get this sort of differential information just by reading the docs.

1 Like

Yeah, I completely agree. The issue is that PrettyTables.jl has always been a one-man show, so I didn’t have the time to write a migration guide for v2 to v3 because about 90% of the keywords and options changed at some point. Instead, I focused on creating comprehensive documentation so users can search and adapt their existing code.

For this particular release, a migration guide would probably be bigger than the documentation itself.

5 Likes

Ah, by the way! For anyone migrating from PrettyTables.jl v2 to v3, feel free to post any errors on this thread. I really do not mind answering them, and it would probably be much faster :slight_smile:

When I get some time in the future, I can use this feedback to make a simple migration guide as @giordano proposed with the most common errors.

1 Like

The following has been generated by a free LLM agent. I have no idea if it has any value.

Migration Guide: PrettyTables.jl v2 to v3

This guide is intended to help users migrate their code from PrettyTables.jl v2 to the new v3 release. Version 3 introduces several significant improvements and API changes that, while breaking, provide a more flexible and powerful way to create and customize tables.

The key areas of change are:

  1. The PrettyTable object is now mutable.
  2. The behavior of the pretty_table function has changed.
  3. Several keyword arguments have been renamed.
  4. The APIs for highlighters and table formats have been redesigned.

1. PrettyTable Object Mutability

In v2, the PrettyTable object was immutable, meaning all configuration had to be provided at the time of its creation. In v3, the PrettyTable object is now mutable, allowing you to modify its properties after creation.

v2 Example:

# In v2, all options were passed in the constructor.
pt = PrettyTable(data, title = "My Table", border_crayon = crayon"blue")

v3 Example:

In v3, you can create a table and modify it step-by-step.

# Create a table with the default configuration.
pt = pretty_table(data)

# Now, modify its properties as needed.
pt.title = "My Table"
pt.table_format = TextTableFormat(border_crayon = crayon"blue")

2. pretty_table Function Behavior

The pretty_table function no longer prints the table to the console by default. Instead, it returns a PrettyTable object.

v2 Example:

# This would print the table directly to STDOUT.
pretty_table(data)

v3 Example:

To display the table in v3, you can either use the show() function or, if in a REPL, simply have the object as the last statement.

# Create the table object.
pt = pretty_table(data)

# To print the table, you can do:
show(pt)

# Or in a REPL, just this will suffice:
pt

3. Keyword Argument Renames

Several keyword arguments have been renamed for better clarity and consistency. Here is a summary of the changes:

v2 Keyword v3 Keyword
formatter formatters
tf table_format
header column_labels
border_crayon (Part of TextTableFormat)

v2 Example:

pretty_table(data,
    header = ["Col A", "Col B"],
    tf = :simple,
    formatter = my_formatter
)

v3 Example:

pretty_table(data,
    column_labels = ["Col A", "Col B"],
    table_format = tf_simple,
    formatters = my_formatter
)

4. API Redesigns

The APIs for highlighters and table formats have been significantly redesigned for greater flexibility.

4.1. Highlighters

The highlighter API has been completely revamped. Instead of using tuples to define highlighters, v3 introduces dedicated highlighter objects for each backend (TextHighlighter, HtmlHighlighter, etc.).

v2 Example:

# v2 used a tuple-based system.
highlighters = (
    (data, i, j) -> data[i, j] > 10,
    crayon"bold red"
)

v3 Example:

In v3, you create a highlighter object and pass it to the highlighters keyword. This approach is more explicit and powerful.

# Define a highlighter object.
hl_gt10 = TextHighlighter(
    (data, i, j) -> data[i, j] > 10,
    crayon"bold red"
)

# Pass it in a vector to the `highlighters` keyword.
pretty_table(data, highlighters = [hl_gt10])

4.2. Table Formats

Table formats are now defined by immutable structs (TextTableFormat, HtmlTableFormat, etc.). This means that to modify a format, you must create a new format object instead of modifying an existing one.

v2 Example:

# v2 might have allowed direct modification or used symbols.
pretty_table(data, tf = :simple, border_crayon = crayon"green")

v3 Example:

In v3, you instantiate a format object with your desired settings. You can create a new format based on an existing one.

# Create a new table format.
my_format = TextTableFormat(
    border_crayon = crayon"green",
    horizontal_char = '─'
)

# You can also use predefined formats and modify them.
# For example, to get a simple table with no vertical lines:
no_vertical_lines_format = TextTableFormat(; @text__no_vertical_lines)


pretty_table(data, table_format = no_vertical_lines_format)

Conclusion

The changes in PrettyTables.jl v3 are substantial but are designed to provide a more intuitive and powerful API. By following this guide, you should be able to update your code with relative ease.

For a complete overview of all the new features and options, please refer to the official v3 documentation.

4 Likes

You could try installing quarto_jll if the normal installer causes problems for you

2 Likes

The new column_label_alignment option fixed the Quarto build :white_check_mark:

@Ronis_BR although the build is successful, the output with the workaround is raw HTML:

I removed the workaround and the output is rendered properly:

Now we are back to show in html is a bit hard to read · Issue #3378 · JuliaData/DataFrames.jl · GitHub.

Do you have a new workaround to better align the DataFrame columns?

Hum, the old workaround should still work. We need to verify why the system is not rendering the HTML output and showing plain text instead.