File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed
snakemake_interface_storage_plugins Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,9 @@ class StorageProviderSettings(StorageProviderSettingsBase):
6868# This class can be empty as the one below.
6969# You can however use it to store global information or maintain e.g. a connection
7070# pool.
71+ # Inside of the provider, you can use self.logger (a normal Python logger of type
72+ # logging.Logger) to log any additional informations or
73+ # warnings.
7174class StorageProvider (StorageProviderBase ):
7275 # For compatibility with future changes, you should not overwrite the __init__
7376 # method. Instead, use __post_init__ to set additional attributes and initialize
@@ -129,6 +132,8 @@ class StorageProvider(StorageProviderBase):
129132# storage (e.g. because it is read-only see
130133# snakemake-storage-http for comparison), remove the corresponding base classes
131134# from the list of inherited items.
135+ # Inside of the object, you can use self.provider to access the provider (e.g. for )
136+ # self.provider.logger, see above, or self.provider.settings).
132137class StorageObject (
133138 StorageObjectRead ,
134139 StorageObjectWrite ,
Original file line number Diff line number Diff line change 88from dataclasses import dataclass
99from enum import Enum
1010from fractions import Fraction
11+ from logging import Logger
1112from pathlib import Path
1213import sys
1314from abc import ABC , abstractmethod
@@ -57,11 +58,13 @@ class StorageProviderBase(ABC):
5758 def __init__ (
5859 self ,
5960 local_prefix : Path ,
61+ logger : Logger ,
6062 settings : Optional [StorageProviderSettingsBase ] = None ,
6163 keep_local = False ,
6264 retrieve = True ,
6365 is_default = False ,
6466 ):
67+ self .logger : Logger = logger
6568 try :
6669 local_prefix .mkdir (parents = True , exist_ok = True )
6770 except OSError as e :
Original file line number Diff line number Diff line change 55
66from abc import ABC , abstractmethod
77import asyncio
8+ import logging
89from pathlib import Path
910import shutil
1011import sys
2021from snakemake .io import IOCache
2122
2223
24+ logger = logging .getLogger (__name__ )
25+
26+
2327class TestStorageBase (ABC ):
2428 __test__ = False
2529 retrieve_only = False
@@ -129,6 +133,7 @@ def test_query_validation(self, tmp_path):
129133
130134 def _get_provider (self , tmp_path ):
131135 return self .get_storage_provider_cls ()(
136+ logger = logger ,
132137 local_prefix = Path (tmp_path ) / "local_prefix" ,
133138 settings = self .get_storage_provider_settings (),
134139 )
You can’t perform that action at this time.
0 commit comments