-
Notifications
You must be signed in to change notification settings - Fork 45
Django to 4.2.0 #1959
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
base: develop
Are you sure you want to change the base?
Django to 4.2.0 #1959
Conversation
|
I checked the failing tests for def test_manual_migration_makes_submissions_from_one_phase_in_another(self):
self.client.login(username='creator', password='creator')
# make 5 submissions in phase 1
for _ in range(5):
SubmissionFactory(owner=self.creator, phase=self.phase_1, status=Submission.FINISHED, leaderboard=self.leaderboard)
assert self.phase_1.submissions.count() == 5
assert self.phase_2.submissions.count() == 0
# call "migrate" from phase 1 -> 2
with mock.patch("competitions.tasks.run_submission") as run_submission_mock:
url = reverse('phases-manually_migrate', kwargs={"pk": self.phase_1.pk})
resp = self.client.post(url)
assert resp.status_code == 200
# Test failing here:
assert run_submission_mock.call_count == 5
# check phase 2 has the 5 submissions
assert self.phase_1.submissions.count() == 5
# Test failing here:
assert self.phase_2.submissions.count() == 5I don't understand some lines and here are some comments:
I am still looking into this and will share more details if I find something interesting |
|
Ihsaan, While working on the build errors in circleci I made some changes to django settings files and all non e2e (UI) tests now pass, so the good news is we can "skip" dealing with this perhaps as maybe it was something deeper with the settings file. I also added these migrations in (tonight) and they are making real simple changes to id fields in the migrations and they were created by django manage.py We can discuss tomorrow but it's getting better... PS: Ran a search on the code project for The So while nothing is done, the mock variable |
|
It looks like all the e2e are failing because of "Server stopped". According to GPT this comes from channels. We could check if the current version of channels is problematic. Some feedback from GPT:Why your tests die with "Server stopped" channels.testing.LiveServerTestCase in Channels 4+ is more strict: In your docker-compose.selenium.yml, Django exposes 36475, but LiveServerTestCase defaults to 8081. |
|
I have merged develop into django branch and resolved the conflicts. Conflicting files were toml and lock files that i accepted from django branch. |
|
Shouldn't we keep this PR for release 1.22.0? 1.21.0 is already quite heavy and late, maybe it is risky to add this on top of it. |
|
@Didayolo ok for separating the django upgrade from 1.21. In this case, we will plan the 1.22 directly after. |
|
I fixed the issue we had with botocore and HTTPS/HTTP connections. However, we need to update the package to get a real fix. |
|
Now that #2042 has been merged, we need to rebase this branch so that we can hopefully have passing tests |
|
I tried rebasing locally, then ran the makemigrations --merge and migrate commands but they are failing. Error : Applying datasets.0011_alter_data_data_file_alter_data_id_and_more...Traceback (most recent call last):
File "/app/manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 356, in handle
post_migrate_state = executor.migrate(
File "/usr/local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
File "/usr/local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
File "/usr/local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
File "/usr/local/lib/python3.10/site-packages/django/db/migrations/migration.py", line 118, in apply
operation.state_forwards(self.app_label, project_state)
File "/usr/local/lib/python3.10/site-packages/django/db/migrations/operations/fields.py", line 219, in state_forwards
state.alter_field(
File "/usr/local/lib/python3.10/site-packages/django/db/migrations/state.py", line 272, in alter_field
fields = self.models[model_key].fields
KeyError: ('datasets', 'datagroup')Makemigrations --merge : Merging datasets
Branch 0011_alter_data_data_file_alter_data_id_and_more
- Alter field data_file on data
- Alter field id on data
- Alter field id on datagroup
Branch 0013_merge_0011_auto_20250623_1341_0012_delete_datagroup
- Add field downloads to data
- Add field is_verified to data
- Add field license to data
- Delete model DataGroup
- Remove field chahub_data_hash from data
- Remove field chahub_needs_retry from data
- Remove field chahub_timestamp from data
- Remove field deleted from data
Merging will only work if the operations printed above do not conflict
with each other (working on different fields or models)
Should these migration branches be merged? [y/N] y
Created new merge migration /app/src/apps/datasets/migrations/0014_merge_20251212_0942.py
Merging tasks
Branch 0005_alter_solution_id_alter_task_id
- Alter field id on solution
- Alter field id on task
Branch 0005_auto_20250623_1341
- Remove field chahub_data_hash from solution
- Remove field chahub_needs_retry from solution
- Remove field chahub_timestamp from solution
- Remove field deleted from solution
- Remove field chahub_data_hash from task
- Remove field chahub_needs_retry from task
- Remove field chahub_timestamp from task
- Remove field deleted from task
Merging will only work if the operations printed above do not conflict
with each other (working on different fields or models)
Should these migration branches be merged? [y/N] y
Created new merge migration /app/src/apps/tasks/migrations/0006_merge_20251212_0942.py
Merging competitions
Branch 0059_alter_competition_fact_sheet_alter_competition_id_and_more
- Alter field fact_sheet on competition
- Alter field id on competition
- Alter field id on competitioncreationtaskstatus
- Alter field id on competitiondump
- Alter field id on competitionparticipant
- Alter field id on competitionwhitelistemail
- Alter field id on page
- Alter field id on phase
- Alter field id on phasetaskinstance
- Alter field detailed_result on submission
- Alter field fact_sheet_answers on submission
- Alter field id on submission
- Alter field prediction_result on submission
- Alter field scoring_result on submission
- Alter field data_file on submissiondetails
- Alter field id on submissiondetails
Branch 0059_auto_20250623_1341
- Remove field chahub_data_hash from competition
- Remove field chahub_needs_retry from competition
- Remove field chahub_timestamp from competition
- Remove field deleted from competition
- Remove field chahub_data_hash from competitionparticipant
- Remove field chahub_needs_retry from competitionparticipant
- Remove field chahub_timestamp from competitionparticipant
- Remove field deleted from competitionparticipant
- Remove field chahub_data_hash from phase
- Remove field chahub_needs_retry from phase
- Remove field chahub_timestamp from phase
- Remove field deleted from phase
- Remove field chahub_data_hash from submission
- Remove field chahub_needs_retry from submission
- Remove field chahub_timestamp from submission
- Remove field deleted from submission
Merging will only work if the operations printed above do not conflict
with each other (working on different fields or models)
Should these migration branches be merged? [y/N] y
Created new merge migration /app/src/apps/competitions/migrations/0060_merge_20251212_0942.py
Merging profiles
Branch 0017_alter_deleteduser_id_alter_githubuserinfo_id_and_more
- Alter field id on deleteduser
- Alter field id on githubuserinfo
- Alter field id on membership
- Alter field id on organization
- Alter field id on user
Branch 0019_merge_0017_user_is_banned_0018_auto_20250623_1719
- Change managers on user
- Remove field chahub_data_hash from user
- Remove field chahub_needs_retry from user
- Remove field chahub_timestamp from user
- Remove field deleted from user
- Change managers on user
- Add field is_banned to user
Merging will only work if the operations printed above do not conflict
with each other (working on different fields or models)
Should these migration branches be merged? [y/N] y
Created new merge migration /app/src/apps/profiles/migrations/0020_merge_20251212_0942.pyI'm not sure if I messed up the rebase, the makemigrations --merge, or if it's a new problem we have to fix |
|
Small update, I "deleted" the content of the failing migration file and let the rest of the migrations run. This is the content of the failing migration: # Generated by Django 4.2.23 on 2025-09-08 12:32
from django.db import migrations, models
import utils.data
import utils.storage
class Migration(migrations.Migration):
dependencies = [
("datasets", "0010_auto_20250218_1100"),
]
operations = [
migrations.AlterField(
model_name="data",
name="data_file",
field=models.FileField(
blank=True,
null=True,
storage=utils.storage.PrivateStorageClass(),
upload_to=utils.data.PathWrapper("dataset"),
),
),
migrations.AlterField(
model_name="data",
name="id",
field=models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
migrations.AlterField(
model_name="datagroup",
name="id",
field=models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
]I changed it to be # Generated by Django 4.2.23 on 2025-09-08 12:32
from django.db import migrations, models
import utils.data
import utils.storage
class Migration(migrations.Migration):
passI doubt this is what's supposed to be done in the first place but at least I was able to launch the new e2e tests on the django4 branch locally |
FAILED src/apps/api/tests/test_competitions.py::PhaseMigrationTests::test_manual_migration_makes_submissions_from_one_phase_in_another - AssertionError: assert 0 == 5
FAILED src/apps/api/tests/test_competitions.py::PhaseMigrationTests::test_manual_migration_makes_submissions_out_of_only_parents_not_children - AssertionError: assert 0 == 1
FAILED src/apps/api/tests/test_submissions.py::TaskSelectionTests::test_can_re_run_submissions_with_multiple_tasks - AttributeError: 'NoneType' object has no attribute 'pk'
FAILED src/apps/api/tests/test_submissions.py::TaskSelectionTests::test_can_select_tasks_when_making_submissions - assert [] == [229, 230]
FAILED src/apps/competitions/tests/test_submissions.py::MultipleTasksPerPhaseTests::test_children_always_created_in_the_same_order - AssertionError: assert 1 == 2
FAILED src/apps/competitions/tests/test_submissions.py::MultipleTasksPerPhaseTests::test_making_submission_creates_parent_sub_and_additional_sub_per_task - AssertionError: assert 1 == 2
It seems like the tests were failing locally because we have to use the |
d2e8f94 to
422a9a2
Compare
a2f1cca to
3388f2f
Compare
|
This is because of this env variable in the If we copy the normal |
django_to_4.2.0
This will be incremental but this is the PR to push django up to 4.2.0 LTS
Asociated issue: #1701
Description
Upgrading django to major version 4.2.0 from 3.0.0
A checklist for hand testing
Checklist