-
Notifications
You must be signed in to change notification settings - Fork 613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] make repr formatting narrower #903
Conversation
Hi @davanstrien thanks for your PR. I want to follow-up on it. Is it still a Draft/WIP work or it's ready to review/merge ? |
If everyone is happy with the suggested approach, then I would suggest adding this updated |
I quickly looked at @davanstrien Since you already started working on it, would you mind taking care of it ? Thanks in advance :) |
Sure, I'm super busy at the moment so I likely won't be able to look at this until mid-September. |
Ok thanks, that's fine 👍 |
The documentation is not available anymore as the PR was closed or merged. |
@Wauplin I've used a Mixin to implement this new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for completing this @davanstrien ! Failing tests are indeed not related. I'm merging the PR :)
What this PR does?
This PR aims to make the
__repr__
s inhf_api.py
easier to view on a narrow screen i.e. to favour a longer__repr__
for a class over a short but very wide__repr__
. This PR closes #857Intended outcome
As discussed in #857, the goal here is to have a
__repr__
that is easy to view on a narrow screen without horizontal scrolling.I have tried to make sure the approach taken doesn't do anything esoteric and doesn't add too much additional code to the
__repr__
. I have tried to keep the format of the__repr__
as similar to what is there now, except for making it narrower.Approach taken
For now, I have just changed the
__repr__
forModelInfo
to get initial feedback. The__repr__
now usespprint.pformat
to offload the formatting work for the attributes inside the class. At the moment, the__repr__
s for all the classes inhf_api.py
show all the attributes, but it would also be possible to hide some before passing topformat
if needed. I chose this approach since many people working with python will be at least vaguely familiar with pprint so hopefully, the code is quite easily understood.My suggestion, if this approach/format looks okay, would be to add this to all the classes in
hf_api
. There is also the option of tweaking thewidth
parameter used bypformat
.An example of the output given by the old and new
__repr__
are shown below.old
new