Skip to content

WEB: Better management of releases in the pandas home page #50885

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
datapythonista opened this issue Jan 20, 2023 · 6 comments · Fixed by #56207
Closed

WEB: Better management of releases in the pandas home page #50885

datapythonista opened this issue Jan 20, 2023 · 6 comments · Fixed by #56207
Assignees
Labels
Milestone

Comments

@datapythonista
Copy link
Member

In the pandas home page we show the released versions, both in the Latest version box, and the Previous versions list.

Obtaining the releases is done here. So far, the function is pretty simple, just sorting the releases by date, and assuming the last one by date it's the latest.

While this makes sense, we're planning to release 2.0 shortly, and it's likely that we release 1.5.4 after it. With the current implementation and after those releases, we'd list 1.5.4 as the latest release, which is not great since we expect users to use 2.0, which is not the latest by date, but the newest in terms of features.

The idea is to improve the current implementation to be smarter, and not use the date, but use the version number. This can be done with version.parse.

Since we are implementing this, I think besides detecting the latest version, it can make sense to also filter obsolete versions from the long list of releases. For example, 1.5.3 is the same version as 1.5.2, 1.5.1 and 1.5.0 but with bugs fixed. There is no reason a user would want to install any 1.5 version except the last one. 1.4.4 is a reasonable version, since users may have code using that version that they didn't migrate yet to be compatible with 1.5. But 1.4.3, 1.4.2, 1.4.1 and 1.4.0 shouldn't be used, so probably better to not have them in the list.

I don't think we have any tests for the script that generates the website. But since the new implementation is not trivial, it'd be good to have it tested. Maybe just a tests/test_pandas_web.py in the same directory as the script, and calling pytest on that directory in the documentation build is the best option.

@datapythonista datapythonista added this to the 2.0 milestone Jan 20, 2023
@JustinAmstadt
Copy link

take

@JustinAmstadt
Copy link

JustinAmstadt commented Jan 20, 2023

So the function didn't actually do any sorting in it, however, in order to group versions together to find the max version, sorting is required. The sorting is done by parsing the version ("tag_name" in the code) using version.parse and sorting it. I also made it so that the obsolete versions do not make it into the context map. The output now looks as follows:

{'name': '1.5.3', 'tag': 'v1.5.3', 'published': datetime.datetime(2023, 1, 19, 3, 34, 5), 'url': 'https://github.com/pandas-dev/pandas/releases/download/v1.5.3/pandas-1.5.3.tar.gz'}
{'name': '1.4.4', 'tag': 'v1.4.4', 'published': datetime.datetime(2022, 8, 31, 12, 20, 17), 'url': 'https://github.com/pandas-dev/pandas/releases/download/v1.4.4/pandas-1.4.4.tar.gz'}
{'name': '1.3.5', 'tag': 'v1.3.5', 'published': datetime.datetime(2021, 12, 12, 14, 25, 33), 'url': 'https://github.com/pandas-dev/pandas/releases/download/v1.3.5/pandas-1.3.5.tar.gz'}
{'name': '1.2.5', 'tag': 'v1.2.5', 'published': datetime.datetime(2021, 6, 22, 13, 39, 19), 'url': 'https://github.com/pandas-dev/pandas/releases/download/v1.2.5/pandas-1.2.5.tar.gz'}
{'name': '1.1.5', 'tag': 'v1.1.5', 'published': datetime.datetime(2020, 12, 7, 15, 5, 34), 'url': 'https://github.com/pandas-dev/pandas/releases/download/v1.1.5/pandas-1.1.5.tar.gz'}

I'm not too sure about properly testing the code, though. Is it possible for you to explain further please? What sort of tests should the file run?

This is also might be a very silly question, but I'm having difficulty running a test file that prints the outputs in anywhere but where pandas_web.py is located. I tried using sys.path.insert, but then it was having difficulty locating the config.yml file.

Also, I'm not sure whether this is fine or not, but in order to make my test context work, I had to add this line manually:

context["target_path"] = "build"

This is done normally in the pandas_web.py file by default in the if name == "main" section, so I had to manually add it in myself or I would get an error

@datapythonista
Copy link
Member Author

Thanks @JustinAmstadt, this looks great. Feel free to open a pull request with what you have, even if it's giving you problems. It may be easier to comment directly on the code.

If you use pytest, afaik the root directory being tested is added to the python path. So, when doing python -m pytest web I think you you then should be able to use import pandas_web in your test file. And then inside the test Preprocessors.home_add_releases() mocking the return of the web service with some sample data that emulates some cases, including the tricky case where for example version 2.0 is older than 1.5.4.

Does this answer your questions? As said, feel free to open a PR, and add yourself comments with the questions in the code, if that makes things easier.

@naman1402
Copy link

Hey I am new to open source development, is there any way I can contribute to this repo ?

@srkds
Copy link
Contributor

srkds commented Apr 6, 2023

Hey I am new to open source development, is there any way I can contribute to this repo ?

Hi @NamanMohnani
You can first refer to 🔗contributing page.
There you will find a structured guide on how can one contribute to pandas.
Or you can start with issues labeled with good first issues.

@Masnan-306
Copy link

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
7 participants
@datapythonista @mroeschke @srkds @Masnan-306 @JustinAmstadt @naman1402 and others