Skip to content

Commit

Permalink
dbg
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoester committed Dec 7, 2023
1 parent e0d48a9 commit 4121f28
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions snakemake_storage_plugin_gcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
StorageProviderBase,
StorageQueryValidationResult,
ExampleQuery,
QueryType,
)

from snakemake.exceptions import WorkflowError, CheckSumMismatchException
Expand Down Expand Up @@ -209,6 +210,7 @@ def example_queries(cls) -> List[ExampleQuery]:
return [
ExampleQuery(
query="gcs://mybucket/myfile.txt",
type=QueryType.ANY,
description="A file in an google storage (GCS) bucket",
)
]
Expand Down Expand Up @@ -284,23 +286,24 @@ async def inventory(self, cache: IOCacheStorageInterface):
- cache.mtime
- cache.size
"""
if self.get_inventory_parent() in cache.exists_in_storage:
# bucket has been inventorized before, stop here
return

# check if bucket exists
if not self.bucket_exists():
cache.exists_in_storage[self.cache_key()] = False
cache.exists_in_storage[self.get_inventory_parent()] = False
else:
subfolder = os.path.dirname(self.blob.name)
for blob in self.client.list_blobs(self.bucket_name, prefix=subfolder):
# By way of being listed, it exists. mtime is a datetime object
key = self.cache_key(self._local_suffix_from_key(blob.name))
cache.exists_in_storage[key] = True
cache.mtime[key] = Mtime(remote=blob.updated.timestamp())
cache.size[key] = blob.size
# TODO cache "is directory" information
# TODO enable again later
# if self.get_inventory_parent() in cache.exists_in_storage:
# # bucket has been inventorized before, stop here
# return

# # check if bucket exists
# if not self.bucket_exists():
# cache.exists_in_storage[self.cache_key()] = False
# cache.exists_in_storage[self.get_inventory_parent()] = False
# else:
# subfolder = os.path.dirname(self.blob.name)
# for blob in self.client.list_blobs(self.bucket_name, prefix=subfolder):
# # By way of being listed, it exists. mtime is a datetime object
# key = self.cache_key(self._local_suffix_from_key(blob.name))
# cache.exists_in_storage[key] = True
# cache.mtime[key] = Mtime(remote=blob.updated.timestamp())
# cache.size[key] = blob.size
# # TODO cache "is directory" information

def get_inventory_parent(self) -> Optional[str]:
"""
Expand Down Expand Up @@ -487,7 +490,7 @@ def client(self):

@property
def blob(self):
return self.bucket.blob(self.key)
return self._blob

# Note from @vsoch - functions removed include:
# name
Expand Down

0 comments on commit 4121f28

Please sign in to comment.