Skip to content
Snippets Groups Projects

Allow uninstantiated class to get protocols

Merged Yannick DAYER requested to merge add-protocols into master
1 file
+ 10
2
Compare changes
  • Side-by-side
  • Inline
@@ -189,7 +189,7 @@ class CSVDatabase(FileListDatabase, Database):
@@ -189,7 +189,7 @@ class CSVDatabase(FileListDatabase, Database):
*,
*,
name: str,
name: str,
protocol: str,
protocol: str,
dataset_protocols_path: str,
dataset_protocols_path: Optional[str] = None,
transformer: Optional[sklearn.pipeline.Pipeline] = None,
transformer: Optional[sklearn.pipeline.Pipeline] = None,
annotation_type: Optional[str] = None,
annotation_type: Optional[str] = None,
fixed_positions: Optional[dict[str, tuple[float, float]]] = None,
fixed_positions: Optional[dict[str, tuple[float, float]]] = None,
@@ -266,11 +266,19 @@ class CSVDatabase(FileListDatabase, Database):
@@ -266,11 +266,19 @@ class CSVDatabase(FileListDatabase, Database):
files=False,
files=False,
)
)
def protocols(self):
def _instance_protocols(self) -> list[str]:
 
"""Same as ``protocols`` but for CSVDatabase instances."""
return list_dir(
return list_dir(
self.dataset_protocols_path, ".", folders=True, files=False
self.dataset_protocols_path, ".", folders=True, files=False
)
)
 
@classmethod
 
def protocols(cls) -> list[str]:
 
"""Returns the list of protocols without an instance of CSVDataset."""
 
return list_dir(
 
cls.retrieve_dataset_protocols(), ".", folders=True, files=False
 
)
 
# cached methods should be based on protocol as well
# cached methods should be based on protocol as well
@functools.lru_cache(maxsize=None)
@functools.lru_cache(maxsize=None)
def _background_model_samples(self, protocol):
def _background_model_samples(self, protocol):
Loading