Skip to content

Commit

Permalink
Merge branch 'main' of github.com:snakemake/snakemake-storage-plugin-gs
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoester committed Apr 26, 2024
2 parents 6ec568a + 0ebf52c commit 29cb9ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
poetry run python tests/test_fake_gcs.py
- name: Run pytest
run: poetry run coverage run -m pytest tests/tests.py
run: poetry run coverage run -m pytest -v tests/tests.py

- name: Run Coverage
run: poetry run coverage report -m
12 changes: 8 additions & 4 deletions snakemake_storage_plugin_gcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ def is_valid_query(cls, query: str) -> StorageQueryValidationResult:
valid=False,
reason=f"cannot be parsed as URL ({e})",
)
if parsed.scheme != "gs":
if parsed.scheme != "gcs":
return StorageQueryValidationResult(
query=query,
valid=False,
reason="must start with gs (gs://...)",
reason="must start with gcs scheme (gcs://...)",
)
return StorageQueryValidationResult(
query=query,
Expand All @@ -207,7 +207,7 @@ def example_queries(cls) -> List[ExampleQuery]:
"""
return [
ExampleQuery(
query="gs://mybucket/myfile.txt",
query="gcs://mybucket/myfile.txt",
type=QueryType.ANY,
description="A file in an google storage (GCS) bucket",
)
Expand Down Expand Up @@ -338,7 +338,11 @@ def get_mtime(blob):
return blob.updated.timestamp()

if self.is_directory():
return max(get_mtime(blob) for blob in self.directory_entries())
entries = list(self.directory_entries())
assert (
entries
), f"bug: mtime called but directory does not seem to exist: {self.query}"
return max(get_mtime(blob) for blob in entries)
else:
return get_mtime(self.blob)

Expand Down
5 changes: 3 additions & 2 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@

class TestStorage(TestStorageBase):
__test__ = True
files_only = False

def get_query(self, tmp_path) -> str:
return "gs://snakemake-test-bucket/test-file.txt"
return "gcs://snakemake-test-bucket/test-file.txt"

def get_query_not_existing(self, tmp_path) -> str:
bucket = uuid.uuid4().hex
key = uuid.uuid4().hex
return f"gs://{bucket}/{key}"
return f"gcs://{bucket}/{key}"

def get_storage_provider_cls(self) -> Type[StorageProviderBase]:
# Return the StorageProvider class of this plugin
Expand Down

0 comments on commit 29cb9ce

Please sign in to comment.