Open ElenaKhaustova opened 3 days ago
I've prototyped two different approaches for printing:
__repr__()
method for AbstractDataset
based on the implementation of _describe()
method for the specific dataset. Since the __str__
method is not implemented __repr__()
is called when converting object to string, so we have the same results when print(obj)
,obj
.module.Class(arg1=val_1, ..., arg_n=val_n)
where argument values are formatted with pprint.pformat
and then joined as strings, so we construct the resulting string from formatted strings.{'module.Class': {'arg_1:' val_1}, ..., {}}
, so at first the end dictionary is created and then it is formatted with pprint.pformat
thus we can control indentation but it looks less compact._pretty_repr
and providing some level of customisation to user to set up width, indentation, depthI'm curious about what you think. Does it feel good enough? Do we want more or less information provided? Which approach seems better?
One caveats if you are doing pprint
https://github.com/kedro-org/vscode-kedro/pull/33
Description
Parent ticket: https://github.com/kedro-org/kedro/issues/3913
Implement
__repr__
forAbstractDataset
for better dataset representation and printing and further use it withinDataCatalog.__repr__
Context
https://github.com/kedro-org/kedro/issues/3913#issue-2330910213 https://github.com/kedro-org/kedro/issues/1721
Possible Implementation
__str__
method forAbstractDataset
based on the dataset's_describe
which can be adjusted and moved to__repr__
._describe
forMemoryDataset
,LambdaDataset
,SharedMemoryDataset
, andCachedDataset
if needed.pprint.PrettyPrinter
.