Skip to content

[#835] allow key-agnostic iRODSMeta construction for AVU assignments - #836

Open
d-w-moore wants to merge 16 commits into
irods:mainfrom
d-w-moore:835.m
Open

d-w-moore wants to merge 16 commits into
irods:mainfrom
d-w-moore:835.m

Conversation

@d-w-moore

Copy link
Copy Markdown
Collaborator

No description provided.

@d-w-moore
d-w-moore marked this pull request as draft September 14, 2026 15:54
@d-w-moore d-w-moore changed the title #835 allow key-agnostic iRODSMeta construction for AVU assignments [#835] allow key-agnostic iRODSMeta construction for AVU assignments Sep 14, 2026
@d-w-moore
d-w-moore marked this pull request as ready for review September 14, 2026 19:04
@d-w-moore
d-w-moore marked this pull request as ready for review September 15, 2026 16:38
@d-w-moore

Copy link
Copy Markdown
Collaborator Author

ready for review. Until review comments are seen, the changes from here on will be only for codacy/ruff and other minor modifications as needed.

Comment thread irods/test/meta_test.py
Comment thread irods/meta.py Outdated

@MartinFlores751 MartinFlores751 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code is looking good to me, only have one suggestion. Learned about the := operator.

Comment thread irods/test/meta_test.py Outdated
# Set a number of metadata AVUs with the iRODSMeta builder invocation. (Each of
# these AVU values follow a predictable relation defined by the test_mapping function.)
def test_mapping(name): return str(ord(name))
avu_names = [chr(_) for _ in range(ord('a'), ord('z')+1)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Style question. Is it preferable to use _ here? I thought _ was equivalent to "discard this result" and was a bit surprised to see it work.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

_ is a valid dummy variable name, so our tools like it better than having a meaningfule variable like loopVariable because, you know, namespace pollution. Of course it's also true as of Python 3.x that list comprehension temporaries do not leak outward, so ... really we can choose anything.

_ , in the interpreter, means "last result". Other than that , I don't think there's any special meaning....

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Style question. Is it preferable to use _ here? I thought _ was equivalent to "discard this result" and was a bit surprised to see it work.

now that I look at it though, [ letter for letter in string.ascii_lowercase ] might be more self-documenting - ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

_ is a valid dummy variable name, so our tools like it better than having a meaningfule variable like loopVariable because, you know, namespace pollution. Of course it's also true as of Python 3.x that list comprehension temporaries do not leak outward, so ... really we can choose anything.

_ , in the interpreter, means "last result". Other than that , I don't think there's any special meaning....

Learned a lot about how _ is treated and scoping behavior here. Thanks for the info!

Style question. Is it preferable to use _ here? I thought _ was equivalent to "discard this result" and was a bit surprised to see it work.

now that I look at it though, [ letter for letter in string.ascii_lowercase ] might be more self-documenting - ?

Definitely like self-documenting code. If you think it'll help future readers, I'd change _ to letter.

Comment thread irods/test/meta_test.py
Comment thread irods/test/meta_test.py Outdated
Comment thread irods/test/meta_test.py
# data.metadata(admin = True) generates a cloned object but for the one change to "admin".
data.metadata.admin = True

def test_iRODSMeta_builder__issue_835(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this test about exercising basic functionality of the new builder?

Comment thread irods/test/meta_test.py
Comment on lines +831 to +841
# Use both forms of the iRODSMeta builder invocation, testing that both attempts
# resulted in the AVU we expected. (For sets, s1 < s2 iff s1 is a proper subset of s2.)
data_obj.metadata['mile'] = iRODSMeta.builder(value=KM_PER_MILE, units='km')
data_obj.metadata['foot'] = iRODSMeta.builder(CM_PER_FOOT, 'cm')
self.assertLess(
{
iRODSMeta('mile', KM_PER_MILE, 'km'),
iRODSMeta('foot', CM_PER_FOOT, 'cm'),
},
set(data_obj.metadata.items())
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If I'm understanding correctly, set(data_obj.metadata.items()) will be the superset because it has more AVUs?

Comment thread README.md
With only one AVU on the object with a name of "key2", *get_one*
is assured of not throwing an exception:
Alternatively, in the indexed AVU assignment, the following construction can
be used in lieu of the direct call to the iRODSMeta constructor, thus avoiding redundant use of the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to determine if there's a pattern in how we style types and other important words. I suspect there are inconsistencies in the README.

Suggested change
be used in lieu of the direct call to the iRODSMeta constructor, thus avoiding redundant use of the
be used in lieu of the direct call to the `iRODSMeta` constructor, thus avoiding redundant use of the

We need to do a consistency sweep across the READMEs. That can happen in a separate PR.

Comment thread README.md
any other pre-existing AVUs with a name field of 'key2' before the requested assignment is
actually made.

Be aware that use of the indexing form on obj.metadata to retrieve AVUs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Be aware that use of the indexing form on obj.metadata to retrieve AVUs
Be aware that use of the indexing form on `obj.metadata` to retrieve AVUs

Comment thread README.md
Comment on lines +860 to +862
```
x = obj.metadata['key1']
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing python styling keyword on opening backticks.

Comment thread README.md
Comment on lines +849 to +851
```
>>> obj.metadata['key2'] = iRODSMeta.builder(value='value5', units='units2')
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing python styling keyword on opening backticks.

Comment thread README.md
```

In versions of iRODS 4.2.12 and later, we can also do:
In iRODS 4.2.12 and after, a rodsadmin can apply the ADMIN_KW

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
In iRODS 4.2.12 and after, a rodsadmin can apply the ADMIN_KW
In iRODS 4.2.12 and after, a rodsadmin can apply the `ADMIN_KW`

Comment thread README.md
actually made.

Be aware that use of the indexing form on obj.metadata to retrieve AVUs
with code such as

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add colon after "as"? Noticed other places in this diff had a colon.

Suggested change
with code such as
with code such as:

Comment thread README.md

For these reasons, the indexed assignment may be better considered an artifact of convenience
rather than reliable, straightforward coding practice. For clear and unambiguous intent, the
canonical iRODS API endpoints should be used, with calls such as

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add colon after "as"? Noticed other places in this diff had a colon.

Suggested change
canonical iRODS API endpoints should be used, with calls such as
canonical iRODS API endpoints should be used, with calls such as:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants