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 blacklist #279

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions docs/source/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,23 @@ Warnings can also be switched off through python's `warnings` package:

.. code-block:: python

import warnings
warnings.filterwarnings("ignore")
import warnings
warnings.filterwarnings("ignore")


**My metadata with keys starting with `org_` do not show up in the iBridges metadata.**
---------------------------------------------------------------------------------------

iBridges **does not show** metadata that contain a key starting with the prefix `org_`. This is due to data security reasons on `Yoda systems <https://github.com/iBridges-for-iRODS/yoda>`__.
By default, iBridges **does not show** metadata that contain a key starting with the prefix `org_`. This is due to data security reasons on `Yoda systems <https://github.com/UtrechtUniversity/yoda>`__.

You can omit this by the following code:

.. code-block:: python

from ibridges.meta import MetaData

# collections
meta = MetaData(IrodsPath(session, "~", "my_coll").collection, blacklist=None)
# data objects
meta = MetaData(IrodsPath(session, "~", "my_obj").dataobject, blacklist=None)
print(meta)
6 changes: 5 additions & 1 deletion ibridges/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ def __iter__(self) -> Iterator:
"""Iterate over all metadata key/value/units triplets."""
if self.blacklist is None:
yield from self.item.metadata.items()
return
for meta in self.item.metadata.items():
if re.match(self.blacklist, meta.name) is None:
if self.blacklist and re.match(self.blacklist, meta.name) is None:
yield meta
else:
warnings.warn(f"Ignoring metadata entry with value {meta.name}, because it matches "
Expand Down Expand Up @@ -148,6 +149,9 @@ def add(self, key: str, value: str, units: Optional[str] = None):
try:
if (key, value, units) in self:
raise ValueError("ADD META: Metadata already present")
if self.blacklist:
if re.match(self.blacklist, key):
raise ValueError(f"ADD META: Key must not start with {self.blacklist}.")
self.item.metadata.add(key, value, units)
except irods.exception.CAT_NO_ACCESS_PERMISSION as error:
raise PermissionError("UPDATE META: no permissions") from error
Expand Down
Loading