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

Upgrade python and node versions, use pip-tools for dependency freezing #1682

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

alastair
Copy link
Member

@alastair alastair commented May 8, 2023

Description
After giving the talk at the general meeting yesterday I realised that we're using python 3.7, which will be unsupported in a month! (after all of @Bomme's hard work upgrading us from a different unsupported python...)

I saw two options to upgrade the python version:

  • Update to debian 11, which comes with python 3.9
  • Just use the official docker python 3.11 base image, which is based off of debian anyway

In the end I went for the most recent version of python, in order to take advantage of potential code speedups. We should try and measure container performance before and after the release (although I guess this is more difficult now without grafana...)
It turns out that python 3.11 deleted a bunch of previoulsy deprecated things and our version of celery doesn't work, requiring a non-released beta version to work properly. What's more, some syntax for defining celery tasks has changed between 4.x and 5.x, meaning that we require changes to fs code to upgrade celery too. In light of that, let's just stick with python 3.10 until a new version of celery comes out and then we can upgrade that in one go.

In addition, I added the use of pip-compile to take a list of top level dependencies and generate a file of all transitive dependencies, as we had previously discussed with @Bomme
I noticed that our original requirements.txt file was already pretty "light", with what appears to be only top-level dependencies anyway, that's great! We can double-check that these dependencies are accurate.

I swapped out the use of pip install --no-cache-dir for RUN --cache in the Dockerfile. This means that docker will cache the pip wheel dir on your computer making rebuilds faster, as it doesn't need to download the wheels again (this was mostly done because doing multiple builds on my current internet connection takes ages due to slow download speeds!).
This requires docker "buildkit" to be enabled. It's enabled by default on docker for mac and Docker versions > 23.0 (which is the case for sonic). Let me know if you think we should keep it or remove it.

edit: In retrospect this was really annoying to get going on github actions, and I'm not too against going back to the original system

While I was here, I upgraded Node to a more recent LTS (v14 -> v18. v20 is the current latest LTS).

There are still a few pending items that we should look at:

  • Ensure that tests run
  • Ensure that JS assets correctly build
  • Upgrade the version of our other top-level dependencies and re-test
    • I upgraded enough to run the code on py 3.10, should we go further?
  • Remove any packages/specific versions that are added because of our old versions (e.g. importlib-metadata)
  • Configure pip-compile for similarity/clustering/tagrec requirements files and test. (as similarity is still py2, I'd vote to skip this one)
  • Look at upgrading python dependencies on the freesound-audio-analyzers repo. I believe that these containers are completely isolated and so shouldn't be affected by this upgrade, and so perhaps we can ignore that for now.

Deployment steps:

@alastair alastair requested review from ffont and Bomme May 8, 2023 23:59
@alastair alastair force-pushed the python-upgrade branch 3 times, most recently from 493be10 to 5995537 Compare May 9, 2023 02:25
Copy link
Contributor

@Bomme Bomme 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 @alastair!

The only comment I have about this is that we would want to update the requirements.in in the future to reflect the actual requirements that we have.
For example, we might just need some version of beautifulsoup4 between 4 and 5 and let the version pinning be handled by pip-compile.

docker/Dockerfile.base Outdated Show resolved Hide resolved
@alastair
Copy link
Member Author

Thanks @Bomme. I agree that it'd be nice to have version ranges in requirements.in. However, this can probably be left for a next step. what do you think?

@ffont ffont merged commit 105008b into master Jul 27, 2023
1 check passed
@ffont ffont deleted the python-upgrade branch July 27, 2023 09:13
@@ -104,10 +104,10 @@ def test_clean_html(self):
self.assertEqual('<p></p>', ret)

ret = clean_html('<A REL="nofollow" hREF="http://www.google.com"><strong>http://www.google.com</strong></a>')
self.assertEqual('<a href="http://www.google.com" rel="nofollow"><strong>http://www.google.com</strong></a>', ret)
self.assertEqual('<a rel="nofollow" href="http://www.google.com"><strong>http://www.google.com</strong></a>', ret)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should be using assertHTMLEqual to avoid changes like this in the future

@@ -0,0 +1,53 @@
akismet==1.0.1
autopep8==1.5.7
Copy link
Contributor

Choose a reason for hiding this comment

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

We can put dev requirements to a separate requirements.in

@@ -1,7 +1,7 @@
ARG PYTHON
FROM debian:10
FROM python:3.10
Copy link
Contributor

Choose a reason for hiding this comment

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

I have the feeling that a number of dependencies were not ready for Python > 3.7 😅

@ffont ffont mentioned this pull request Jul 27, 2023
@ffont ffont restored the python-upgrade branch September 14, 2023 08:55
@alastair alastair deleted the python-upgrade branch October 16, 2023 16:06
@ffont ffont restored the python-upgrade branch October 24, 2023 19:17
@alastair alastair mentioned this pull request Oct 30, 2023
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.

None yet

3 participants