Skip to content
Permalink
Browse files
fix: iRODS functionality - issue #1510 (#1611)
* fix: iRODS functionality - issue #1510

* fix: iRODS functionality - issue #1510

Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>

* fmt with black

* iRODS correctly handles subdirectories  

allows iRODS _upload function to either create (if missing) or ignore (if user has no access) a subdirectory

Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
  • Loading branch information
ScottMastro and johanneskoester committed May 16, 2022
1 parent 76f69d9 commit 9c3767d6ee13a2c149a4ffe1c0547cabec0346dd
Showing 1 changed file with 14 additions and 3 deletions.
@@ -24,7 +24,11 @@
from irods.session import iRODSSession
from irods.meta import iRODSMeta
from irods.models import DataObject
from irods.exception import CollectionDoesNotExist, DataObjectDoesNotExist
from irods.exception import (
CollectionDoesNotExist,
DataObjectDoesNotExist,
CAT_NO_ACCESS_PERMISSION,
)
import irods.keywords as kw
except ImportError as e:
raise WorkflowError(
@@ -90,6 +94,10 @@ def available_protocols(self):
"""List of valid protocols for this remote provider."""
return ["irods://"]

def glob_wildcards(self, pattern, *args, **kwargs):
remote_pattern = os.path.join(os.sep, self._irods_session.zone, pattern)
return super().glob_wildcards(remote_pattern, *args, **kwargs)


class RemoteObject(AbstractRemoteRetryObject):
"""This is a class to interact with an iRODS server."""
@@ -200,13 +208,16 @@ def _upload(self):

# create folder structure on remote
folders = os.path.dirname(self.remote_path).split(os.sep)[1:]
collpath = os.sep
# add zone name to path
collpath = os.sep + folders.pop(0) + os.sep + folders.pop(0)

for folder in folders:
collpath = os.path.join(collpath, folder)

try:
self._irods_session.collections.get(collpath)
# ignore subdirectories where user does not have access
except (CAT_NO_ACCESS_PERMISSION):
pass
except:
self._irods_session.collections.create(collpath)

0 comments on commit 9c3767d

Please sign in to comment.