CWorthy-ocean / C-Star

C-Star is a python package for setting up and running ocean model simulations, with a particular focus on marine carbon dioxide removal (mCDR) applications.
https://c-star.readthedocs.io
10 stars 4 forks source link

Better input dataset hash handling #52

Closed dafyddstephenson closed 1 month ago

dafyddstephenson commented 1 month ago

Closes #51 . Branched off #43 - do not merge until after merging #43.

This PR makes InputDataset.file_hash an optional attribute but throws an error in InputDataset.__init__() if source.location_type is "url" and file_hash is None. It also updates Case.from_blueprint to use dict.get rather than attempting to directly access potentially nonexistent keys for optional attributes (such as file_hash).

This behaviour improves consistency following #30 .

dafyddstephenson commented 1 month ago

TIL backticks in commit messages make words disappear... "make Optional with ValueError if None and is" = "Make InputDataset.file_hash Optional with ValueError if None and InputDataset.source.location_type is 'url'"

dafyddstephenson commented 1 month ago

@TomNicholas Hoping to put this in so I can update the changelog in #55 (branched off this one). Any comments?