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

Python3 migration & Emscripten update #133

Merged
merged 17 commits into from
Feb 11, 2024
Merged

Python3 migration & Emscripten update #133

merged 17 commits into from
Feb 11, 2024

Conversation

jmarcosfer
Copy link
Collaborator

Two main changes to the build pipeline before other development tasks:

  • update scripts to Python 3
  • update to more recent version of Emscripten (1.39.19 --> 3.1.24)

Notes:

  • Since Emscripten 2.0.3 the default output format is executable javascript (+ wasm) instead of compiling to object files (.bc), unless a -c, -r, or -shared flag is given. Therefore commands have changed slightly and we have two options: either (1) build to object files first, like we used to do, but individually for bindings_essentiajs.o and essentiajs.o because now it doesn't accept multiple files with -o flag; (2) use the new default way, which also means fewer commands, and go directly from C++ to JS+WASM.
  • Not sure whether to leave the changes on "update included and excluded algo lists" and "add excluded tensor algos to script", perhaps those should go in on a separate development branch.

@jmarcosfer jmarcosfer self-assigned this Jan 7, 2024
@jmarcosfer jmarcosfer linked an issue Jan 7, 2024 that may be closed by this pull request
@jmarcosfer
Copy link
Collaborator Author

@albincorreya let me know what you think about the 2 notes in question, please

Copy link
Member

@albincorreya albincorreya left a comment

Choose a reason for hiding this comment

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

The new default compiling method looks clean. Is there any major performance difference between these methods?

I assume we will migrate the python scripts to python3 in another PR?

Dockerfile Outdated
&& rm /tmp/requirements.txt
# install essentia python bindings from pre-compiled wheels
COPY src/python/essentia-2.1b6.dev861-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl /tmp/essentia-2.1b6.dev861-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Copy link
Member

Choose a reason for hiding this comment

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

Why not directly install the pip wheels from PyPi? Ideally we shouldn't store binaries in the repository.

Copy link
Member

Choose a reason for hiding this comment

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

Ideally we shouldn't need to install this if we compile essentia with python3 bindings. It will install the latest python library as well. I don't remember the details but there was some issues with it at that time. We could test it again to see if it solves now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I seem to remember I found some issues back in september when I did this, but let me re-try with a regular PyPi install to see if it works

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you're right, this still produces a Could not build python extensions error, so I'll leave essentia in requirements.txt for now

Dockerfile Outdated Show resolved Hide resolved
NPM_PATH=/emsdk/node/12.18.1_64bit/bin/npm
NODE_PATH=/emsdk/node/12.18.1_64bit/bin/node
# NPM_PATH=/emsdk/node/12.18.1_64bit/bin/npm
# NODE_PATH=/emsdk/node/12.18.1_64bit/bin/node
Copy link
Member

Choose a reason for hiding this comment

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

we can remove these comments if the entrypoint issues are resolved

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, I didn't find any issues with the latest emscripten base docker image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

However I can see the CI build workflow failing because it grabs the pre-built docker image from Docker Hub, so the change to the newer emscripten version is not reflected on the CI workflow.
I wonder if there is a way to build the image from the Dockerfile on the github CI workflow for these changes to the build pipeline instead of grabbing from Docker Hub...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's definitely possible to build the Docker image in a GitHub workflow, but I should create a new build-dev workflow for when we commit changes to the Dockerfile itself and the other build scripts.

I can do that on this PR to ensure that the other changes result in a successful build process.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have done this now and checks are passing. I would remove the files being watched on the new "build-dev" workflow from the other two workflows (integration.yml and deploy.yml), let me know what you think about that @albincorreya

Copy link
Member

Choose a reason for hiding this comment

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

Great job! We could remove these comments in build-libs.sh since it is not needed anymore?

@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
Copy link
Member

Choose a reason for hiding this comment

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

I assume we will migrate these old python2 scripts to python3 after fixing the build pipeline?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as above, my intention is to do it on this PR
I think all scripts now are compatible with Python 3, but let me know if you see anything that should clearly be changed

Copy link
Member

Choose a reason for hiding this comment

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

Looks like code_generator.py script has python2 string formatting, not sure if python3 supports that? maybe I missed something here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@albincorreya I see what you mean. It seems that modulo string formatting still works in Python3, although f-strings are the preferred syntax. If it's okay with you, I think it makes sense to do the switch to f-strings on the code_generator.py script on the object-oriented PR that I'm working on, because that will already change significant portions of the script.

Copy link
Member

Choose a reason for hiding this comment

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

@jmarcosfer make sense, let's merge this then 💯

Makefile.essentiajs Show resolved Hide resolved
Makefile2.essentiajs Outdated Show resolved Hide resolved
@jmarcosfer
Copy link
Collaborator Author

jmarcosfer commented Jan 8, 2024

The new default compiling method looks clean. Is there any major performance difference between these methods?

I assume we will migrate the python scripts to python3 in another PR?

I don't see any noticeable performance difference between the two methods, so I'll stick to the newer default way, which also looks cleaner as you say :)
The change to Python3 should be included in this PR, that was the initial goal of this PR, but then along the way I found I should update Emscripten too. I guess it's okay to include the two as updating the build pipeline.

Copy link
Member

@albincorreya albincorreya left a comment

Choose a reason for hiding this comment

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

@jmarcosfer Nice one with CI:) Left few minor comments

.github/workflows/build-dev.yml Show resolved Hide resolved
- dev
- master
paths:
- 'src/python/requirements.txt'
Copy link
Member

Choose a reason for hiding this comment

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

same

NPM_PATH=/emsdk/node/12.18.1_64bit/bin/npm
NODE_PATH=/emsdk/node/12.18.1_64bit/bin/node
# NPM_PATH=/emsdk/node/12.18.1_64bit/bin/npm
# NODE_PATH=/emsdk/node/12.18.1_64bit/bin/node
Copy link
Member

Choose a reason for hiding this comment

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

Great job! We could remove these comments in build-libs.sh since it is not needed anymore?

@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
Copy link
Member

Choose a reason for hiding this comment

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

Looks like code_generator.py script has python2 string formatting, not sure if python3 supports that? maybe I missed something here

@jmarcosfer jmarcosfer merged commit 9f2c160 into dev Feb 11, 2024
1 check passed
@jmarcosfer jmarcosfer deleted the python3-migration branch February 11, 2024 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Migrate to python 3
2 participants