-
Notifications
You must be signed in to change notification settings - Fork 14
Make the async processing service (psv2) the default and update all existing projects #1353
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
276d7c8
chore(main): enable async pipeline workers for all existing projects
mihow 8ee44eb
feat(main): make async pipeline workers the default for new projects
mihow bd4d881
refactor(main): toggle async flag in place with jsonb_set
mihow 1be1204
test(jobs): pin sync dispatch by disabling the flag explicitly
mihow 29cf619
docs(main): correct reverse-migration docstring on prior flag state
mihow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| """ | ||
| Turn on the ``async_pipeline_workers`` feature flag for every existing project. | ||
|
|
||
| This rolls out async ML processing (workers that pull tasks from the NATS queue | ||
| instead of the synchronous push API) to all projects at once. New projects keep | ||
| the model default of ``False`` until they are opted in separately; this migration | ||
| only updates rows that exist at deploy time. | ||
|
|
||
| The flag lives inside the ``feature_flags`` JSONB column (a ``ProjectFeatureFlags`` | ||
| pydantic model). We read each project's flags through the historical model, set the | ||
| one boolean, and write it back. The reverse flips the flag back off for every | ||
| project — a blanket disable. It does not restore per-project values from before the | ||
| rollout, because the field default is ``False`` and this is the first global enable, | ||
| so no project is expected to have been ``True`` beforehand. | ||
| """ | ||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| def enable_async_pipeline_workers(apps, schema_editor): | ||
| Project = apps.get_model("main", "Project") | ||
| for project in Project.objects.all(): | ||
| flags = project.feature_flags | ||
| if not flags.async_pipeline_workers: | ||
| flags.async_pipeline_workers = True | ||
| project.feature_flags = flags | ||
| project.save(update_fields=["feature_flags"]) | ||
|
mihow marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| def disable_async_pipeline_workers(apps, schema_editor): | ||
| Project = apps.get_model("main", "Project") | ||
| for project in Project.objects.all(): | ||
|
mihow marked this conversation as resolved.
Outdated
|
||
| flags = project.feature_flags | ||
| if flags.async_pipeline_workers: | ||
| flags.async_pipeline_workers = False | ||
| project.feature_flags = flags | ||
| project.save(update_fields=["feature_flags"]) | ||
|
mihow marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("main", "0093_occurrence_project_score_index"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython(enable_async_pipeline_workers, disable_async_pipeline_workers), | ||
| ] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.