pyetp 0.0.33__tar.gz → 0.0.35__tar.gz

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.
@@ -1,13 +1,14 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pyetp
3
- Version: 0.0.33
3
+ Version: 0.0.35
4
4
  Summary: Interface with OSDU RDDMS using ETP protocol
5
5
  Author: Adam Cheng
6
6
  Author-email: 52572642+adamchengtkc@users.noreply.github.com
7
- Requires-Python: >=3.11,<3.13
7
+ Requires-Python: >=3.10,<3.13
8
8
  Classifier: Development Status :: 3 - Alpha
9
9
  Classifier: License :: OSI Approved :: Apache Software License
10
10
  Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
11
12
  Classifier: Programming Language :: Python :: 3.11
12
13
  Classifier: Programming Language :: Python :: 3.12
13
14
  Requires-Dist: async-lru (>=2.0.4,<3.0.0)
@@ -25,7 +25,7 @@ from pyetp.config import SETTINGS
25
25
  from pyetp.types import *
26
26
  from pyetp.uri import DataObjectURI, DataspaceURI
27
27
  from pyetp.utils import short_id, batched
28
- from asyncio import timeout
28
+ #from asyncio import timeout
29
29
 
30
30
  try:
31
31
  # for py >3.11, we can raise grouped exceptions
@@ -34,18 +34,18 @@ except ImportError:
34
34
  def ExceptionGroup(msg, errors):
35
35
  return errors[0]
36
36
 
37
- # try:
38
- # from asyncio import timeout
39
- # except ImportError:
40
- # import async_timeout
41
-
42
- # @asynccontextmanager
43
- # async def timeout(delay: T.Optional[float]) -> T.Any:
44
- # try:
45
- # async with async_timeout.timeout(delay):
46
- # yield None
47
- # except asyncio.CancelledError as e:
48
- # raise asyncio.TimeoutError(f'Timeout ({delay}s)') from e
37
+ try:
38
+ from asyncio import timeout
39
+ except ImportError:
40
+ import async_timeout
41
+ from contextlib import asynccontextmanager
42
+ @asynccontextmanager
43
+ async def timeout(delay: T.Optional[float]) -> T.Any:
44
+ try:
45
+ async with async_timeout.timeout(delay):
46
+ yield None
47
+ except asyncio.CancelledError as e:
48
+ raise asyncio.TimeoutError(f'Timeout ({delay}s)') from e
49
49
 
50
50
 
51
51
  logger = logging.getLogger(__name__)
@@ -96,7 +96,7 @@ class ETPClient(ETPConnection):
96
96
  self.timeout = timeout
97
97
  self.client_info.endpoint_capabilities['MaxWebSocketMessagePayloadSize'] = SETTINGS.MaxWebSocketMessagePayloadSize
98
98
  self.__recvtask = asyncio.create_task(self.__recv__())
99
- self.max_concurrent_requests = 1
99
+ self.max_concurrent_requests = SETTINGS.max_concurrent_requests
100
100
 
101
101
  #
102
102
  # client
@@ -229,8 +229,7 @@ class ETPClient(ETPConnection):
229
229
  currentDateTime=self.timestamp,
230
230
  earliestRetainedChangeTime=0,
231
231
  endpointCapabilities=dict(
232
- MaxWebSocketMessagePayloadSize=DataValue(item=self.max_size),
233
- MaxWebSocketFramePayloadSize=DataValue(item=10000)
232
+ MaxWebSocketMessagePayloadSize=DataValue(item=self.max_size)
234
233
  )
235
234
  )
236
235
  )
@@ -262,7 +261,8 @@ class ETPClient(ETPConnection):
262
261
 
263
262
  @property
264
263
  def max_size(self):
265
- return self.client_info.getCapability("MaxWebSocketMessagePayloadSize")
264
+ return SETTINGS.MaxWebSocketMessagePayloadSize
265
+ #return self.client_info.getCapability("MaxWebSocketMessagePayloadSize")
266
266
 
267
267
  @property
268
268
  def max_array_size(self):
@@ -502,11 +502,15 @@ class ETPClient(ETPConnection):
502
502
  )
503
503
  async def start_transaction(self, dataspace_uri: DataspaceURI, readOnly :bool= True) -> uuid.UUID:
504
504
  trans_id = await self.send(StartTransaction(readOnly=readOnly, dataspaceUris=[dataspace_uri.raw_uri]))
505
+ if trans_id.successful is False:
506
+ raise Exception(f"Failed starting transaction {dataspace_uri.raw_uri}")
505
507
  return uuid.UUID(bytes=trans_id.transaction_uuid)
506
508
 
507
509
  async def commit_transaction(self, transaction_id: uuid.UUID):
508
- trans_id = await self.send(CommitTransaction(transaction_uuid=transaction_id))
509
- return trans_id
510
+ r = await self.send(CommitTransaction(transaction_uuid=transaction_id))
511
+ if r.successful is False:
512
+ raise Exception(r.failure_reason)
513
+ return r
510
514
 
511
515
  async def rollback_transaction(self, transaction_id: uuid.UUID):
512
516
  return await self.send(RollbackTransaction(transactionUuid=transaction_id))
@@ -965,7 +969,6 @@ class ETPClient(ETPConnection):
965
969
 
966
970
  all_ranges = [range(s // block_size + 1) for s in shape]
967
971
  indexes = np.array(np.meshgrid(*all_ranges)).T.reshape(-1, len(shape))
968
-
969
972
  for ijk in indexes:
970
973
  starts = ijk * block_size
971
974
  if offset != 0:
@@ -988,7 +991,6 @@ class ETPClient(ETPConnection):
988
991
  buffer_shape = np.array([total_count], dtype=np.int64)
989
992
  else:
990
993
  buffer_shape = np.array(metadata.dimensions, dtype=np.int64)
991
-
992
994
  dtype = utils_arrays.get_dtype(metadata.transport_array_type)
993
995
  buffer = np.zeros(buffer_shape, dtype=dtype)
994
996
  params = []
@@ -1001,6 +1003,7 @@ class ETPClient(ETPConnection):
1001
1003
  buffer[slices] = array
1002
1004
  return
1003
1005
  coro = [populate(starts, counts) for starts, counts in self._get_chunk_sizes(buffer_shape, dtype, offset)]
1006
+ logger.debug(f"Concurrent request: {self.max_concurrent_requests}")
1004
1007
  for i in batched(coro, self.max_concurrent_requests):
1005
1008
  await asyncio.gather(*i)
1006
1009
  # r = await asyncio.gather(*[
@@ -1011,7 +1014,6 @@ class ETPClient(ETPConnection):
1011
1014
  return buffer
1012
1015
 
1013
1016
  async def _put_array_chuncked(self, uid: DataArrayIdentifier, data: np.ndarray):
1014
-
1015
1017
  transport_array_type = utils_arrays.get_transport(data.dtype)
1016
1018
  await self._put_uninitialized_data_array(uid, data.shape, transport_array_type=transport_array_type)
1017
1019
  params = []
@@ -1020,6 +1022,7 @@ class ETPClient(ETPConnection):
1020
1022
  params.append([starts, counts])
1021
1023
  #await self.put_subarray(uid, data, starts, counts)
1022
1024
  coro.append(self.put_subarray(uid, data, starts, counts))
1025
+ logger.debug(f"Concurrent request: {self.max_concurrent_requests}")
1023
1026
  for i in batched(coro, self.max_concurrent_requests):
1024
1027
  await asyncio.gather(*i)
1025
1028
  #r = await asyncio.gather(*coro)
@@ -23,7 +23,8 @@ class Settings(BaseSettings):
23
23
  etp_url: WebSocketUrl = Field(default='wss://host.com')
24
24
  etp_timeout: float = Field(default=15., description="Timeout in seconds")
25
25
  data_partition: Optional[str] = None
26
- MaxWebSocketMessagePayloadSize: int = Field(default=100000)
26
+ MaxWebSocketMessagePayloadSize: int = Field(default=30000)
27
+ max_concurrent_requests: int = Field(default = 5)
27
28
 
28
29
 
29
30
  SETTINGS = Settings()
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pyetp"
3
- version = "0.0.33"
3
+ version = "0.0.35"
4
4
  description = "Interface with OSDU RDDMS using ETP protocol"
5
5
  authors = ["Adam Cheng <52572642+adamchengtkc@users.noreply.github.com>"]
6
6
  readme = "README.md"
@@ -12,7 +12,7 @@ classifiers = [
12
12
 
13
13
 
14
14
  [tool.poetry.dependencies]
15
- python = ">=3.11, <3.13"
15
+ python = ">=3.10, <3.13"
16
16
  numpy = "^1.26.3"
17
17
  websockets = "^12.0"
18
18
  lxml = ">=4.9.4, <6.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes