irods / python-irodsclient

A Python API for iRODS
Other
62 stars 72 forks source link

Trying to add and set non string metadata values raise different errors #547

Closed mstfdkmn closed 1 month ago

mstfdkmn commented 2 months ago

When I tried to add an integer (or float) value as metadata avu, I got a different error than how the set method returns the error in that case. The reason looks like because of the check for possible empty argument(s) in the add method.

the prc snippet:

from irods.test.helpers import make_session
from irods.meta import iRODSMeta

s = make_session()
target = s.collections.get("/u0137480/home/rods/colA")

meta_set = iRODSMeta("abc", 2, "units")
meta_add = iRODSMeta("abcd", 3, "units")

print("set exception:")
try:
    target.metadata.set(meta_set)
except Exception as e:
    print(e)
print("\nadd exception:")
try:
    target.metadata.add(meta_add)
except Exception as e:
    print(e)

exceptions that I catch:

[irods@dev-u0137480 irods]$ python3 test.py
set exception:
AVU value (2) has incorrect type. AVU fields must be strings, except for units, which could be None.

add exception:
object of type 'int' has no len()

To be able to see the consistent same errors like here for both methods, I can make a pr. Thanks.

trel commented 2 months ago

PR would be great - thanks!

alanking commented 1 month ago

@d-w-moore - Please close if complete. Thanks!