qri-io / qri

you're invited to a data party!
https://qri.io
GNU General Public License v3.0
1.1k stars 66 forks source link

feat(transform): Detect terminal size, pass it to transform to affect DataFrame rendering #1972

Closed dustmop closed 2 years ago

dustmop commented 2 years ago

Depends on https://github.com/qri-io/starlib/pull/146

This PR adds terminal size detection to qri apply. The width and height of the terminal is passed down to lib/ and eventually to transform/ and starlib/dataframe/, where it affects how DataFrames get stringified. Users of the http api can also send this same info via normal arguments, in order to match the correct size of whatever html element they are going to display upon.

The first commit refactors the automation orchestrator a bit, to make passing this info a bit easier. Some new nomenclature is introduced here: rather than Run for runs that commit and Apply for runs that do not commit, this change uses RunAndCommit and RunEphemeral. The idea is that apply as a piece of terminology was intended as a high level command to contrast with qri save. When deeper in the code base, with a different context, it isn't quite as obvious which of these is and isn't making a new commit, especially since those parts of the code are referring to Workflows which are being run in either case.

Some parts of this are missing functionality. In particular, qri save --apply is not handling terminal size information. That can be done in a follow-up PR, the groundwork laid here will make it much easier to implement.