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

fix: iRODS functionality - issue #1510 #1611

Merged
merged 5 commits into from May 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 19 additions & 7 deletions snakemake/remote/iRODS.py
Expand Up @@ -24,7 +24,7 @@
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(
Expand Down Expand Up @@ -90,6 +90,9 @@ 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."""
Expand Down Expand Up @@ -194,21 +197,30 @@ def _download(self, make_dest_dirs=True):
"The file does not seem to exist remotely: %s" % self.local_file()
)

def denied_access(self, collpath):
try:
self._irods_session.collections.get(collpath)
return False
except(CAT_NO_ACCESS_PERMISSION):
return True
return False

def _upload(self):
# get current local timestamp
stat = os.stat(self.local_path)

# create folder structure on remote
folders = os.path.dirname(self.remote_path).split(os.sep)[1:]
collpath = os.sep
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)
except:
self._irods_session.collections.create(collpath)
print(collpath)
ScottMastro marked this conversation as resolved.
Show resolved Hide resolved
if not self.denied_access(collpath):
try:
self._irods_session.collections.get(collpath)
except:
self._irods_session.collections.create(collpath)

# upload file and store local timestamp in metadata since irods sets the files modification time to
# the upload time rather than retaining the local modification time
Expand Down