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

MetaData rework #281

Merged
merged 13 commits into from
Nov 14, 2024
Merged

MetaData rework #281

merged 13 commits into from
Nov 14, 2024

Conversation

qubixes
Copy link
Collaborator

@qubixes qubixes commented Nov 8, 2024

This PR improves the internals of the MetaData class. Instead of relying on the PRC iRODSMeta class, a new class is created (MetaDataItem) which encapsulates one entry of the metadata for a data object or collection.

New features:

  • Use meta["some_key"] to quickly get an entry for some key.
  • Use meta.find_all(key=..., value=..., units=...) to find metadata entries.
  • Rename keys/values/units with meta["some_key"].key = "new_key"

Fixes #277 (Open a new issue in the GUI repository if necessary)

@qubixes qubixes changed the title Meta getitem MetaData rework Nov 8, 2024
@qubixes qubixes requested a review from chStaiger November 8, 2024 15:10
@chStaiger
Copy link
Collaborator

chStaiger commented Nov 11, 2024

Some suggestions for error messaging:

  • If the key is set to something else as string or None, the error message is not very user friendly:
    meta["test"].key = meta
    TypeError: expected string or bytes-like object, got 'NoneType'
    ...
    
  • When the key or value is set to '' --> Bad_AVU_Field: AVU attribute ('') is zero-length.

I think we should catch them and turn them into something like ValueError('Metadata key must be string and not empty.') and for the value respectively.

Copy link
Collaborator

@chStaiger chStaiger left a comment

Choose a reason for hiding this comment

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

A very nice new feature and reorganisation of the code!!! Many thanks!
The only thing that needs to be adjusted are the exception strings mentioned above. They might not be understandable by an iRODS rooky.

meta_list = sorted(list(self))
return "\n".join(f" - {meta}" for meta in meta_list)

def find_all(self, key = ..., value = ..., units = ...):
Copy link
Collaborator

Choose a reason for hiding this comment

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

A very useful function!!!

ibridges/meta.py Outdated Show resolved Hide resolved
Co-authored-by: chStaiger <[email protected]>
@JTvD
Copy link
Collaborator

JTvD commented Nov 12, 2024

This PR has quite some feature that are going to make life a lot easier, great work!

@chStaiger chStaiger merged commit 1a8a681 into develop Nov 14, 2024
12 checks passed
@chStaiger chStaiger deleted the meta-getitem branch November 14, 2024 16:20
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.

Sellective metadata set
3 participants