Python client show/summary/describe improvements


suggestions to improve printing logic in Python client:

  • clearly distinguish __repr__ from __str__:

    • only the second should be used by default for printing. The first should always provide a structured representation (ideally even understandable by the Py interpreter), when the second provides a reader-friendly representation if needed, otherwise __repr__ is also used as a default representation if no __str__ is provided by the class.

    • none of these function should call print directly or indirectly !!! (see impl. in H2OFrame). It's print that will call str() and therefore __str__...

    • see for official recommendation.

  • consider using a logger (by default logging to stdout) for all calls to print that are not part of a method that explicitly aim at printing on stdout (e.g. show, summary, describe…)

  • for complex representations, consider separating data from formatting. Currently, it's all hardcoded, not customizable, and user can often hardly access the various data printed by methods like show or summary.

    • idea behind H2ODisplay is good and should be used to represent most complex objects, but the current implementation is poor (especiallly the calls to print at construction time).

    • for example, summaryshould always be implemented as follow:

      • create an H2ODisplay instance holding all the data that will be printed. For example a list of entries, with each entry having a title/header (optional), a description/text section (optional), a table for data (optional). This should allow to represent any kind of object in a structured way.

      • H2ODisplay can have a formatteror renderer attribute allowing to render its representation in various formats: plain text, html, json… defaults to plain text.

      • H2ODisplay.__str__ returns the application of the formatter to the content.

      • summary calls print(h2o_display_instance)(for backwards compatibility) before returning the H2ODisplay instance itself so that the user can access to the content (or change the formatter for an export to html for example).

Your pinned fields
Click on the next to a field label to start pinning.


New H2O Bugs

Fix versions


Sebastien Poirier