pyetp 0.0.36__py3-none-any.whl → 0.0.38__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.
- pyetp/client.py +42 -32
- pyetp/config.py +1 -2
- pyetp/types.py +1 -0
- {pyetp-0.0.36.dist-info → pyetp-0.0.38.dist-info}/METADATA +2 -2
- {pyetp-0.0.36.dist-info → pyetp-0.0.38.dist-info}/RECORD +7 -7
- {pyetp-0.0.36.dist-info → pyetp-0.0.38.dist-info}/LICENSE.md +0 -0
- {pyetp-0.0.36.dist-info → pyetp-0.0.38.dist-info}/WHEEL +0 -0
pyetp/client.py
CHANGED
|
@@ -96,7 +96,6 @@ 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 = SETTINGS.max_concurrent_requests
|
|
100
99
|
|
|
101
100
|
#
|
|
102
101
|
# client
|
|
@@ -502,34 +501,36 @@ class ETPClient(ETPConnection):
|
|
|
502
501
|
rotation=rotation,
|
|
503
502
|
masked=True
|
|
504
503
|
)
|
|
505
|
-
async def start_transaction(self, dataspace_uri: DataspaceURI, readOnly :bool= True) ->
|
|
504
|
+
async def start_transaction(self, dataspace_uri: DataspaceURI, readOnly :bool= True) -> Uuid:
|
|
506
505
|
trans_id = await self.send(StartTransaction(readOnly=readOnly, dataspaceUris=[dataspace_uri.raw_uri]))
|
|
507
506
|
if trans_id.successful is False:
|
|
508
507
|
raise Exception(f"Failed starting transaction {dataspace_uri.raw_uri}")
|
|
509
|
-
return uuid.UUID(bytes=trans_id.transaction_uuid)
|
|
508
|
+
return Uuid(trans_id.transaction_uuid) #uuid.UUID(bytes=trans_id.transaction_uuid)
|
|
510
509
|
|
|
511
|
-
async def commit_transaction(self, transaction_id:
|
|
512
|
-
r = await self.send(CommitTransaction(
|
|
510
|
+
async def commit_transaction(self, transaction_id: Uuid):
|
|
511
|
+
r = await self.send(CommitTransaction(transactionUuid=transaction_id))
|
|
513
512
|
if r.successful is False:
|
|
514
513
|
raise Exception(r.failure_reason)
|
|
515
514
|
return r
|
|
516
515
|
|
|
517
|
-
async def rollback_transaction(self, transaction_id:
|
|
516
|
+
async def rollback_transaction(self, transaction_id: Uuid):
|
|
518
517
|
return await self.send(RollbackTransaction(transactionUuid=transaction_id))
|
|
519
518
|
|
|
520
519
|
async def put_xtgeo_surface(self, surface: RegularSurface, epsg_code: int, dataspace_uri: DataspaceURI):
|
|
521
520
|
"""Returns (epc_uri, crs_uri, gri_uri)"""
|
|
522
521
|
assert surface.values is not None, "cannot upload empty surface"
|
|
523
522
|
|
|
524
|
-
|
|
523
|
+
t_id = await self.start_transaction(dataspace_uri, False)
|
|
525
524
|
epc, crs, gri = utils_xml.parse_xtgeo_surface_to_resqml_grid(surface, epsg_code)
|
|
526
525
|
epc_uri, crs_uri, gri_uri = await self.put_resqml_objects(epc, crs, gri, dataspace_uri=dataspace_uri)
|
|
527
|
-
|
|
526
|
+
|
|
527
|
+
await self.put_array(
|
|
528
528
|
DataArrayIdentifier(
|
|
529
529
|
uri=epc_uri.raw_uri if isinstance(epc_uri, DataObjectURI) else epc_uri,
|
|
530
530
|
pathInResource=gri.grid2d_patch.geometry.points.zvalues.values.path_in_hdf_file # type: ignore
|
|
531
531
|
),
|
|
532
|
-
surface.values.filled(np.nan).astype(np.float32)
|
|
532
|
+
surface.values.filled(np.nan).astype(np.float32),
|
|
533
|
+
t_id
|
|
533
534
|
)
|
|
534
535
|
|
|
535
536
|
return epc_uri, gri_uri, crs_uri
|
|
@@ -693,6 +694,7 @@ class ETPClient(ETPConnection):
|
|
|
693
694
|
assert len(cprop0.patch_of_values) == 1, "property obj must have exactly one patch of values"
|
|
694
695
|
|
|
695
696
|
st = time.time()
|
|
697
|
+
t_id = await self.start_transaction(dataspace_uri, False)
|
|
696
698
|
propkind_uri = [""] if (propertykind0 is None) else (await self.put_resqml_objects(propertykind0, dataspace_uri=dataspace_uri))
|
|
697
699
|
cprop_uri = await self.put_resqml_objects(cprop0, dataspace_uri=dataspace_uri)
|
|
698
700
|
delay = time.time() - st
|
|
@@ -705,6 +707,7 @@ class ETPClient(ETPConnection):
|
|
|
705
707
|
pathInResource=cprop0.patch_of_values[0].values.values.path_in_hdf_file,
|
|
706
708
|
),
|
|
707
709
|
array_ref, # type: ignore
|
|
710
|
+
t_id
|
|
708
711
|
)
|
|
709
712
|
delay = time.time() - st
|
|
710
713
|
logger.debug(f"pyetp: put_rddms_property: put array ({array_ref.shape}) took {delay} s")
|
|
@@ -715,6 +718,7 @@ class ETPClient(ETPConnection):
|
|
|
715
718
|
dataspace_uri: DataspaceURI
|
|
716
719
|
):
|
|
717
720
|
uns, crs, epc, timeseries, hexa = utils_xml.convert_epc_mesh_to_resqml_mesh(epc_filename, title_in, projected_epsg)
|
|
721
|
+
t_id = await self.start_transaction(dataspace_uri, False)
|
|
718
722
|
epc_uri, crs_uri, uns_uri = await self.put_resqml_objects(epc, crs, uns, dataspace_uri=dataspace_uri)
|
|
719
723
|
timeseries_uri = ""
|
|
720
724
|
if timeseries is not None:
|
|
@@ -771,7 +775,7 @@ class ETPClient(ETPConnection):
|
|
|
771
775
|
),
|
|
772
776
|
hexa.cell_face_is_right_handed # type: ignore
|
|
773
777
|
)
|
|
774
|
-
|
|
778
|
+
await self.commit_transaction(t_id)
|
|
775
779
|
#
|
|
776
780
|
# mesh properties: one Property, one array of values, and an optional PropertyKind per property
|
|
777
781
|
#
|
|
@@ -891,21 +895,25 @@ class ETPClient(ETPConnection):
|
|
|
891
895
|
arrays = list(response.data_arrays.values())
|
|
892
896
|
return utils_arrays.to_numpy(arrays[0])
|
|
893
897
|
|
|
894
|
-
async def put_array(self, uid: DataArrayIdentifier, data: np.ndarray):
|
|
898
|
+
async def put_array(self, uid: DataArrayIdentifier, data: np.ndarray, transaction_id: Uuid | None = None):
|
|
895
899
|
|
|
896
900
|
|
|
897
901
|
# Check if we can upload the full array in one go.
|
|
898
902
|
if data.nbytes > self.max_array_size:
|
|
899
|
-
return await self._put_array_chuncked(uid, data)
|
|
900
|
-
|
|
903
|
+
return await self._put_array_chuncked(uid, data, transaction_id)
|
|
904
|
+
|
|
901
905
|
response = await self.send(
|
|
902
906
|
PutDataArrays(
|
|
903
907
|
dataArrays={uid.path_in_resource: PutDataArraysType(uid=uid, array=utils_arrays.to_data_array(data))})
|
|
904
908
|
)
|
|
909
|
+
|
|
905
910
|
assert isinstance(response, PutDataArraysResponse), "Expected PutDataArraysResponse"
|
|
906
911
|
assert len(response.success) == 1, "expected one success from put_array"
|
|
912
|
+
if isinstance(transaction_id, Uuid):
|
|
913
|
+
await self.commit_transaction(transaction_id)
|
|
907
914
|
return response.success
|
|
908
915
|
|
|
916
|
+
|
|
909
917
|
async def get_subarray(self, uid: DataArrayIdentifier, starts: T.Union[np.ndarray, T.List[int]], counts: T.Union[np.ndarray, T.List[int]]):
|
|
910
918
|
starts = np.array(starts).astype(np.int64)
|
|
911
919
|
counts = np.array(counts).astype(np.int64)
|
|
@@ -1004,31 +1012,33 @@ class ETPClient(ETPConnection):
|
|
|
1004
1012
|
slices = tuple(map(lambda se: slice(se[0], se[1]), zip(starts-offset, ends-offset)))
|
|
1005
1013
|
buffer[slices] = array
|
|
1006
1014
|
return
|
|
1007
|
-
coro = [populate(starts, counts) for starts, counts in self._get_chunk_sizes(buffer_shape, dtype, offset)]
|
|
1008
|
-
logger.debug(f"Concurrent request: {self.max_concurrent_requests}")
|
|
1009
|
-
for i in batched(coro, self.max_concurrent_requests):
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
+
# coro = [populate(starts, counts) for starts, counts in self._get_chunk_sizes(buffer_shape, dtype, offset)]
|
|
1016
|
+
# logger.debug(f"Concurrent request: {self.max_concurrent_requests}")
|
|
1017
|
+
# for i in batched(coro, self.max_concurrent_requests):
|
|
1018
|
+
# await asyncio.gather(*i)
|
|
1019
|
+
r = await asyncio.gather(*[
|
|
1020
|
+
populate(starts, counts)
|
|
1021
|
+
for starts, counts in self._get_chunk_sizes(buffer_shape, dtype, offset)
|
|
1022
|
+
])
|
|
1015
1023
|
|
|
1016
1024
|
return buffer
|
|
1017
1025
|
|
|
1018
|
-
async def _put_array_chuncked(self, uid: DataArrayIdentifier, data: np.ndarray):
|
|
1026
|
+
async def _put_array_chuncked(self, uid: DataArrayIdentifier, data: np.ndarray, transaction_id: Uuid | None = None):
|
|
1019
1027
|
transport_array_type = utils_arrays.get_transport(data.dtype)
|
|
1028
|
+
|
|
1020
1029
|
await self._put_uninitialized_data_array(uid, data.shape, transport_array_type=transport_array_type)
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
for starts, counts in self._get_chunk_sizes(data.shape, data.dtype):
|
|
1024
|
-
params.append([starts, counts])
|
|
1025
|
-
#await self.put_subarray(uid, data, starts, counts)
|
|
1026
|
-
coro.append(self.put_subarray(uid, data, starts, counts))
|
|
1027
|
-
logger.debug(f"Concurrent request: {self.max_concurrent_requests}")
|
|
1028
|
-
for i in batched(coro, self.max_concurrent_requests):
|
|
1029
|
-
await asyncio.gather(*i)
|
|
1030
|
-
#r = await asyncio.gather(*coro)
|
|
1030
|
+
if isinstance(transaction_id, Uuid):
|
|
1031
|
+
await self.commit_transaction(transaction_id)
|
|
1031
1032
|
|
|
1033
|
+
ds_uri = DataspaceURI.from_any(uid.uri)
|
|
1034
|
+
t_id = None
|
|
1035
|
+
if isinstance(transaction_id, Uuid):
|
|
1036
|
+
t_id = await self.start_transaction(ds_uri, False)
|
|
1037
|
+
for starts, counts in self._get_chunk_sizes(data.shape, data.dtype):
|
|
1038
|
+
await self.put_subarray(uid, data, starts, counts)
|
|
1039
|
+
if isinstance(t_id, Uuid):
|
|
1040
|
+
await self.commit_transaction(t_id)
|
|
1041
|
+
|
|
1032
1042
|
return {uid.uri: ''}
|
|
1033
1043
|
|
|
1034
1044
|
async def _put_uninitialized_data_array(self, uid: DataArrayIdentifier, shape: T.Tuple[int, ...], transport_array_type=AnyArrayType.ARRAY_OF_FLOAT, logical_array_type=AnyLogicalArrayType.ARRAY_OF_BOOLEAN):
|
pyetp/config.py
CHANGED
|
@@ -23,8 +23,7 @@ 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=
|
|
27
|
-
max_concurrent_requests: int = Field(default = 5)
|
|
26
|
+
MaxWebSocketMessagePayloadSize: int = Field(default=500000000)
|
|
28
27
|
|
|
29
28
|
|
|
30
29
|
SETTINGS = Settings()
|
pyetp/types.py
CHANGED
|
@@ -25,6 +25,7 @@ from etptypes.energistics.etp.v12.datatypes.object.data_object import \
|
|
|
25
25
|
from etptypes.energistics.etp.v12.datatypes.object.dataspace import Dataspace
|
|
26
26
|
from etptypes.energistics.etp.v12.datatypes.server_capabilities import \
|
|
27
27
|
ServerCapabilities
|
|
28
|
+
from etptypes.energistics.etp.v12.datatypes.uuid import Uuid
|
|
28
29
|
from etptypes.energistics.etp.v12.datatypes.supported_data_object import \
|
|
29
30
|
SupportedDataObject
|
|
30
31
|
from etptypes.energistics.etp.v12.datatypes.supported_protocol import \
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pyetp
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.38
|
|
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
|
|
@@ -19,7 +19,7 @@ Requires-Dist: numpy (>=1.26.3,<2.0.0)
|
|
|
19
19
|
Requires-Dist: pyarrow (>=15.0.0,<16.0.0)
|
|
20
20
|
Requires-Dist: pydantic (>=1.10,<2.0)
|
|
21
21
|
Requires-Dist: redis (>=5.0.1,<6.0.0)
|
|
22
|
-
Requires-Dist: resqpy (
|
|
22
|
+
Requires-Dist: resqpy (>=5.1.10,<6.0.0)
|
|
23
23
|
Requires-Dist: websockets (>=12.0,<13.0)
|
|
24
24
|
Requires-Dist: xsdata (>=24.3.1,<25.0.0)
|
|
25
25
|
Requires-Dist: xtgeo (>=3.8.0,<4.0.0)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
pyetp/__init__.py,sha256=FSlPJ3AXoMe3vDQ0z8k417aKJWwt7sxbNPsLgdc21tI,123
|
|
2
|
-
pyetp/client.py,sha256=
|
|
3
|
-
pyetp/config.py,sha256=
|
|
2
|
+
pyetp/client.py,sha256=H2fSpR4tNM4dfXvldlmI4VxemepOTarNGKkCuQos108,47173
|
|
3
|
+
pyetp/config.py,sha256=eKSpS7EXOYchZPoh0bHsNTQIAcipG-nFYKpfdtEz3g8,868
|
|
4
4
|
pyetp/resqml_objects/__init__.py,sha256=Sr_1bktzS8JMmE9oi6pcW6BuERm7gH0u50rBs58zI7Q,50492
|
|
5
5
|
pyetp/resqml_objects/generated.py,sha256=P-hfL8btOE6uAmtaGXbSdWMl8Z9iJx-r6FRzSvmzHvU,783914
|
|
6
|
-
pyetp/types.py,sha256=
|
|
6
|
+
pyetp/types.py,sha256=k3lvtgYmLO5aZGkQE2CChQ0RO-fB-Bkc9AC9uCrAC94,6458
|
|
7
7
|
pyetp/uri.py,sha256=6NE_-QvtaL_z5NCUbxehc28ul-70DgXpMiEGaIJPqNc,2996
|
|
8
8
|
pyetp/utils.py,sha256=4U_9ndZGzN3B0xMoeSglmxdg7jgfYP5v_mE6tF2Lqmc,518
|
|
9
9
|
pyetp/utils_arrays.py,sha256=HHhw23La4SG7UJyd5Q_OJ5WlMq98QpwHBk553YyyYOk,4331
|
|
10
10
|
pyetp/utils_xml.py,sha256=OLGKPxFsz2OzsJOEJDgQXIZ9wwvanlOr6jD3i3KHVZI,33861
|
|
11
|
-
pyetp-0.0.
|
|
12
|
-
pyetp-0.0.
|
|
13
|
-
pyetp-0.0.
|
|
14
|
-
pyetp-0.0.
|
|
11
|
+
pyetp-0.0.38.dist-info/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
+
pyetp-0.0.38.dist-info/METADATA,sha256=2g26bR8RjV1bosf4_TTvJJIrh55JAgyjVsbtzVm7FBA,2347
|
|
13
|
+
pyetp-0.0.38.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
14
|
+
pyetp-0.0.38.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|