Skip to content

Commit

Permalink
Fix spelling of "unembargo"
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnesbitt committed Jun 20, 2024
1 parent 6ae94fc commit 492b48c
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 41 deletions.
10 changes: 4 additions & 6 deletions dandiapi/api/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,14 @@ def build_dandisets_to_unembargo_message(dandisets: Iterable[Dandiset]):
]
render_context = {**BASE_RENDER_CONTEXT, 'dandisets': dandiset_context}
return build_message(
subject='DANDI: New Dandisets to un-embargo',
subject='DANDI: New Dandisets to unembargo',
message=render_to_string('api/mail/dandisets_to_unembargo.txt', render_context),
to=[settings.DANDI_DEV_EMAIL],
)


def send_dandisets_to_unembargo_message(dandisets: Iterable[Dandiset]):
logger.info('Sending dandisets to un-embargo message to devs at %s', settings.DANDI_DEV_EMAIL)
logger.info('Sending dandisets to unembargo message to devs at %s', settings.DANDI_DEV_EMAIL)
messages = [build_dandisets_to_unembargo_message(dandisets)]
with mail.get_connection() as connection:
connection.send_messages(messages)
Expand All @@ -219,17 +219,15 @@ def build_dandiset_unembargoed_message(dandiset: Dandiset):
}
html_message = render_to_string('api/mail/dandiset_unembargoed.html', render_context)
return build_message(
subject='Your Dandiset has been un-embargoed!',
subject='Your Dandiset has been unembargoed!',
message=strip_tags(html_message),
html_message=html_message,
to=[owner.email for owner in dandiset.owners],
)


