Skip to content

Conversation

@pgm
Copy link
Contributor

@pgm pgm commented Aug 6, 2025

Two changes:

  1. when a dataset is uploaded, it can now be assigned an expiry.
  2. Added a new bb command which actually performs deletes of expired datasets (or those transient datasets over a given age)

Two changes:
1. when a dataset is uploaded, it can now be assigned an expiration date.
2. Added a new bb command which actually performs deletes of expired datasets (or those transient datasets over a given age)
@pgm pgm requested a review from jessica-cheng August 6, 2025 20:30
"""
utils.check_celery()

if not dataset.is_transient and dataset.expiry_in_seconds is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally prefer adding these types of validations within the pydantic model itself since it feels a bit cleaner and will catch malformed request body faster. In addition, this prevents us from needing to do asserts or similar checks later on which I notice you do later on in breadbox/breadbox/compute/dataset_uploads_tasks.py:87

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm less a fan of validations within the pydanic model ... but only for reasons that I'd say more "habit" then anything.

I agree, this is a validation which would make perfect sense to include in the pydantic model. I'll fix.

allowed_values=valid_fields.valid_allowed_values,
dataset_metadata=dataset_metadata,
dataset_md5=None,
expiry=None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that we are manually setting this field multiple places even though it is already default to None. Is there a reason we need to explicitly set this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's being set to None in the legacy code paths. I've only updated the dataset-v2 endpoint's code path to be aware of expiry.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see what you're saying. On the pydantic model expiry is specified as:

expiry: Annotated[Optional[datetime], Field(default=None,)]

I'd love to leave out the expiry=None here, but pyright doesn't seem to be aware of the the defaulting and complained that I wasn't providing expiry.



def get_current_datetime():
# this method only exists to allow us to mock it in tests. Since `datetime` is a built-in we're not able to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks adding this informational comment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants