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

Clean up the API for release #235

Merged
merged 2 commits into from
Apr 23, 2024
Merged

Clean up the API for release #235

merged 2 commits into from
Apr 23, 2024

Conversation

JamesWrigley
Copy link
Member

Leaving this as a draft for now because it's still missing a lot of edge cases, notably around user-editable variables.

Example:

damn_db = Damnit(6156)            # Create an object to refer to a database for a specific proposal
run_vars = damn_db[311]           # Select a specific run
run_vars.keys()                   # Long list of variable names
run_vars["peak_dataset"].read()   # Read one of them

Fixes #33.

@JamesWrigley JamesWrigley added the enhancement New feature or request label Apr 16, 2024
@JamesWrigley JamesWrigley self-assigned this Apr 16, 2024
@JamesWrigley JamesWrigley marked this pull request as ready for review April 19, 2024 08:57
@JamesWrigley
Copy link
Member Author

I made some more tests and added a VariableData.title property in d9e9f9b, I think the API itself is feature complete now. Last thing to do is the docs...

@JamesWrigley
Copy link
Member Author

Should we treat empty strings as being 'available' for .keys()? 🤔

@JamesWrigley
Copy link
Member Author

Added docs in 2e3c4be.

@takluyver
Copy link
Member

You mean, if a key is only in the database and its value there is '' rather than None? Interesting one. I don't think you can easily get that state with user-editable variables, because we special case the empty string and save None instead:

parsed = variable_type_class.parse(value) if value != '' else None

You probably can for comments, though. I'd say it's probably more friendly to say you can always look up comment, even if it's empty. But I don't feel strongly about that. You could argue that treating empty comments as absent from that run is in keeping with what we do for other missing variables.

@JamesWrigley
Copy link
Member Author

I moved the API to the toplevel module in af7bbc9. I also tried out the include-missing-variables API but didn't really like it, it's annoying to have an extra step to check which variables are actually present 🤷

@JamesWrigley
Copy link
Member Author

If there's no objections, I'd like to merge and deploy this tomorrow.

@JamesWrigley JamesWrigley merged commit 243bb76 into master Apr 23, 2024
3 checks passed
@JamesWrigley JamesWrigley deleted the api branch April 23, 2024 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API to access the data in the table and HDF5 files
2 participants