def send_dandiset_unembargoed_message(dandiset: Dandiset):
logger.info(
'Sending dandisets un-embargoed message to dandiset %s owners.', dandiset.identifier
)
logger.info('Sending dandisets unembargoed message to dandiset %s owners.', dandiset.identifier)
messages = [build_dandiset_unembargoed_message(dandiset)]
with mail.get_connection() as connection:
connection.send_messages(messages)
2 changes: 1 addition & 1 deletion dandiapi/api/migrations/0008_migrate_embargoed_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def migrate_embargoed_blob(embargoed_blob):
# as the above case, but between an embargoed and open dandiset, instead of two
# embargoed dandisets.
#
# In case #3, the asset will effectively be un-embargoed.
# In case #3, the asset will effectively be unembargoed.
existing_blob = AssetBlob.objects.filter(
etag=embargoed_blob.etag, size=embargoed_blob.size
).first()
Expand Down
4 changes: 2 additions & 2 deletions dandiapi/api/services/asset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def add_asset_to_version(
raise ZarrArchiveBelongsToDifferentDandisetError

# Creating an asset in an OPEN dandiset that points to an embargoed blob results in that
# blob being un-embargoed
# blob being unembargoed
unembargo_asset_blob = (
asset_blob is not None
and asset_blob.embargoed
Expand All @@ -159,7 +159,7 @@ def add_asset_to_version(
version.save()

# Perform this after the above transaction has finished, to ensure we only operate on
# un-embargoed asset blobs
# unembargoed asset blobs
if asset_blob and unembargo_asset_blob:
remove_asset_blob_embargoed_tag_task.delay(blob_id=asset_blob.blob_id)

Expand Down
4 changes: 2 additions & 2 deletions dandiapi/api/services/dandiset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dandiapi.api.models.dandiset import Dandiset
from dandiapi.api.models.version import Version
from dandiapi.api.services.dandiset.exceptions import DandisetAlreadyExistsError
from dandiapi.api.services.embargo.exceptions import DandisetUnEmbargoInProgressError
from dandiapi.api.services.embargo.exceptions import DandisetUnembargoInProgressError
from dandiapi.api.services.exceptions import AdminOnlyOperationError, NotAllowedError
from dandiapi.api.services.version.metadata import _normalize_version_metadata

Expand Down Expand Up @@ -57,7 +57,7 @@ def delete_dandiset(*, user, dandiset: Dandiset) -> None:
if dandiset.versions.filter(status=Version.Status.PUBLISHING).exists():
raise NotAllowedError('Cannot delete dandisets that are currently being published.')
if dandiset.embargo_status == Dandiset.EmbargoStatus.UNEMBARGOING:
raise DandisetUnEmbargoInProgressError
raise DandisetUnembargoInProgressError

# Delete all versions first, so that AssetPath deletion is cascaded
# through versions, rather than through zarrs directly
Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/services/embargo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def unembargo_dandiset(*, user: User, dandiset: Dandiset):
raise DandisetActiveUploadsError

# A scheduled task will pick up any new dandisets with this status and email the admins to
# initiate the un-embargo process
# initiate the unembargo process
dandiset.embargo_status = Dandiset.EmbargoStatus.UNEMBARGOING
dandiset.save()

Expand Down
6 changes: 3 additions & 3 deletions dandiapi/api/services/embargo/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class DandisetNotEmbargoedError(DandiError):

class DandisetActiveUploadsError(DandiError):
http_status_code = status.HTTP_400_BAD_REQUEST
message = 'Dandiset un-embargo not allowed with active uploads'
message = 'Dandiset unembargo not allowed with active uploads'


class DandisetUnEmbargoInProgressError(DandiError):
class DandisetUnembargoInProgressError(DandiError):
http_status_code = status.HTTP_400_BAD_REQUEST
message = 'Dandiset modification not allowed during un-embargo'
message = 'Dandiset modification not allowed during unembargo'


class UnauthorizedEmbargoAccessError(DandiError):
Expand Down
4 changes: 2 additions & 2 deletions dandiapi/api/tasks/scheduled.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def send_pending_users_email() -> None:

@shared_task(soft_time_limit=20)
def send_dandisets_to_unembargo_email() -> None:
"""Send an email to admins listing dandisets that have requested un-embargo."""
"""Send an email to admins listing dandisets that have requested unembargo."""
dandisets = Dandiset.objects.filter(embargo_status=Dandiset.EmbargoStatus.UNEMBARGOING)
if dandisets.exists():
send_dandisets_to_unembargo_message(dandisets)
Expand Down Expand Up @@ -148,7 +148,7 @@ def register_scheduled_tasks(sender: Celery, **kwargs):
# Send daily email to admins containing a list of users awaiting approval
sender.add_periodic_task(crontab(hour=0, minute=0), send_pending_users_email.s())

# Send daily email to admins containing a list of dandisets to un-embargo
# Send daily email to admins containing a list of dandisets to unembargo
sender.add_periodic_task(crontab(hour=0, minute=0), send_dandisets_to_unembargo_email.s())

# Refresh the materialized view used by asset search every 10 mins.
Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/templates/api/mail/dandiset_unembargoed.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Dandiset <a href="{{ dandiset.ui_link }}"> {{ dandiset.identifier }} </a> has been un-embargoed, and is now open for
Dandiset <a href="{{ dandiset.ui_link }}"> {{ dandiset.identifier }} </a> has been unembargoed, and is now open for
public access.
<br><br>
<em>You are receiving this email because you are an owner of this dandiset.</em>
2 changes: 1 addition & 1 deletion dandiapi/api/templates/api/mail/dandisets_to_unembargo.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% autoescape off %}
The following new dandisets are awaiting un-embargo:
The following new dandisets are awaiting unembargo:

{% for ds in dandisets %}
Dandiset ID: {{ ds.identifier }}
Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/tests/test_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ def test_asset_create_embargoed_asset_blob_open_dandiset(
api_client, user, draft_version, embargoed_asset_blob, mocker
):
# Ensure that creating an asset in an open dandiset that points to an embargoed asset blob
# results in that asset blob being un-embargoed
# results in that asset blob being unembargoed
assert draft_version.dandiset.embargo_status == Dandiset.EmbargoStatus.OPEN
assert embargoed_asset_blob.embargoed

Expand Down
4 changes: 2 additions & 2 deletions dandiapi/api/tests/test_dandiset.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ def test_dandiset_rest_delete(api_client, draft_version_factory, user):
assert response.status_code == 204
assert not Dandiset.objects.all()

# Ensure that currently un-embargoing dandisets can't be deleted
# Ensure that currently unembargoing dandisets can't be deleted
draft_version = draft_version_factory(
dandiset__embargo_status=Dandiset.EmbargoStatus.UNEMBARGOING
)
Expand Down Expand Up @@ -891,7 +891,7 @@ def test_dandiset_rest_change_owners_unembargoing(
user_factory,
social_account_factory,
):
"""Test that un-embargoing a dandiset prevents user modification."""
"""Test that unembargoing a dandiset prevents user modification."""
draft_version = draft_version_factory(
dandiset__embargo_status=Dandiset.EmbargoStatus.UNEMBARGOING
)
Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/tests/test_unembargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_unembargo_dandiset_sends_emails(
send_dandisets_to_unembargo_email()

assert mailoutbox
assert 'un-embargo' in mailoutbox[0].subject
assert 'unembargo' in mailoutbox[0].subject
assert dandiset.identifier in mailoutbox[0].message().get_payload()
assert user.username in mailoutbox[0].message().get_payload()

Expand Down
8 changes: 4 additions & 4 deletions dandiapi/api/views/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
remove_asset_from_version,
)
from dandiapi.api.services.asset.exceptions import DraftDandisetNotModifiableError
from dandiapi.api.services.embargo.exceptions import DandisetUnEmbargoInProgressError
from dandiapi.api.services.embargo.exceptions import DandisetUnembargoInProgressError
from dandiapi.zarr.models import ZarrArchive

try:
Expand Down Expand Up @@ -325,7 +325,7 @@ def create(self, request, versions__dandiset__pk, versions__version):
)

if version.dandiset.embargo_status == Dandiset.EmbargoStatus.UNEMBARGOING:
raise DandisetUnEmbargoInProgressError
raise DandisetUnembargoInProgressError

serializer = AssetRequestSerializer(data=self.request.data)
serializer.is_valid(raise_exception=True)
Expand Down Expand Up @@ -362,7 +362,7 @@ def update(self, request, versions__dandiset__pk, versions__version, **kwargs):
if version.version != 'draft':
raise DraftDandisetNotModifiableError
if version.dandiset.embargo_status == Dandiset.EmbargoStatus.UNEMBARGOING:
raise DandisetUnEmbargoInProgressError
raise DandisetUnembargoInProgressError

serializer = AssetRequestSerializer(data=self.request.data)
serializer.is_valid(raise_exception=True)
Expand Down Expand Up @@ -400,7 +400,7 @@ def destroy(self, request, versions__dandiset__pk, versions__version, **kwargs):
version=versions__version,
)
if version.dandiset.embargo_status == Dandiset.EmbargoStatus.UNEMBARGOING:
raise DandisetUnEmbargoInProgressError
raise DandisetUnembargoInProgressError

# Lock asset for delete
with transaction.atomic():
Expand Down
4 changes: 2 additions & 2 deletions dandiapi/api/views/dandiset.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from dandiapi.api.services.dandiset import create_dandiset, delete_dandiset
from dandiapi.api.services.embargo import unembargo_dandiset
from dandiapi.api.services.embargo.exceptions import (
DandisetUnEmbargoInProgressError,
DandisetUnembargoInProgressError,
UnauthorizedEmbargoAccessError,
)
from dandiapi.api.views.common import DANDISET_PK_PARAM
Expand Down Expand Up @@ -378,7 +378,7 @@ def users(self, request, dandiset__pk): # noqa: C901
dandiset: Dandiset = self.get_object()
if request.method == 'PUT':
if dandiset.embargo_status == Dandiset.EmbargoStatus.UNEMBARGOING:
raise DandisetUnEmbargoInProgressError
raise DandisetUnembargoInProgressError

# Verify that the user is currently an owner
response = get_40x_or_None(request, ['owner'], dandiset, return_403=True)
Expand Down
6 changes: 3 additions & 3 deletions dandiapi/api/views/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from dandiapi.api.models import AssetBlob, Dandiset, Upload
from dandiapi.api.permissions import IsApproved
from dandiapi.api.services.embargo.exceptions import DandisetUnEmbargoInProgressError
from dandiapi.api.services.embargo.exceptions import DandisetUnembargoInProgressError
from dandiapi.api.tasks import calculate_sha256
from dandiapi.api.views.serializers import AssetBlobSerializer

Expand Down Expand Up @@ -136,9 +136,9 @@ def upload_initialize_view(request: Request) -> HttpResponseBase:
if response:
return response

