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: implement touch #29

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions snakemake_storage_plugin_azure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from snakemake_interface_storage_plugins.storage_object import (
StorageObjectGlob,
StorageObjectRead,
StorageObjectTouch,
StorageObjectWrite,
retry_decorator,
)
Expand Down Expand Up @@ -199,7 +200,9 @@ def list_objects(self) -> Iterable[str]:
# storage (e.g. because it is read-only see
# snakemake-storage-http for comparison), remove the corresponding base classes
# from the list of inherited items.
class StorageObject(StorageObjectRead, StorageObjectWrite, StorageObjectGlob):
class StorageObject(
StorageObjectRead, StorageObjectWrite, StorageObjectGlob, StorageObjectTouch
):
# For compatibility with future changes, you should not overwrite the __init__
# method. Instead, use __post_init__ to set additional attributes and initialize
# further stuff.
Expand Down Expand Up @@ -356,7 +359,7 @@ def store_object(self):
# Ensure that the object is stored at the location
# specified by self.local_path().
if self.local_path().exists():
self.upload_blob_to_storage(self.local_path(), self.local_path())
self.upload_blob_to_storage(self.local_path(), self.blob_path)

def upload_blob_to_storage(self, local_path: Path = None, remote_path: Path = None):
"""Uploads the file at local_path to blob to storage location remote_path,
Expand Down Expand Up @@ -402,3 +405,9 @@ def list_candidate_matches(self) -> Iterable[str]:
"objects because bucket name contains a wildcard, which is not "
"supported."
)

# The following method is only required if the class inherits from
# StorageObjectTouch
# @retry_decorator
def touch(self):
...
1 change: 1 addition & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class TestStorageNoSettings(TestStorageBase):
store_only = False
delete = True
files_only = False
touch = True

def get_query_not_existing(self, tmp_path) -> str:
container = uuid.uuid4().hex
Expand Down
Loading