-
Notifications
You must be signed in to change notification settings - Fork 14
Sync station storage sources from the stations list, per station or all at once #1357
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
Open
mihow
wants to merge
13
commits into
main
Choose a base branch
from
feat/station-sync-action
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e6a4303
docs: design for station row Sync action button [skip ci]
mihow 26439c4
Add a Sync action button to each station row
mihow 89c2574
Address self-review on the station Sync button
mihow 87434eb
docs: next-steps handoff for station sync action (Sync all, perms, jo…
mihow cca5de8
fix(ui): surface DRF plain-string validation errors in parseServerError
mihow 406fbf0
fix(ui): render the sync dialog error above its title
mihow fa3d645
feat(deployments): add "Sync all" and hide per-row Sync on unconnecte…
mihow 25318a8
feat(deployments): allow ML data managers to sync stations
mihow 99cf391
fix(migrations): grant sync_deployment at the object level, not just …
mihow 1ec372f
fix(ui): don't re-enable Sync while a request is still in flight
mihow 7f8e318
docs: frame the station-sync design scope as initial-phase only
mihow 01d1c27
docs: correct sync permission model and trim session handoff
mihow 0d60a1e
fix(deployments): gate sync button on sync permission, not update
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
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
81 changes: 81 additions & 0 deletions
81
ami/main/migrations/0095_grant_sync_deployment_to_mldatamanager.py
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,81 @@ | ||
| """ | ||
| Grant the existing ``sync_deployment`` permission to ``MLDataManager`` role | ||
| groups on projects that already exist. | ||
|
|
||
| ``MLDataManager`` already holds ``run_data_storage_sync_job`` (it can run/retry a | ||
| sync job) but not ``sync_deployment`` (which gates *starting* a sync from a | ||
| station via ``POST /api/v2/deployments/<pk>/sync/`` and the bulk | ||
| ``.../sync-all/`` action). This closes that gap so ML data managers can trigger | ||
| syncs, not only manage the resulting jobs. ``ProjectManager`` already has the | ||
| permission and is unaffected. | ||
|
|
||
| New projects pick this up automatically through ``create_roles_for_project`` | ||
| (``MLDataManager`` now includes the permission); this migration backfills the | ||
| role groups of existing projects. The ``sync_deployment`` permission itself is | ||
| already defined on ``Project.Meta.permissions``, so there is no model/schema | ||
| change here — only a data backfill. | ||
| """ | ||
|
|
||
| from django.db import migrations | ||
| from django.db.models import Q | ||
|
|
||
|
|
||
| def grant_sync_to_mldatamanager(apps, schema_editor): | ||
| Group = apps.get_model("auth", "Group") | ||
| Permission = apps.get_model("auth", "Permission") | ||
| ContentType = apps.get_model("contenttypes", "ContentType") | ||
|
|
||
| try: | ||
| project_ct = ContentType.objects.get(app_label="main", model="project") | ||
| except ContentType.DoesNotExist: | ||
| return | ||
|
|
||
| try: | ||
| perm = Permission.objects.get(codename="sync_deployment", content_type=project_ct) | ||
| except Permission.DoesNotExist: | ||
| return | ||
|
|
||
| for group in Group.objects.filter(Q(name__endswith="_MLDataManager")): | ||
| group.permissions.add(perm) | ||
|
|
||
|
mihow marked this conversation as resolved.
Outdated
|
||
|
|
||
| def revoke_sync_from_mldatamanager(apps, schema_editor): | ||
| Group = apps.get_model("auth", "Group") | ||
| Permission = apps.get_model("auth", "Permission") | ||
| ContentType = apps.get_model("contenttypes", "ContentType") | ||
| GroupObjectPermission = apps.get_model("guardian", "GroupObjectPermission") | ||
|
|
||
| try: | ||
| project_ct = ContentType.objects.get(app_label="main", model="project") | ||
| except ContentType.DoesNotExist: | ||
| return | ||
|
|
||
| try: | ||
| perm = Permission.objects.get(codename="sync_deployment", content_type=project_ct) | ||
| except Permission.DoesNotExist: | ||
| return | ||
|
|
||
| # Only touch MLDataManager groups; ProjectManager holds sync_deployment | ||
| # independently and must keep it. | ||
| mldm_groups = Group.objects.filter(Q(name__endswith="_MLDataManager")) | ||
| for group in mldm_groups: | ||
| group.permissions.remove(perm) | ||
| GroupObjectPermission.objects.filter( | ||
| permission=perm, | ||
| content_type=project_ct, | ||
| group__in=mldm_groups, | ||
| ).delete() | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("main", "0094_enable_async_pipeline_workers"), | ||
| ("guardian", "0002_generic_permissions_index"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython( | ||
| grant_sync_to_mldatamanager, | ||
| revoke_sync_from_mldatamanager, | ||
| ), | ||
| ] | ||
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
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
Oops, something went wrong.
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.