Skip to content
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

Test older versions of pandas, torch #2682

Merged
merged 17 commits into from
Apr 10, 2024
Merged

Test older versions of pandas, torch #2682

merged 17 commits into from
Apr 10, 2024

Conversation

isabelizimm
Copy link
Contributor

@isabelizimm isabelizimm commented Apr 5, 2024

Intent

Describe briefly what problem this pull request resolves, or what new feature it introduces. Include screenshots of any new or altered UI. Link to any GitHub issues that are related.

Instead of time travel, which might be erratic, specifically choose older major versions of packages to run against.

Versions of packages for which we have specific inspectors:

pandas: has 1.X, 2.X
torch: has 1.X, 2.X
polars: still on 0.X, just test latest
numpy: has been 1.X since 2006, soon to release 2.X

related to #2302 #2597

Approach

Describe the approach taken and the tradeoffs involved if non-obvious; add an overview of the solution if it's complicated.

I've changed the name of the requirements file and specifically pinned older versions of packages. These are both the last release of 1.X versions.

QA Notes

Add additional information for QA on how to validate the change, paying special attention to the level of risk, adjacent areas that could be affected by the change, and any important contextual information not present in the linked issues.

You should be able to test this locally with yarn testMinimumPythonReqs. Note that you must use Python 3.9 or lower, since torch 1.X cannot be installed on later versions.

@@ -0,0 +1,2 @@
pandas==1.5.3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is currently testing both of these package versions at the same time, since I don't believe they should interfere with each other. we can split them out if we want, though.

@isabelizimm isabelizimm requested review from wesm and seeM April 8, 2024 17:51
@isabelizimm isabelizimm marked this pull request as ready for review April 8, 2024 17:51
older-versions: false
- os: 'ubuntu-latest'
python: '3.9'
older-versions: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One alternative approach would be to put the pandas / torch / other library versions here instead of in a requirements file. That would make it a bit easier to write down an explicit matrix of library combinations. You would have to have an override step for each supported library (like "Install older pandas version", "Install older torch version", etc.). It wouldn't work for the gulpfile, though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petetronic had previously mentioned that we may want to ensure that our CI tasks are easily reproducible locally, and I agree that it would be helpful to debug these when they fail on CI.

Since the current matrix is simple, I think this is fine, but if we need more flexibility we could consider using something like nox.

It lets you parametrize sessions, and creates a separate virtual environment for each set of parameters (you can opt out of using a venv with @nox.session(python=False). Very roughly, our noxfile would look like:

@nox.session
@nox.parametrize('pandas', ['1.5.3', 'latest'])
@nox.parametrize('torch', ['1'.12.1, 'latest'])
def tests(session, pandas, torch):
    # TODO: install positron_ipykernel and its dependencies
    # TODO: install base test requirements
    if pandas != 'latest':
        session.install(f'pandas=={pandas}')
    if torch != 'latest':
        session.install(f'torch=={torch}')

Then you could run nox --session tests to run the full matrix, or nox --session "tests(pandas='1.5.3', torch='1.12.1')" for just that case, and so on. The GitHub action could also use a matrix that passes its arguments down to a nox --session call.

There is a noxfile from upstream too, but I'd suggest creating our own specifically for the positron_ipykernel package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, nox seems like it might be the best of both worlds. The matrix is much easier to parse, and it would easily be put in a gulpfile. Let me see if I can get that set up, since I think it would set us up better long-term.

python -m pip install --prefer-binary --force-reinstall -r pythonFiles/positron/data-science-requirements.txt
- name: Install minimum supported versions
if: ${{ matrix.older-versions }}
run: python -m pip install --no-deps -r pythonFiles/positron/min-supported.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does --no-deps mean that we could end up with a pandas version as well as incompatible dependencies of pandas?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I was under the impression that it just did not give an error if a dependency couldn't be resolved, but it looks like it would not downgrade dependencies as we need it to. I'll use --force-reinstall instead!

});

// run the tests
await spawnAsync(pythonCommand, pytestArgs).catch((ex) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference would be to repurpose this task to only install the requirements and rename it to installMinSupportedPythonRequirements, then change the package.json script to: gulp installMinSupportedPythonRequirements && pytest pythonFiles/positron. Since IIUC gulp swallows any extra args but yarn passes them through, so I could e.g. do yarn testMinimumPythonReqs --pdb to enable the pytest debugger.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh cool! I didn't know that yarn passed through args. That is super useful for testing

Copy link
Contributor

@seeM seeM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good step! I'm unsure about the --no-deps arg and left a few other nits/thoughts.

@isabelizimm isabelizimm requested a review from seeM April 9, 2024 23:52


@nox.session()
@nox.parametrize('pandas', ['1.5.3'])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sort of prefer to have the desired matrix here, and then always run in CI:

yarn positron:testMinimumPythonReqs

but we can also list latest as a version and use

yarn positron:testMinimumPythonReqs --session "tests(torch='1.12.1', pandas='1.5.3')"

Copy link
Contributor

@seeM seeM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, neat to be trying out nox too! A few more nits - will let you decide whether to implement them

extensions/positron-python/noxfile-positron.py Outdated Show resolved Hide resolved
extensions/positron-python/package.json Outdated Show resolved Hide resolved
.github/workflows/positron-python-ci.yml Outdated Show resolved Hide resolved
isabelizimm and others added 2 commits April 10, 2024 11:49
@isabelizimm isabelizimm merged commit 5b253a2 into main Apr 10, 2024
24 checks passed
@isabelizimm isabelizimm deleted the ci/pandas-matrix branch April 10, 2024 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants