Skip to content

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

Closed
wants to merge 13 commits into from

Conversation

Masnan-306
Copy link

@Masnan-306 Masnan-306 commented Apr 24, 2023

@Masnan-306 Masnan-306 changed the title Added sorting feature and Removed obsolete versions Added version sorting on Web and Removed obsolete versions Apr 24, 2023
@mroeschke mroeschke added the Web pandas website label Apr 24, 2023
Copy link
Member

@datapythonista datapythonista left a 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.

if (v.major, v.minor) == (prev_version.major, prev_version.minor):
# This release is of obsolete version, so skip
continue
latest_releases.append(release)
Copy link
Member

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.

Copy link
Author

@Masnan-306 Masnan-306 May 1, 2023

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.

Copy link
Author

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?

Copy link
Member

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.

Copy link
Author

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.

@frank-monkey
Copy link

@datapythonista could you please review this?

Copy link
Member

@datapythonista datapythonista left a 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.

if (v.major, v.minor) == (prev_version.major, prev_version.minor):
# This release is of obsolete version, so skip
continue
latest_releases.append(release)
Copy link
Member

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.

@Masnan-306
Copy link
Author

@datapythonista could you please review my reply?
I still think that my implementation of creating (version.parse(release["tag_name"]), release) tuple is necessary, since the first serves as the key and the second is a dictionary object that can not be parsed directly. So do you mean that the first element in the tuple can be avoided by using lambda function in sorted? to save space? Thanks for your effort in advance.

@mroeschke
Copy link
Member

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.

@mroeschke mroeschke closed this Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Web pandas website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WEB: Better management of releases in the pandas home page
4 participants