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

Migration to Python3 #3616

Open
wants to merge 205 commits into
base: main
Choose a base branch
from
Open

Migration to Python3 #3616

wants to merge 205 commits into from

Conversation

milescalabresi
Copy link
Contributor

@milescalabresi milescalabresi commented Feb 17, 2023

Migrate the codebase to Python 3 (currently 3.7, aiming for higher once we bump Django and other packages)

willgearty and others added 5 commits February 16, 2023 21:06
full command/config: python -m modernize --no-diffs --write --nobackups --six-unicode --enforce --fix=default --fix=libmodernize.fixes.fix_open -f classic_division -f open -f idioms -f set_literal -f ws_comma .
@milescalabresi milescalabresi added Infrastructure Security Development Future Django Work in progress dependencies Pull requests that update a dependency file python Pull requests that update Python code labels Feb 17, 2023
@hwatheod
Copy link
Contributor

Regarding Python 3.7, its end-of-life is only a few months way (2023-06-27).

@milescalabresi
Copy link
Contributor Author

Good catch, Ted. I think we want to avoid upgrading Django in this PR (the main limiting library), but we should make a separate issue to bump Django as soon as possible. Then we can bump to a current version of Python. Only potential reason I can see to do it sooner is that this tool https://docs.python.org/3.10/library/functools.html#functools.cmp_to_key buys us a lot of ground with the cmp issue

@hwatheod
Copy link
Contributor

I've been out of the loop on this PR for a while but it's great that you find a solution to the pickle migration problem. And also, cucumber is a great name for the util for working with pickles.

@willgearty
Copy link
Member

When running fab setup to make my new VM, I had to do the following undocumented things:

  1. install setuptools
  2. hit enter twice to confirm various steps

@willgearty
Copy link
Member

willgearty commented Jun 12, 2024

I also ran into the same error that @kkbrum encountered while trying to run fab setup:

ERROR: tablespace "encrypted" already exists

I tried dropping the tablespace, and got this warning:

WARNING: could not open directory "pg_tblspc/16384/PG_14_202107181": No such file or directory

Then I reran fab setup and got this error:

Device /dev/mapper/ubuntu--vg-keep_1 is in use. Cannot proceed with format operation.

@milescalabresi
Copy link
Contributor Author

I made a new, clean VM for Ubuntu 24.04, so hoping that fixes things. Try again, reviewers!

@willgearty
Copy link
Member

willgearty commented Jun 28, 2024

That seems to have worked @milescalabresi. I've got a python 3 dev server up and running now!

Although I will note that it seems to be running significantly slower than before. I realize that all of the caching needs to be done again, but even loading the same page or submitting a form takes a looooong time.

@kkbrum
Copy link
Contributor

kkbrum commented Jul 3, 2024

It worked for me as well. Mine seems a bit slower than before as well, but not as significantly as it seems to be for Will.

Comment on lines -1330 to -1332
response = HttpResponse(content_type='application/pdf')
response = HttpResponse(content=render_to_latex(basedir+'studentschedule.tex', context, 'pdf'),
content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="studentschedules.pdf"'
response.write(render_to_latex(basedir+'studentschedule.tex', context, 'pdf'))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@willgearty what is this supposed to do? I'm not sure I understand

Copy link
Member

Choose a reason for hiding this comment

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

Not sure why, but on Python 3 the student schedule download was broken. This fixes it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you help me understand what this change does? This is the file that causes the database errors that are making the PR tests fail

Copy link
Member

Choose a reason for hiding this comment

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

That's bizarre. There shouldn't be anything different here than what was happening before on Python 2. We render the schedules as a pdf, then set the response as a file download. That's basically it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I don't understand it. Maybe best to discuss in real time.... Or maybe this was actually mitigating an error in another file. Stack seems to indicate these requests are notoriously asynchronous/hard to debug 🤷 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file Development Future Django Infrastructure python Pull requests that update Python code Security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade pillow to 7.1.0?
4 participants