Coretex
local_sample.py
1 # Copyright (C) 2023 Coretex LLC
2 
3 # This file is part of Coretex.ai
4 
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as
7 # published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
9 
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Affero General Public License for more details.
14 
15 # You should have received a copy of the GNU Affero General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 
18 from typing import TypeVar, Generic, Final
19 from pathlib import Path
20 
21 import logging
22 
23 from .sample import Sample
24 
25 
26 SampleDataType = TypeVar("SampleDataType")
27 
28 
29 class LocalSample(Generic[SampleDataType], Sample[SampleDataType]):
30 
31  """
32  Represents a local sample object\n
33  The purpose of this class is to provide a way to work with
34  data samples that are stored locally
35 
36  Properties
37  ----------
38  name
39  name of sample retrieved from path
40  path : Path
41  path to local sample
42  """
43 
44  def __init__(self, path: Path) -> None:
45  super().__init__()
46 
47  self.name: Final = path.stem
48  self._path: Final = path
49 
50  @property
51  def path(self) -> Path:
52  """
53  Returns
54  -------
55  Path -> path for local sample
56  """
57 
58  return self._path.parent / self._path.stem
59 
60  @property
61  def zipPath(self) -> Path:
62  """
63  Returns
64  -------
65  Path -> zip path for local sample
66  """
67 
68  return self._path
69 
70  def download(self, decrypt: bool = True, ignoreCache: bool = False) -> None:
71  logging.getLogger("coretexpylib").warning(">> [Coretex] Local sample cannot be downloaded")
72 
73  def load(self) -> SampleDataType:
74  return super().load() # type: ignore
None download(self, bool decrypt=True, bool ignoreCache=False)
Definition: local_sample.py:70