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

Add ability to store multiple cells per HDF5 #63

Merged
merged 7 commits into from
May 7, 2024
Merged

Add ability to store multiple cells per HDF5 #63

merged 7 commits into from
May 7, 2024

Conversation

WardLT
Copy link
Contributor

@WardLT WardLT commented Apr 29, 2024

Fixes #61

  • Add warning if metadata differs between cells added to a H5
  • Add an option that reads any data from an h5, even if a user doesn't know the prefixes

@coveralls
Copy link

coveralls commented Apr 29, 2024

Pull Request Test Coverage Report for Build 8973181701

Details

  • 53 of 54 (98.15%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.7%) to 81.959%

Changes Missing Coverage Covered Lines Changed/Added Lines %
batdata/data.py 53 54 98.15%
Totals Coverage Status
Change from base Build 8784024460: 0.7%
Covered Lines: 686
Relevant Lines: 837

💛 - Coveralls

Copy link
Contributor

@victorventuri victorventuri left a comment

Choose a reason for hiding this comment

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

The main question that I have is: do these changes require one to know the prefixes that have been saved in order to read the data?

The reason I ask is: in the "released" version, it is relatively straightforward; when I read a battdata.h5, I expect to have at least a raw_data and a metadata fields, and, in most occasions, a cycle_stats one as well. With these newer changes, it is not clear to me how I would get any data without knowing the prefix. In my understanding, the inspect_batdat can inform us which prefixes are stored, which definitely alleviates this.

# Prepend the prefix
if prefix is not None:
key = f'{prefix}-{subset}'
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to get all the cells stored in the hdf5 file, regardless of 'prefix', does this work? Or would it raise an error?
Also, doesn't this require one to know all the prefixes that have been stored?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, it does require knowing the prefixes if they are used when saving the file.

Maybe we should return an error if the prefix is not included in those found in the file?

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 going to add that warning message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -0,0 +1,45 @@
# The `BatteryDataset` Object
Copy link
Contributor

Choose a reason for hiding this comment

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

I just want to say I think this is a fantastic idea! A code-free full description of the main class we use will make it much easier for us to use and alter it as needs arise, as well as for other users to smoothly get started. Nicely done!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, we totally need this for a bunch of features. Will gradually piece it together

return metadata, names

@staticmethod
def get_metadata_from_hdf5(path: Union[str, Path]) -> BatteryMetadata:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little confused... Is this a different function from what it used to be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean different than the old method for reading the metadata from an HDF file?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, comparing the additions and deletions on Github it appears they are the same function? Maybe just moved to a different place in the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. It just moved

@WardLT
Copy link
Contributor Author

WardLT commented May 1, 2024

Good point a out the potential annoyance of having to lookup prefixes before reading. How about I add an 'auto' option to the read which will grab data belonging to the first prefix then warn if there are more than one available?

@victorventuri
Copy link
Contributor

I think the 'auto' idea is good, my question there is: how is the "first" prefix identified? I mean, there's no inherent order to them, right?

I also think there should be a 'all' option, which basically loads all prefixes available. If you think it's wise, the 'all' can also output a warning for memory constraints.

@WardLT
Copy link
Contributor Author

WardLT commented May 6, 2024

@victorventuri , I opted to add a "load by index" option to supply the need for "any." prefix=0 will load the first prefix, alphabetically.

Does this give you the features you'd need?

@WardLT WardLT requested a review from victorventuri May 6, 2024 17:29
Copy link
Contributor

@victorventuri victorventuri left a comment

Choose a reason for hiding this comment

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

This seems good to me!

@WardLT WardLT merged commit 936965d into main May 7, 2024
2 checks passed
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.

Store multiple cells in the same HDF5 file
3 participants