Skip to content

Commit

Permalink
feat: add touch support (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoester authored Feb 19, 2024
1 parent 9ac5c8d commit 7ed5a6a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ keywords = ["snakemake", "plugin", "storage", "filesystem", "rsync"]

[tool.poetry.dependencies]
python = "^3.11"
snakemake-interface-common = "^1.14.2"
snakemake-interface-storage-plugins = "^3.0.0"
snakemake-interface-common = "^1.17.0"
snakemake-interface-storage-plugins = "^3.1.0"
sysrsync = "^1.1.1"
reretry = "^0.11.8"

Expand Down
18 changes: 17 additions & 1 deletion snakemake_storage_plugin_fs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
StorageObjectRead,
StorageObjectWrite,
StorageObjectGlob,
StorageObjectTouch,
)
from snakemake_interface_storage_plugins.io import (
IOCacheStorageInterface,
get_constant_prefix,
Mtime,
)
from snakemake_interface_storage_plugins.settings import StorageProviderSettingsBase
from snakemake_interface_common.utils import lutime


@dataclass
Expand Down Expand Up @@ -137,7 +139,9 @@ def wrapper(self, *args, **kwargs):
# 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
# futher stuff.
Expand Down Expand Up @@ -262,3 +266,15 @@ def _stat(self, follow_symlinks: bool = True):
# We don't want the cached variant (Path.stat), as we cache ourselves in
# inventory and afterwards the information may change.
return os.stat(self.query_path, follow_symlinks=follow_symlinks)

def touch(self):
if self.query_path.exists():
if self.query_path.is_dir():
flag = self.query_path / ".snakemake_timestamp"
# Create the flag file if it doesn't exist
if not flag.exists():
with open(flag, "w"):
pass
lutime(flag, None)
else:
lutime(str(self.query_path), None)
1 change: 1 addition & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class TestStorageNoSettings(TestStorageBase):
__test__ = True
retrieve_only = False
touch = True

def get_query(self, tmp_path) -> str:
parent = f"{tmp_path}/storage/test/"
Expand Down

0 comments on commit 7ed5a6a

Please sign in to comment.