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

Atomic operations failing with certain paths #13

Open
montesmariana opened this issue Feb 6, 2025 · 0 comments
Open

Atomic operations failing with certain paths #13

montesmariana opened this issue Feb 6, 2025 · 0 comments

Comments

@montesmariana
Copy link
Collaborator

Certain operations - in particular atomic operations on metadata - fail on data objects or collections where the path contains an apostrophe followed by and. This is a known issue that should be fixed on the PRC side, I understand.

In the meantime, we could patch this with a try-except that uses individual adding and removal when atomic operations fail, just in case. The patch would look something like this:

  1. A function to mimic the atomic operations, taken from mango-portal utils
def mimic_atomic_operations(
  catalog_item: iRODSDataObject \| iRODSCollection, avu_operations
  ):
  for avu_operation in avu_operations:
    if avu_operation.operation == "remove":
      catalog_item.metadata.remove(avu_operation.avu)
    if avu_operation.operation == "add":
      catalog_item.metadata.add(avu_operation.avu)
  1. A try except on each part that calls the atomic operations

a. Where old metadata is removed:

try:
    item.metadata.apply_atomic_operations(
      *[AVUOperation(operation="remove", avu=x) for x in existing_avus]
    )
except:
    mimic_atomic_operations(item, [AVUOperation(operation="remove", avu=x) for x in existing_avus])

b. Where the metadata is added:

try:
    item.metadata.apply_atomic_operations(
       *[AVUOperation(operation="add", avu=x) for x in avus]
      )
except:
    mimic_atomic_operations(item, [AVUOperation(operation="add", avu=x) for x in avus])

This can be made more compact and should be tested, but it is a valid patch.

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

No branches or pull requests

1 participant