18 from typing
import Optional, TypeVar, Generic, List, Callable
19 from abc
import ABC, abstractmethod
20 from pathlib
import Path
22 from ..sample
import Sample
23 from ..utils
import isEntityNameValid
26 SampleType = TypeVar(
"SampleType", bound =
"Sample")
32 Represents the generic class Dataset
33 Includes methods that can be used by any instance of Dataset
34 and abstract methods that must be implemented by any subclass
40 samples : List[SampleType]
45 samples: List[SampleType]
52 int -> number of samples in this dataset
55 return len(self.samples)
59 def path(self) -> Path:
63 def download(self, decrypt: bool =
True, ignoreCache: bool =
False) ->
None:
68 Renames the dataset, if the provided name is
69 different from the current name
78 bool -> True if dataset was renamed, False if dataset was not renamed
81 if not isEntityNameValid(name):
82 raise ValueError(
">> [Coretex] Dataset name is invalid. Requirements: alphanumeric characters (\"a-z\", and \"0-9\") and dash (\"-\") with length between 3 to 50")
84 if self.
namename == name:
90 def getSample(self, name: str) -> Optional[SampleType]:
92 Retrieves sample which matches the provided name
101 Optional[SampleType] -> sample object
104 for sample
in self.samples:
108 if sample.name.startswith(name):
113 def getSamples(self, filterFunc: Callable[[SampleType], bool]) -> List[SampleType]:
114 filteredSamples: List[SampleType] = []
116 for sample
in self.samples:
117 if filterFunc(sample):
118 filteredSamples.append(sample)
120 return filteredSamples
Optional[SampleType] getSample(self, str name)
bool rename(self, str name)