logs-py 3.0.8__py3-none-any.whl → 3.0.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of logs-py might be problematic. Click here for more details.

LOGS/Entities/Dataset.py CHANGED
@@ -3,7 +3,7 @@ from dataclasses import dataclass
3
3
  from datetime import datetime
4
4
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Union, cast
5
5
 
6
- from deprecation import deprecated
6
+ from deprecation import deprecated # type: ignore
7
7
 
8
8
  from LOGS.Auxiliary.Constants import Constants
9
9
  from LOGS.Auxiliary.Decorators import Endpoint, UiEndpoint
@@ -140,6 +140,8 @@ class Dataset(
140
140
  connection: Optional[LOGSConnection] = None,
141
141
  files: Optional[Sequence[Constants.FILE_TYPE]] = None,
142
142
  format: Optional[Union[str, "FormatMinimal"]] = None,
143
+ pathPrefixToStrip: Optional[str] = None,
144
+ pathPrefixToAdd: Optional[str] = None,
143
145
  ):
144
146
  super().__init__(ref=ref, id=id, connection=connection)
145
147
 
@@ -169,6 +171,10 @@ class Dataset(
169
171
  )
170
172
 
171
173
  self._files = FileEntry.entriesFromFiles(files)
174
+ if self._files is not None:
175
+ for file in self._files:
176
+ if pathPrefixToStrip and file.path:
177
+ file.modifyPathPrefix(pathPrefixToStrip, pathPrefixToAdd)
172
178
 
173
179
  def fromDict(self, ref) -> None:
174
180
  if isinstance(ref, dict):
@@ -476,14 +482,6 @@ class Dataset(
476
482
  def dateAdded(self, value):
477
483
  self._dateAdded = self.checkAndConvertNullable(value, datetime, "dateAdded")
478
484
 
479
- @property
480
- def isDeleted(self) -> Optional[bool]:
481
- return self._isDeleted
482
-
483
- @isDeleted.setter
484
- def isDeleted(self, value):
485
- self._isDeleted = self.checkAndConvertNullable(value, bool, "isDeleted")
486
-
487
485
  @property
488
486
  def other(self) -> Optional[str]:
489
487
  return self._other
@@ -28,6 +28,8 @@ class FileEntry(SerializableClass):
28
28
  _typeMapper = {"fragments": FingerprintFragment}
29
29
  _noSerialize = ["isDir", "name"]
30
30
  id: Optional[str] = None
31
+ # The naming here is confusing. FullPath is part of the LOGS API but it refers
32
+ # to the full path in LOGS and not the actual file path.
31
33
  fullPath: str = ""
32
34
  path: str = ""
33
35
  isDir: bool = False
@@ -43,37 +45,42 @@ class FileEntry(SerializableClass):
43
45
  fullPath: Optional[str] = None,
44
46
  state: Optional[FormatFileState] = None,
45
47
  ):
46
- _path: str = ""
47
- if isinstance(ref, (str, os.DirEntry, FileEntry)):
48
- if isinstance(ref, FileEntry):
49
- _path = ref.path
50
- ref = ref.fullPath
51
- elif isinstance(ref, os.DirEntry) and ref.path:
52
- _path = ref.path
53
-
54
- _fullPath = os.path.realpath(ref)
55
- ref = {
56
- "id": uuid.uuid4().hex,
57
- "fullPath": _fullPath,
58
- "isDir": os.path.isdir(_fullPath),
59
- "name": os.path.basename(_fullPath),
60
- }
61
- super().__init__(ref)
48
+ if isinstance(ref, FileEntry):
49
+ super().__init__(self._fieldsFromPath(ref.path))
50
+ self.fullPath = ref.fullPath
51
+ self.state = ref.state
52
+ elif isinstance(ref, os.DirEntry) and ref.path:
53
+ super().__init__(self._fieldsFromPath(ref.path))
54
+ elif isinstance(ref, str) or fullPath is not None:
55
+ super().__init__(
56
+ self._fieldsFromPath(str(ref if fullPath is None else fullPath))
57
+ )
58
+
62
59
  if fullPath is not None:
63
60
  self.fullPath = fullPath
64
- self.path = _path
65
61
  if state is not None:
66
62
  self.state = state
67
63
 
64
+ @classmethod
65
+ def _fieldsFromPath(cls, path: str):
66
+ _path = os.path.realpath(path)
67
+ return {
68
+ "id": uuid.uuid4().hex,
69
+ "fullPath": _path,
70
+ "path": _path,
71
+ "isDir": os.path.isdir(_path),
72
+ "name": os.path.basename(_path),
73
+ }
74
+
68
75
  def __str__(self):
69
76
  return "<%s %s%a>" % (
70
77
  type(self).__name__,
71
78
  ("<dir> " if self.isDir else ""),
72
- self.fullPath,
79
+ self.path,
73
80
  )
74
81
 
75
82
  def addFragment(self, fragments: List[FingerprintFragment]):
76
- with open(self.fullPath, "rb") as read:
83
+ with open(self.path, "rb") as read:
77
84
  if self.fragments is None:
78
85
  self.fragments = []
79
86
  for fragment in fragments:
@@ -84,11 +91,11 @@ class FileEntry(SerializableClass):
84
91
  self.fragments.append(fragment)
85
92
 
86
93
  def addHash(self):
87
- with open(self.fullPath, "rb") as read:
94
+ with open(self.path, "rb") as read:
88
95
  self.hash = sha256(read.read()).hexdigest()
89
96
 
90
97
  def addMtime(self):
91
- self.mtime = datetime.fromtimestamp(os.path.getmtime(self.fullPath))
98
+ self.mtime = datetime.fromtimestamp(os.path.getmtime(self.path))
92
99
 
93
100
  @classmethod
94
101
  def entriesFromFiles(
@@ -108,16 +115,22 @@ class FileEntry(SerializableClass):
108
115
  if isinstance(file, (str, os.DirEntry, FileEntry)):
109
116
  f = FileEntry(file)
110
117
  if f.isDir:
111
- with os.scandir(f.fullPath) as entries:
118
+ with os.scandir(f.path) as entries:
112
119
  files.extend(entries)
113
120
  else:
114
- if not os.path.isfile(f.fullPath) or not os.access(
115
- f.fullPath, os.R_OK
116
- ):
121
+ if not os.path.isfile(f.path) or not os.access(f.path, os.R_OK):
117
122
  if not ignoreReadErrors:
118
- raise PermissionError("Could not read file %a" % f.fullPath)
123
+ raise PermissionError("Could not read file %a" % f.path)
119
124
  else:
120
- f.id = f.fullPath
125
+ f.id = uuid.uuid4().hex
121
126
  result.append(f)
122
127
 
123
128
  return result
129
+
130
+ def modifyPathPrefix(
131
+ self, prefixToStrip: Optional[str] = None, prefixToAdd: Optional[str] = None
132
+ ):
133
+ if prefixToStrip and self.fullPath.startswith(prefixToStrip):
134
+ self.fullPath = self.fullPath[len(prefixToStrip) :]
135
+ if prefixToAdd and not self.fullPath.startswith(prefixToAdd):
136
+ self.fullPath = os.path.join(prefixToAdd, self.fullPath)
@@ -38,7 +38,6 @@ class Inventory(
38
38
  _rootCustomType: Optional["InventoryMinimal"] = None
39
39
  _isRootItem: Optional[bool] = None
40
40
  _isHierarchyItem: Optional[bool] = None
41
- _isDeleted: Optional[bool] = None
42
41
  _ancestors: Optional[List["InventoryMinimal"]] = None
43
42
  _parent: Optional["InventoryMinimal"] = None
44
43
 
@@ -70,14 +69,6 @@ class Inventory(
70
69
  value, bool, "isHierarchyItem"
71
70
  )
72
71
 
73
- @property
74
- def isDeleted(self) -> Optional[bool]:
75
- return self._isDeleted
76
-
77
- @isDeleted.setter
78
- def isDeleted(self, value):
79
- self._isDeleted = self.checkAndConvertNullable(value, bool, "isDeleted")
80
-
81
72
  @property
82
73
  def ancestors(self) -> Optional[List["InventoryMinimal"]]:
83
74
  return self._ancestors
LOGS/Entity/Entity.py CHANGED
@@ -144,7 +144,7 @@ class Entity(ConnectedEntity):
144
144
  self._endpoint + [self.id], parameters={"deletePermanently": permanently}
145
145
  )
146
146
  if hasattr(self, "isDeleted"):
147
- self.isDeleted = True
147
+ setattr(self, "isDeleted", True)
148
148
 
149
149
  if permanently:
150
150
  self.connection = None
LOGS/LOGSConnection.py CHANGED
@@ -370,7 +370,7 @@ class LOGSConnection:
370
370
  content: Any = ""
371
371
  if isinstance(entry.content, FileEntry):
372
372
  # content = entry.content.toJson(compact=True)
373
- with open(entry.content.fullPath, "rb") as read:
373
+ with open(entry.content.path, "rb") as read:
374
374
  content = read.read()
375
375
  else:
376
376
  content = json.dumps(entry.content)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: logs-py
3
- Version: 3.0.8
3
+ Version: 3.0.9
4
4
  Summary: A python interface for the LOGS public API
5
5
  Home-page: https://docs.logs-python.com
6
6
  Author: Sina Kazemi
@@ -1,5 +1,5 @@
1
1
  LOGS/LOGS.py,sha256=c596CnYdNeyRcuuqHzoBjFaHspbtp8LatoqkQx6GDYY,44548
2
- LOGS/LOGSConnection.py,sha256=T8C9vTk4nyy0qJjs3Ee2_pkFyDPMoKapOGTUszP_htY,21581
2
+ LOGS/LOGSConnection.py,sha256=lsp0J4KvovJogDzBy89uc9KC4kT72_U3_rMJyFjnAAE,21577
3
3
  LOGS/LOGSOptions.py,sha256=eDymNMLvms_DcM_71poUxcn7FkUH5K-zSZw28gMsVzs,271
4
4
  LOGS/ServerMetaData.py,sha256=8D5jl3JVDT-1aV0P8mBddYORWwiRO-ohfKviIOvuA_Y,3358
5
5
  LOGS/__init__.py,sha256=zFHOekiFfVI2SnyMhBJCCofrKTn1gXXC-rUk8A9mRw4,260
@@ -53,7 +53,7 @@ LOGS/Entities/DataSourceRelations.py,sha256=eIszpHjZqz6v4WyhaPNu8efSzedsJLNrYR9b
53
53
  LOGS/Entities/DataSourceRequestParameter.py,sha256=zAfC61NvVt4XO3HhIy1PLViN3AEBJo7Q6Fa_EtyqNvA,1610
54
54
  LOGS/Entities/DataSourceStatus.py,sha256=LIMesU020i1clMiTxvO3hAoESf4B1-fXsDGMMtWLdsM,427
55
55
  LOGS/Entities/DataSources.py,sha256=UU5ey98_vX4WQknyWITMy-dPOV-wgjblXxu5uXpnVso,481
56
- LOGS/Entities/Dataset.py,sha256=VTelbPwxSpLsX6Fu4-4flBFClKtEjLXfiVDC-8uwU-Q,27417
56
+ LOGS/Entities/Dataset.py,sha256=qKIEGuIaBy5SFSzUAckBFk5ACm7xxsl8nVcu9gydQhk,27523
57
57
  LOGS/Entities/DatasetCreator.py,sha256=GJ2e0pcYt5ziVqREViBM_uq45K3rm3FG_3NqIOjrO3Y,3253
58
58
  LOGS/Entities/DatasetInfo.py,sha256=GVs9dxE2ufMfiuhgKXDcN-GEi2VrZPM1TMBLwtsfMU0,4972
59
59
  LOGS/Entities/DatasetMatchTypes.py,sha256=6C60F0GcioNyfRWIIh2XGQJokZxFdBZY9UpKv1y3M7w,4363
@@ -80,7 +80,7 @@ LOGS/Entities/ExperimentMinimal.py,sha256=45NzqBQNwxC96qlEyf8ESLk76ATHem6F765m9s
80
80
  LOGS/Entities/ExperimentRelations.py,sha256=NgHv9xbOrsqi7JkExB34-zXsBh5UtZHVv_uheTt-tns,658
81
81
  LOGS/Entities/ExperimentRequestParameter.py,sha256=qz0a1JejJ0cAr-oSJVKQGnYSKinQABwdqCFjNQsP9VQ,1248
82
82
  LOGS/Entities/Experiments.py,sha256=U9O4JaKpOTui2vWEZ9WeOPHXkI-GMO__vFFYqB5t7Ws,453
83
- LOGS/Entities/FileEntry.py,sha256=GMg0ABi9Ltdl_jor-1tvMNrP_pjT0tBJdR7KhfqiYlQ,3914
83
+ LOGS/Entities/FileEntry.py,sha256=iJtf_ByBwiCyd5ETXoMOcQG0oTbKviiE2dUwZCJNS74,4556
84
84
  LOGS/Entities/FileExcludePattern.py,sha256=LhJfgiKrdTwYhXWBrb0PBMUh4H9vO1dFLFGC2gfHlz8,201
85
85
  LOGS/Entities/Format.py,sha256=yH4k1wLyhq09oD0N1SATJN-M4xbAZJLwQV8rMlXYWCA,2377
86
86
  LOGS/Entities/FormatFormat.py,sha256=H7uTmPyDZZjAf5IPjx4sTt40rLnigxE-CmWH9n4klFo,1416
@@ -114,7 +114,7 @@ LOGS/Entities/InstrumentRelations.py,sha256=sXlLo_TQiRnkWAOkAAYlYxqquas9KBVEJVW6
114
114
  LOGS/Entities/InstrumentRequestParameter.py,sha256=mDPAtXMHVLaYiGnXSUVXGzitG6xFMr75FzCOLD5sUME,1433
115
115
  LOGS/Entities/Instruments.py,sha256=0KgCWU5J9nFOM9qQw5s6tRyAdnCzOnjuvAtSwpdbyiU,453
116
116
  LOGS/Entities/Inventories.py,sha256=0MluOe-xuNVRqLh6sayaHXM2LMUc43RV7D5b5QOd5Zg,450
117
- LOGS/Entities/Inventory.py,sha256=Bwf8iqrICieD4t3DM91F17g0nDmHwK4UfkA-1UHuF88,3105
117
+ LOGS/Entities/Inventory.py,sha256=9CWMJChz06KlCgCr2lX-ajMiX0tzCXP--eSMflblIDc,2842
118
118
  LOGS/Entities/InventoryMinimal.py,sha256=yunVsM9OiayIHjdwGHM2UxdgaK7fLj2l8Pdurb6zVxI,594
119
119
  LOGS/Entities/InventoryRelations.py,sha256=IFlkthKdUcKwFCVz4nxASwtOpog56p2zqoRqjJQZwIE,661
120
120
  LOGS/Entities/InventoryRequestParameter.py,sha256=xIL5kGc4mtoVqtsWHDf_IESn_ELMMH9124jq3uGUzTw,1949
@@ -214,7 +214,7 @@ LOGS/Entities/LabNotebookEntryContent/TextMarkConverter.py,sha256=esycxCZBj9-KaP
214
214
  LOGS/Entities/LabNotebookEntryContent/TextMarks.py,sha256=CQTyP7xtSTC0__kq9hgdEul2D2XxCoro9koYxnX3HSM,1998
215
215
  LOGS/Entities/LabNotebookEntryContent/__init__.py,sha256=VIL4R44IXUOPOADapm1QilZ1uC0g6roAqlOYKAQkLHU,1092
216
216
  LOGS/Entity/ConnectedEntity.py,sha256=O3YOGaHArWnk9LPpFIfHBm01PscX7MN5yY3gWpVihRQ,2802
217
- LOGS/Entity/Entity.py,sha256=WLCtVjRxyRg6nX8UzEMjKJ4MkLICrMmXSo5xrtRHaUE,6300
217
+ LOGS/Entity/Entity.py,sha256=Dx_s0UF0I9gI8HD80ZMeY32mWQkF_1kfdwNGqczNNTU,6311
218
218
  LOGS/Entity/EntityConnector.py,sha256=936-3WpUB087u7YxpzR8T3V3HX4RITsOlp5fZWmc8k0,2106
219
219
  LOGS/Entity/EntityIterator.py,sha256=EF29TdSvC0rTMMnQgCe5X99mYAYNjZydtLaQc3n7-6k,8165
220
220
  LOGS/Entity/EntityMinimal.py,sha256=GysThwk8YbT8xqbHvJqmYKgPf8ckALO5pG-J_SNT0vw,3237
@@ -254,7 +254,7 @@ LOGS/Parameters/ParameterElement.py,sha256=fr6AlO_flKRygZZFx1OILP4P-2lV2Tx4PAe6W
254
254
  LOGS/Parameters/ParameterList.py,sha256=ijukB1__iKI5cefmOIIWz0wKaPz9Cx8KpD7Y7Gz2Pn0,1478
255
255
  LOGS/Parameters/ParameterTable.py,sha256=7Lew4DPgWmKcpV1T-1Pvt00kEI05FB383QqO-LHAjds,1758
256
256
  LOGS/Parameters/__init__.py,sha256=KpMSuBPx964v2YMZ1BqVp8vjrgSpuiW9KYBm-aejRuc,312
257
- logs_py-3.0.8.dist-info/METADATA,sha256=2ddIR966EkrF9IwiimrJebOpNfYcK_bs3MPGR3MoRo4,2339
258
- logs_py-3.0.8.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
259
- logs_py-3.0.8.dist-info/top_level.txt,sha256=Ckn2LiAmGaR7k3tdEnKAc04z_uboMD4gLreYghRNdCs,5
260
- logs_py-3.0.8.dist-info/RECORD,,
257
+ logs_py-3.0.9.dist-info/METADATA,sha256=C-jyeUN24wtHKYyrBuoJUlF7sNZWRA7_U4iXpu65vKQ,2339
258
+ logs_py-3.0.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
259
+ logs_py-3.0.9.dist-info/top_level.txt,sha256=Ckn2LiAmGaR7k3tdEnKAc04z_uboMD4gLreYghRNdCs,5
260
+ logs_py-3.0.9.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5