# Ensure dandiset not in the process of un-embargo
# Ensure dandiset not in the process of unembargo
if dandiset.embargo_status == Dandiset.EmbargoStatus.UNEMBARGOING:
raise DandisetUnEmbargoInProgressError
raise DandisetUnembargoInProgressError

logging.info(
'Starting upload initialization of size %s, ETag %s to dandiset %s',
Expand Down
4 changes: 2 additions & 2 deletions dandiapi/api/views/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from rest_framework_extensions.mixins import DetailSerializerMixin, NestedViewSetMixin

from dandiapi.api.models import Dandiset, Version
from dandiapi.api.services.embargo.exceptions import DandisetUnEmbargoInProgressError
from dandiapi.api.services.embargo.exceptions import DandisetUnembargoInProgressError
from dandiapi.api.services.publish import publish_dandiset
from dandiapi.api.tasks import delete_doi_task
from dandiapi.api.views.common import DANDISET_PK_PARAM, VERSION_PARAM
Expand Down Expand Up @@ -96,7 +96,7 @@ def update(self, request, **kwargs):
status=status.HTTP_405_METHOD_NOT_ALLOWED,
)
if version.dandiset.embargo_status == Dandiset.EmbargoStatus.UNEMBARGOING:
raise DandisetUnEmbargoInProgressError
raise DandisetUnembargoInProgressError

serializer = VersionMetadataSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
Expand Down
10 changes: 5 additions & 5 deletions doc/design/embargo-redesign.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ sequenceDiagram
end
```

## Change to Un-Embargo Procedure
## Change to Unembargo Procedure

Once the time comes to *********un-embargo********* those files, all that is required is to remove the `embargoed` tag from all of the objects. This can be achieved by an [S3 Batch Operations Job](https://docs.aws.amazon.com/AmazonS3/latest/userguide/batch-ops-create-job.html), in which the list of files is specified (all files belonging to the dandiset), and the desired action is specified (delete/replace tags).
Once the time comes to *********unembargo********* those files, all that is required is to remove the `embargoed` tag from all of the objects. This can be achieved by an [S3 Batch Operations Job](https://docs.aws.amazon.com/AmazonS3/latest/userguide/batch-ops-create-job.html), in which the list of files is specified (all files belonging to the dandiset), and the desired action is specified (delete/replace tags).

The benefit of this approach is that once the files are uploaded, no further movement is required to change the embargo state, eliminating the storage, egress, and time costs associated with unembargoing from a second bucket. Using S3 Batch Operations to perform the untagging also means we can rely on AWS’s own error reporting mechanisms, while retrying any failed operations requires only minimal engineering effort within the Archive codebase.

Expand All @@ -85,7 +85,7 @@ The benefit of this approach is that once the files are uploaded, no further mov
4. If there are no failures, the Job ID is set to null in the DB model, and the embargo status, metadata, etc. is updated to reflect that the dandiset is now `OPEN`.
5. Otherwise, an exception is raised and attended to by the developers.

A diagram of the un-embargo procedure (pertaining to just the objects) is shown below
A diagram of the unembargo procedure (pertaining to just the objects) is shown below

```mermaid
sequenceDiagram
Expand All @@ -95,8 +95,8 @@ sequenceDiagram
participant Worker
participant S3
Client ->> Server: Un-embargo dandiset
Server ->> Worker: Dispatch un-embargo task
Client ->> Server: Unembargo dandiset
Server ->> Worker: Dispatch unembargo task
Worker ->> S3: List of all dandiset objects are aggregated into a manifest
Worker ->> S3: S3 Batch Operation job created
S3 ->> Worker: Job ID is returned
Expand Down
4 changes: 2 additions & 2 deletions web/src/views/DandisetLandingView/DandisetUnembargo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<v-divider class="my-3" />
<v-card-text>
<span>
This action will un-embargo this dandiset. Note that this is a
This action will unembargo this dandiset. Note that this is a
<span class="font-weight-bold">
permanent
</span>
action and cannot be undone. Once a dandiset has been un-embargoed,
action and cannot be undone. Once a dandiset has been unembargoed,
it cannot be re-embargoed.
<br><br>
Note: this may take several days to complete.
Expand Down

0 comments on commit 492b48c

Please sign in to comment.