Skip to content
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

Dataset usage tracking and purging of expired temporary datasets #503

Merged
merged 13 commits into from
Jan 30, 2024

Conversation

robertbartel
Copy link
Contributor

Adds functionality to maintain links between datasets and things using the datasets (e.g., a job), in order to ensure that the life of temporary datasets is extended based on their use.

Also adds service functionality to periodically purge temporary datasets that have expired.

@robertbartel robertbartel added enhancement New feature or request maas MaaS Workstream labels Jan 25, 2024
Adding convenience method to DatasetManager to simplify creating
temporary datasets.
Adding mock implementation and unit tests class for DatasetManager and
the methods it implements directly, along with set of tests for the
create_temporary method.
Implementing the logic to initiate, hold, and release linkage between
DatasetManager and DatasetUser.
Updating deserialization process for Dataset instances to drop
microseconds from applicable datetime attributes, via a Pydantic
validator.
Updating service manager for dataservice with functions to support
purging expired temporary datasets.
Adding async task to service manager setup in main dataservice function
to manage temporary datasets.
Copy link
Member

@aaraney aaraney left a comment

Choose a reason for hiding this comment

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

Looks good! I left a few comments that should be pretty easy to get through. Thanks!

@@ -671,6 +686,41 @@ def filter(self, base_dataset: Dataset, restrictions: List[Union[ContinuousRestr
"""
pass

def get_dataset_user(self, uuid: UUID) -> DatasetUser:
Copy link
Member

Choose a reason for hiding this comment

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

Any reason not to return Optional[DatasetUser] here instead of throwing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intent for the function is that it will only receive a user UUID value corresponding to a user instance that the manager is linked with (perhaps the caller even received the UUID from the manager; that's done in the ServiceManager in one spot). If some other UUID is given, it's fundamentally a problem.

I'd also expect real-world calls without a proper corresponding user object to generally be bug related: e.g., the manager failed to completely track a user properly when it was linked. An immediate error made more sense to me there.

python/lib/core/dmod/core/dataset.py Show resolved Hide resolved
python/lib/core/dmod/core/dataset.py Show resolved Hide resolved
python/lib/core/dmod/core/dataset.py Show resolved Hide resolved
next invocation).
"""
# Get these upfront, since no meaningful changes can happen during the course of an iteration
temp_datasets = {ds_name: ds for ds_name, ds in self.get_known_datasets().values() if ds.is_temporary}
Copy link
Member

Choose a reason for hiding this comment

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

I think this is fine so long as temp datasets can only be used by a single job. If a temp dataset can be referenced by multiple jobs, I think there is a data race if a job starts that uses a temp dataset but the dataservice is waiting to check for new jobs. The temp dataset that job depends on could be swept.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I'll need to put something in ServiceManager.perform_checks_for_job to block the mark and sweep routine (or maybe even just the sweep portion). I'll also either have to unmark in this function, or perhaps move the logic for linking job users to here.

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 have made some changes to account for this.

python/services/dataservice/dmod/dataservice/service.py Outdated Show resolved Hide resolved
Copy link
Member

@aaraney aaraney left a comment

Choose a reason for hiding this comment

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

Looks good! I left a few comments that should be pretty easy to get through. Thanks!

robertbartel and others added 4 commits January 29, 2024 06:39
Updating dataservice ServiceManager class to block processing of
managing temporary datasets at all times when datasets may be marked as
fulfilling data requirements, including updating the latter to also do
linking to dataset users at the same time.
Ensuring that dataservice service.py uses items() function rather than
values().
@robertbartel
Copy link
Contributor Author

@aaraney, this is ready for re-review, although I am a little concerned about the test fails. I was having the same failures after my initial requested changes, but I cleared them up locally by switching values() calls to `items(). Though the failure remain in the action runners ... maybe? I'm wondering if maybe something is just cached?

@aaraney
Copy link
Member

aaraney commented Jan 30, 2024

@robertbartel, yeah that is odd about the tests failing. I pulled your branch and the tests passed fine for me.

@aaraney
Copy link
Member

aaraney commented Jan 30, 2024

@robertbartel, like you suspected, after clearing the runner caches the tests are passing again.

Copy link
Member

@aaraney aaraney left a comment

Choose a reason for hiding this comment

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

Changes look good to me!

@aaraney aaraney merged commit abc684f into NOAA-OWP:master Jan 30, 2024
4 checks passed
aaraney added a commit to aaraney/DMOD that referenced this pull request Jan 31, 2024
aaraney added a commit to aaraney/DMOD that referenced this pull request Jan 31, 2024
@robertbartel robertbartel deleted the f/temp_ds_purge/main branch February 1, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request maas MaaS Workstream
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants