Skip to content

Commit

Permalink
PB-756: Fix comments for collection assets
Browse files Browse the repository at this point in the history
Add type hint for new function log_extra.
  • Loading branch information
benschs committed Sep 10, 2024
1 parent 77f042b commit 9105c82
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
14 changes: 12 additions & 2 deletions app/stac_api/migrations/0050_collectionassetupload_and_more.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.0.8 on 2024-09-09 10:59
# Generated by Django 5.0.8 on 2024-09-10 12:45

import pgtrigger.compiler
import pgtrigger.migrations
Expand All @@ -19,6 +19,16 @@ class Migration(migrations.Migration):
]

operations = [
migrations.AlterField(
model_name='assetupload',
name='update_interval',
field=models.IntegerField(
default=-1,
help_text=
'Interval in seconds in which the asset data is updated. -1 means that the data is not on a regular basis updated. This field can only be set via the API.',
validators=[django.core.validators.MinValueValidator(-1)]
),
),
migrations.CreateModel(
name='CollectionAssetUpload',
fields=[
Expand Down Expand Up @@ -65,7 +75,7 @@ class Migration(migrations.Migration):
models.IntegerField(
default=-1,
help_text=
'Interval in seconds in which the asset data is updated.-1 means that the data is not on a regular basis updated.This field can only be set via the API.',
'Interval in seconds in which the asset data is updated. -1 means that the data is not on a regular basis updated. This field can only be set via the API.',
validators=[django.core.validators.MinValueValidator(-1)]
)
),
Expand Down
10 changes: 5 additions & 5 deletions app/stac_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,8 @@ class ContentEncoding(models.TextChoices):
null=False,
blank=False,
validators=[MinValueValidator(-1)],
help_text="Interval in seconds in which the asset data is updated."
"-1 means that the data is not on a regular basis updated."
help_text="Interval in seconds in which the asset data is updated. "
"-1 means that the data is not on a regular basis updated. "
"This field can only be set via the API."
)

Expand Down Expand Up @@ -819,7 +819,7 @@ class Meta:
fields=['asset', 'upload_id'],
name='unique_asset_upload_collection_asset_upload_id'
),
# Make sure that there is only one asset upload in progress per asset
# Make sure that there is only one upload in progress per collection asset
models.UniqueConstraint(
fields=['asset', 'status'],
condition=Q(status='in-progress'),
Expand All @@ -837,8 +837,8 @@ def update_asset_from_upload(self):
is set to its asset parent.
'''
logger.debug(
'Updating asset %s file:checksum from %s to %s and update_interval from %d to %d '
'due to upload complete',
'Updating collection asset %s file:checksum from %s to %s and update_interval '
'from %d to %d due to upload complete',
self.asset.name,
self.asset.checksum_multihash,
self.checksum_multihash,
Expand Down
6 changes: 4 additions & 2 deletions app/stac_api/s3_multipart_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from rest_framework import serializers

from stac_api.exceptions import UploadNotInProgressError
from stac_api.models import Asset
from stac_api.models import CollectionAsset
from stac_api.utils import AVAILABLE_S3_BUCKETS
from stac_api.utils import get_s3_cache_control_value
from stac_api.utils import get_s3_client
Expand Down Expand Up @@ -65,8 +67,8 @@ def list_multipart_uploads(self, key=None, limit=100, start=None):
response.get('NextUploadIdMarker', None),
)

def log_extra(self, asset, upload_id=None, parts=None):
if hasattr(asset, 'item'):
def log_extra(self, asset: Asset | CollectionAsset, upload_id=None, parts=None):
if isinstance(asset, Asset):
log_extra = {
'collection': asset.item.collection.name,
'item': asset.item.name,
Expand Down

0 comments on commit 9105c82

Please sign in to comment.