From 9c3767d6ee13a2c149a4ffe1c0547cabec0346dd Mon Sep 17 00:00:00 2001 From: ScottMastro Date: Mon, 16 May 2022 06:11:19 -0400 Subject: [PATCH] fix: iRODS functionality - issue #1510 (#1611) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: iRODS functionality - issue #1510 * fix: iRODS functionality - issue #1510 Co-authored-by: Johannes Köster * 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 --- snakemake/remote/iRODS.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/snakemake/remote/iRODS.py b/snakemake/remote/iRODS.py index 703c2a58e..3fb132dea 100644 --- a/snakemake/remote/iRODS.py +++ b/snakemake/remote/iRODS.py @@ -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)