Coretex
coretex.coretex.dataset.network_dataset.NetworkDataset Class Reference
Inheritance diagram for coretex.coretex.dataset.network_dataset.NetworkDataset:
coretex.coretex.dataset.dataset.Dataset coretex.coretex.dataset.custom_dataset.custom_dataset.CustomDataset coretex.coretex.dataset.image_dataset.image_dataset.ImageDataset coretex.coretex.dataset.image_segmentation_dataset.image_segmentation_dataset.ImageSegmentationDataset

Public Member Functions

Path path (self)
 
Optional[Self] createDataset (cls, str name, int spaceId, Optional[List[int]] sampleIds=None, Optional[Dict[str, Any]] meta=None)
 
None download (self, bool ignoreCache=False)
 
bool add (self, SampleType sample)
 
bool rename (self, str name)
 
- Public Member Functions inherited from coretex.coretex.dataset.dataset.Dataset
int count (self)
 
Optional[SampleType] getSample (self, str name)
 

Detailed Description

    Represents the base class for all Dataset classes which are
    comunicating with Coretex.ai

    Properties
    ----------
    createdOn : datetime
        creation date of dataset
    createdById : str
        id of created dataset id
    isLocked : bool
        availabilty of dataset for modifications

Definition at line 36 of file network_dataset.py.

Member Function Documentation

◆ add()

bool coretex.coretex.dataset.network_dataset.NetworkDataset.add (   self,
SampleType  sample 
)
    Adds the specified sample into the dataset

    Parameters
    ----------
    sample : SampleType
sample which should be added into the dataset

    Returns
    -------
    bool -> True if sample was added, False if sample was not added

Reimplemented from coretex.coretex.dataset.dataset.Dataset.

Definition at line 189 of file network_dataset.py.

189  def add(self, sample: SampleType) -> bool:
190  if self.isLocked or sample.isDeleted:
191  return False
192 
193  success = self.update({
194  "sessions": [sample.id]
195  })
196 
197  if success:
198  return super().add(sample)
199 
200  return success
201 

◆ createDataset()

Optional[Self] coretex.coretex.dataset.network_dataset.NetworkDataset.createDataset (   cls,
str  name,
int  spaceId,
Optional[List[int]]   sampleIds = None,
Optional[Dict[str, Any]]   meta = None 
)
    Creates a new dataset with the provided name, type
    and samples (if present, samples are not required)

    Parameters
    ----------
    name : str
dataset name
    spaceId : int
space for which the dataset will be created
    samplesIds : List[int]
samples which should be added to dataset (if present)

    Returns
    -------
    The created dataset object or None if creation failed

    Example
    -------
    >>> from coretex import NetworkDataset
    \b
    >>> dummyDataset = NetworkDataset.createDataset("dummyDataset", 123)
    >>> if dummyDataset is not None:
    print("Dataset created successfully")

Definition at line 107 of file network_dataset.py.

107  def createDataset(
108  cls,
109  name: str,
110  spaceId: int,
111  sampleIds: Optional[List[int]] = None,
112  meta: Optional[Dict[str, Any]] = None
113  ) -> Optional[Self]:
114 
115  """
116  Creates a new dataset with the provided name, type
117  and samples (if present, samples are not required)
118 
119  Parameters
120  ----------
121  name : str
122  dataset name
123  spaceId : int
124  space for which the dataset will be created
125  samplesIds : List[int]
126  samples which should be added to dataset (if present)
127 
128  Returns
129  -------
130  The created dataset object or None if creation failed
131 
132  Example
133  -------
134  >>> from coretex import NetworkDataset
135  \b
136  >>> dummyDataset = NetworkDataset.createDataset("dummyDataset", 123)
137  >>> if dummyDataset is not None:
138  print("Dataset created successfully")
139  """
140 
141  if sampleIds is None:
142  sampleIds = []
143 
144  return cls.create({
145  "name": name,
146  "project_id": spaceId,
147  "sessions": sampleIds,
148  "meta": meta
149  })
150 

◆ download()

None coretex.coretex.dataset.network_dataset.NetworkDataset.download (   self,
bool   ignoreCache = False 
)
    Downloads dataset from Coretex

    Parameters
    ----------
    ignoreCache : bool
if dataset is already downloaded and ignoreCache
is True it will be downloaded again (not required)

    Example
    -------
    >>> from coretex import NetworkDataset
    \b
    >>> dummyDataset = NetworkDataset.fetchById(1023)
    >>> dummyDataset.download()
    >> [Coretex] Downloading dataset: [==>...........................] - 10%

Reimplemented from coretex.coretex.dataset.dataset.Dataset.

Definition at line 151 of file network_dataset.py.

151  def download(self, ignoreCache: bool = False) -> None:
152  """
153  Downloads dataset from Coretex
154 
155  Parameters
156  ----------
157  ignoreCache : bool
158  if dataset is already downloaded and ignoreCache
159  is True it will be downloaded again (not required)
160 
161  Example
162  -------
163  >>> from coretex import NetworkDataset
164  \b
165  >>> dummyDataset = NetworkDataset.fetchById(1023)
166  >>> dummyDataset.download()
167  >> [Coretex] Downloading dataset: [==>...........................] - 10%
168  """
169 
170  self.path.mkdir(exist_ok = True)
171 
172  def sampleDownloader(sample: SampleType) -> None:
173  downloadSuccess = sample.download(ignoreCache)
174  if not downloadSuccess:
175  return
176 
177  symlinkPath = self.path / f"{sample.id}.zip"
178  if not symlinkPath.exists():
179  os.symlink(sample.zipPath, symlinkPath)
180 
181  processor = MultithreadedDataProcessor(
182  self.samples,
183  sampleDownloader,
184  title = "Downloading dataset"
185  )
186 
187  processor.process()
188 

◆ path()

Path coretex.coretex.dataset.network_dataset.NetworkDataset.path (   self)
    Retrieves path of dataset

    Returns
    -------
    Path -> path of dataset

Reimplemented from coretex.coretex.dataset.dataset.Dataset.

Definition at line 62 of file network_dataset.py.

62  def path(self) -> Path:
63  """
64  Retrieves path of dataset
65 
66  Returns
67  -------
68  Path -> path of dataset
69  """
70 
71  return FolderManager.instance().datasetsFolder / str(self.id)
72 

◆ rename()

bool coretex.coretex.dataset.network_dataset.NetworkDataset.rename (   self,
str  name 
)
    Renames the dataset, if the provided name is
    different from the current name

    Parameters
    ----------
    name : str
new dataset name

    Returns
    -------
    bool -> True if dataset was renamed, False if dataset was not renamed

Reimplemented from coretex.coretex.dataset.dataset.Dataset.

Definition at line 202 of file network_dataset.py.

202  def rename(self, name: str) -> bool:
203  success = self.update({
204  "name": name
205  })
206 
207  if success:
208  return super().rename(name)
209 
210  return success

The documentation for this class was generated from the following file: