-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Added version sorting on Web and Removed obsolete versions #52887
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
Conversation
Masnan-306
commented
Apr 24, 2023
•
edited
Loading
edited
- closes WEB: Better management of releases in the pandas home page #50885
- Tests added and passed
- All code checks passed.
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.
Very nice, thanks @Masnan-306
I added few more comments, but looking great.
web/pandas_web.py
Outdated
if (v.major, v.minor) == (prev_version.major, prev_version.minor): | ||
# This release is of obsolete version, so skip | ||
continue | ||
latest_releases.append(release) |
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.
I think you can use v
here instead of release. Since str(v) == release
I think the render on the website should stay the same. And you don't need to make releases
and sorted_releases
lists (or generators) of tuples, but only of Version
objects, which makes things easier.
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.
I don't think str(v) == release
is true judging from the code below. I think there are fields like assets
and tag_name
in each release
. So I may not understand what you mean here.
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.
@datapythonista Hi, can you give some more clarifications on this?
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.
Sorry for the delay. So, here you keep a tuple to deal with versions: (Version(1, 5, 2), '1.5.2')
. You use the first element to compare versions, and the second to display it in the template. But the template will parse to string whatever you give it when creating the html. And this is true:
>>> from packaging import version
>>> v152 = version.Version('1.5.2')
>>> str(v152)
'1.5.2'
The second element in the tuple is not needed, since you can give the first one to the template, and when rendered it will become the second. So, you can just use Version(...)
instead of the tuple, and simplify the code, which is a bit tricky to follow.
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.
Hi, I am still a little confused. The first element in the tuple is indeed the objectVersion(...)
, but it is parsed from release[tag_name]
but not from release
directly. Since each release
is a dictionary with many fields including assets
, tag_name
, published_at
etc, I can only think of making them key-values pairs in the list (v, release)
and sort the list by the key values v
. In other word, the list latest_releases
consists of tuple like (Version(1,5,2), {...})
instead of (Version(1, 5, 2), '1.5.2')
. So, I'm sorting the dictionaries by the versions and then feed the dictionaries to the next loop.
@datapythonista could you please review this? |
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.
Sorry for the delay @Masnan-306, and for not being clear in my previous review. This is looking better, but I think we can still simplify your implementation significantly, added couple of ideas.
web/pandas_web.py
Outdated
if (v.major, v.minor) == (prev_version.major, prev_version.minor): | ||
# This release is of obsolete version, so skip | ||
continue | ||
latest_releases.append(release) |
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.
Sorry for the delay. So, here you keep a tuple to deal with versions: (Version(1, 5, 2), '1.5.2')
. You use the first element to compare versions, and the second to display it in the template. But the template will parse to string whatever you give it when creating the html. And this is true:
>>> from packaging import version
>>> v152 = version.Version('1.5.2')
>>> str(v152)
'1.5.2'
The second element in the tuple is not needed, since you can give the first one to the template, and when rendered it will become the second. So, you can just use Version(...)
instead of the tuple, and simplify the code, which is a bit tricky to follow.
@datapythonista could you please review my reply? |
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |