pyetp 0.0.35__py3-none-any.whl → 0.0.37__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 +47 -35
- pyetp/config.py +1 -2
- pyetp/types.py +1 -0
- pyetp/utils_xml.py +1 -1
- {pyetp-0.0.35.dist-info → pyetp-0.0.37.dist-info}/METADATA +1 -1
- pyetp-0.0.37.dist-info/RECORD +14 -0
- pyetp-0.0.35.dist-info/RECORD +0 -14
- {pyetp-0.0.35.dist-info → pyetp-0.0.37.dist-info}/LICENSE.md +0 -0
- {pyetp-0.0.35.dist-info → pyetp-0.0.37.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
|
|
@@ -274,6 +273,8 @@ class ETPClient(ETPConnection):
|
|
|
274
273
|
|
|
275
274
|
|
|
276
275
|
def dataspace_uri(self, ds: str) -> DataspaceURI:
|
|
276
|
+
if ds.count("/") > 1:
|
|
277
|
+
raise Exception(f"Max one / in dataspace name")
|
|
277
278
|
return DataspaceURI.from_name(ds)
|
|
278
279
|
|
|
279
280
|
def list_objects(self, dataspace_uri: DataspaceURI, depth: int = 1) -> list:
|
|
@@ -291,10 +292,10 @@ class ETPClient(ETPConnection):
|
|
|
291
292
|
#
|
|
292
293
|
|
|
293
294
|
async def put_dataspaces(self, *dataspace_uris: DataspaceURI):
|
|
294
|
-
|
|
295
|
-
|
|
296
295
|
_uris = list(map(DataspaceURI.from_any, dataspace_uris))
|
|
297
|
-
|
|
296
|
+
for i in _uris:
|
|
297
|
+
if i.raw_uri.count("/") > 4: # includes the 3 eml
|
|
298
|
+
raise Exception(f"Max one / in dataspace name")
|
|
298
299
|
time = self.timestamp
|
|
299
300
|
response = await self.send(
|
|
300
301
|
PutDataspaces(dataspaces={
|
|
@@ -500,34 +501,36 @@ class ETPClient(ETPConnection):
|
|
|
500
501
|
rotation=rotation,
|
|
501
502
|
masked=True
|
|
502
503
|
)
|
|
503
|
-
async def start_transaction(self, dataspace_uri: DataspaceURI, readOnly :bool= True) ->
|
|
504
|
+
async def start_transaction(self, dataspace_uri: DataspaceURI, readOnly :bool= True) -> Uuid:
|
|
504
505
|
trans_id = await self.send(StartTransaction(readOnly=readOnly, dataspaceUris=[dataspace_uri.raw_uri]))
|
|
505
506
|
if trans_id.successful is False:
|
|
506
507
|
raise Exception(f"Failed starting transaction {dataspace_uri.raw_uri}")
|
|
507
|
-
return uuid.UUID(bytes=trans_id.transaction_uuid)
|
|
508
|
+
return Uuid(trans_id.transaction_uuid) #uuid.UUID(bytes=trans_id.transaction_uuid)
|
|
508
509
|
|
|
509
|
-
async def commit_transaction(self, transaction_id:
|
|
510
|
-
r = await self.send(CommitTransaction(
|
|
510
|
+
async def commit_transaction(self, transaction_id: Uuid):
|
|
511
|
+
r = await self.send(CommitTransaction(transactionUuid=transaction_id))
|
|
511
512
|
if r.successful is False:
|
|
512
513
|
raise Exception(r.failure_reason)
|
|
513
514
|
return r
|
|
514
515
|
|
|
515
|
-
async def rollback_transaction(self, transaction_id:
|
|
516
|
+
async def rollback_transaction(self, transaction_id: Uuid):
|
|
516
517
|
return await self.send(RollbackTransaction(transactionUuid=transaction_id))
|
|
517
518
|
|
|
518
519
|
async def put_xtgeo_surface(self, surface: RegularSurface, epsg_code: int, dataspace_uri: DataspaceURI):
|
|
519
520
|
"""Returns (epc_uri, crs_uri, gri_uri)"""
|
|
520
521
|
assert surface.values is not None, "cannot upload empty surface"
|
|
521
522
|
|
|
522
|
-
|
|
523
|
+
t_id = await self.start_transaction(dataspace_uri, False)
|
|
523
524
|
epc, crs, gri = utils_xml.parse_xtgeo_surface_to_resqml_grid(surface, epsg_code)
|
|
524
525
|
epc_uri, crs_uri, gri_uri = await self.put_resqml_objects(epc, crs, gri, dataspace_uri=dataspace_uri)
|
|
525
|
-
|
|
526
|
+
|
|
527
|
+
await self.put_array(
|
|
526
528
|
DataArrayIdentifier(
|
|
527
529
|
uri=epc_uri.raw_uri if isinstance(epc_uri, DataObjectURI) else epc_uri,
|
|
528
530
|
pathInResource=gri.grid2d_patch.geometry.points.zvalues.values.path_in_hdf_file # type: ignore
|
|
529
531
|
),
|
|
530
|
-
surface.values.filled(np.nan).astype(np.float32)
|
|
532
|
+
surface.values.filled(np.nan).astype(np.float32),
|
|
533
|
+
t_id
|
|
531
534
|
)
|
|
532
535
|
|
|
533
536
|
return epc_uri, gri_uri, crs_uri
|
|
@@ -691,6 +694,7 @@ class ETPClient(ETPConnection):
|
|
|
691
694
|
assert len(cprop0.patch_of_values) == 1, "property obj must have exactly one patch of values"
|
|
692
695
|
|
|
693
696
|
st = time.time()
|
|
697
|
+
t_id = await self.start_transaction(dataspace_uri, False)
|
|
694
698
|
propkind_uri = [""] if (propertykind0 is None) else (await self.put_resqml_objects(propertykind0, dataspace_uri=dataspace_uri))
|
|
695
699
|
cprop_uri = await self.put_resqml_objects(cprop0, dataspace_uri=dataspace_uri)
|
|
696
700
|
delay = time.time() - st
|
|
@@ -703,6 +707,7 @@ class ETPClient(ETPConnection):
|
|
|
703
707
|
pathInResource=cprop0.patch_of_values[0].values.values.path_in_hdf_file,
|
|
704
708
|
),
|
|
705
709
|
array_ref, # type: ignore
|
|
710
|
+
t_id
|
|
706
711
|
)
|
|
707
712
|
delay = time.time() - st
|
|
708
713
|
logger.debug(f"pyetp: put_rddms_property: put array ({array_ref.shape}) took {delay} s")
|
|
@@ -713,6 +718,7 @@ class ETPClient(ETPConnection):
|
|
|
713
718
|
dataspace_uri: DataspaceURI
|
|
714
719
|
):
|
|
715
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)
|
|
716
722
|
epc_uri, crs_uri, uns_uri = await self.put_resqml_objects(epc, crs, uns, dataspace_uri=dataspace_uri)
|
|
717
723
|
timeseries_uri = ""
|
|
718
724
|
if timeseries is not None:
|
|
@@ -769,7 +775,7 @@ class ETPClient(ETPConnection):
|
|
|
769
775
|
),
|
|
770
776
|
hexa.cell_face_is_right_handed # type: ignore
|
|
771
777
|
)
|
|
772
|
-
|
|
778
|
+
await self.commit_transaction(t_id)
|
|
773
779
|
#
|
|
774
780
|
# mesh properties: one Property, one array of values, and an optional PropertyKind per property
|
|
775
781
|
#
|
|
@@ -889,21 +895,25 @@ class ETPClient(ETPConnection):
|
|
|
889
895
|
arrays = list(response.data_arrays.values())
|
|
890
896
|
return utils_arrays.to_numpy(arrays[0])
|
|
891
897
|
|
|
892
|
-
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):
|
|
893
899
|
|
|
894
900
|
|
|
895
901
|
# Check if we can upload the full array in one go.
|
|
896
902
|
if data.nbytes > self.max_array_size:
|
|
897
|
-
return await self._put_array_chuncked(uid, data)
|
|
898
|
-
|
|
903
|
+
return await self._put_array_chuncked(uid, data, transaction_id)
|
|
904
|
+
|
|
899
905
|
response = await self.send(
|
|
900
906
|
PutDataArrays(
|
|
901
907
|
dataArrays={uid.path_in_resource: PutDataArraysType(uid=uid, array=utils_arrays.to_data_array(data))})
|
|
902
908
|
)
|
|
909
|
+
|
|
903
910
|
assert isinstance(response, PutDataArraysResponse), "Expected PutDataArraysResponse"
|
|
904
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)
|
|
905
914
|
return response.success
|
|
906
915
|
|
|
916
|
+
|
|
907
917
|
async def get_subarray(self, uid: DataArrayIdentifier, starts: T.Union[np.ndarray, T.List[int]], counts: T.Union[np.ndarray, T.List[int]]):
|
|
908
918
|
starts = np.array(starts).astype(np.int64)
|
|
909
919
|
counts = np.array(counts).astype(np.int64)
|
|
@@ -1002,31 +1012,33 @@ class ETPClient(ETPConnection):
|
|
|
1002
1012
|
slices = tuple(map(lambda se: slice(se[0], se[1]), zip(starts-offset, ends-offset)))
|
|
1003
1013
|
buffer[slices] = array
|
|
1004
1014
|
return
|
|
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}")
|
|
1007
|
-
for i in batched(coro, self.max_concurrent_requests):
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
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
|
+
])
|
|
1013
1023
|
|
|
1014
1024
|
return buffer
|
|
1015
1025
|
|
|
1016
|
-
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):
|
|
1017
1027
|
transport_array_type = utils_arrays.get_transport(data.dtype)
|
|
1028
|
+
|
|
1018
1029
|
await self._put_uninitialized_data_array(uid, data.shape, transport_array_type=transport_array_type)
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
for starts, counts in self._get_chunk_sizes(data.shape, data.dtype):
|
|
1022
|
-
params.append([starts, counts])
|
|
1023
|
-
#await self.put_subarray(uid, data, starts, counts)
|
|
1024
|
-
coro.append(self.put_subarray(uid, data, starts, counts))
|
|
1025
|
-
logger.debug(f"Concurrent request: {self.max_concurrent_requests}")
|
|
1026
|
-
for i in batched(coro, self.max_concurrent_requests):
|
|
1027
|
-
await asyncio.gather(*i)
|
|
1028
|
-
#r = await asyncio.gather(*coro)
|
|
1030
|
+
if isinstance(transaction_id, Uuid):
|
|
1031
|
+
await self.commit_transaction(transaction_id)
|
|
1029
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
|
+
|
|
1030
1042
|
return {uid.uri: ''}
|
|
1031
1043
|
|
|
1032
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 \
|
pyetp/utils_xml.py
CHANGED
|
@@ -437,7 +437,7 @@ def create_resqml_mesh(rmdi, rmdts, geotimes, projected_epsg: int): #(rddms_mes
|
|
|
437
437
|
node_count=node_count,
|
|
438
438
|
face_count=face_count,
|
|
439
439
|
cell_shape=cellshape,
|
|
440
|
-
points=ro.
|
|
440
|
+
points=ro.Point3dHdf5Array(
|
|
441
441
|
coordinates=ro.Hdf5Dataset(
|
|
442
442
|
path_in_hdf_file=f"/RESQML/{str(hexa_uuid)}/points",
|
|
443
443
|
hdf_proxy=ro.DataObjectReference(
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
pyetp/__init__.py,sha256=FSlPJ3AXoMe3vDQ0z8k417aKJWwt7sxbNPsLgdc21tI,123
|
|
2
|
+
pyetp/client.py,sha256=H2fSpR4tNM4dfXvldlmI4VxemepOTarNGKkCuQos108,47173
|
|
3
|
+
pyetp/config.py,sha256=eKSpS7EXOYchZPoh0bHsNTQIAcipG-nFYKpfdtEz3g8,868
|
|
4
|
+
pyetp/resqml_objects/__init__.py,sha256=Sr_1bktzS8JMmE9oi6pcW6BuERm7gH0u50rBs58zI7Q,50492
|
|
5
|
+
pyetp/resqml_objects/generated.py,sha256=P-hfL8btOE6uAmtaGXbSdWMl8Z9iJx-r6FRzSvmzHvU,783914
|
|
6
|
+
pyetp/types.py,sha256=k3lvtgYmLO5aZGkQE2CChQ0RO-fB-Bkc9AC9uCrAC94,6458
|
|
7
|
+
pyetp/uri.py,sha256=6NE_-QvtaL_z5NCUbxehc28ul-70DgXpMiEGaIJPqNc,2996
|
|
8
|
+
pyetp/utils.py,sha256=4U_9ndZGzN3B0xMoeSglmxdg7jgfYP5v_mE6tF2Lqmc,518
|
|
9
|
+
pyetp/utils_arrays.py,sha256=HHhw23La4SG7UJyd5Q_OJ5WlMq98QpwHBk553YyyYOk,4331
|
|
10
|
+
pyetp/utils_xml.py,sha256=OLGKPxFsz2OzsJOEJDgQXIZ9wwvanlOr6jD3i3KHVZI,33861
|
|
11
|
+
pyetp-0.0.37.dist-info/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
+
pyetp-0.0.37.dist-info/METADATA,sha256=cjlX-Fm_oO4KK7LEduqtuVMx96bomR0frV5SryyVRKg,2344
|
|
13
|
+
pyetp-0.0.37.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
14
|
+
pyetp-0.0.37.dist-info/RECORD,,
|
pyetp-0.0.35.dist-info/RECORD
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
pyetp/__init__.py,sha256=FSlPJ3AXoMe3vDQ0z8k417aKJWwt7sxbNPsLgdc21tI,123
|
|
2
|
-
pyetp/client.py,sha256=YlNrmhiuNkyMC8dJ-km1TSjFrMF867becxK8Y6Fzgxg,46534
|
|
3
|
-
pyetp/config.py,sha256=WCs9n5Cd2igSVQzSNKPjnYP_H-61BYSHEeQ5Jh1oQlc,918
|
|
4
|
-
pyetp/resqml_objects/__init__.py,sha256=Sr_1bktzS8JMmE9oi6pcW6BuERm7gH0u50rBs58zI7Q,50492
|
|
5
|
-
pyetp/resqml_objects/generated.py,sha256=P-hfL8btOE6uAmtaGXbSdWMl8Z9iJx-r6FRzSvmzHvU,783914
|
|
6
|
-
pyetp/types.py,sha256=HMNZ4_cJqhxqzXiYsNT-Ywvtfji9PARX4d6MixoQn1k,6397
|
|
7
|
-
pyetp/uri.py,sha256=6NE_-QvtaL_z5NCUbxehc28ul-70DgXpMiEGaIJPqNc,2996
|
|
8
|
-
pyetp/utils.py,sha256=4U_9ndZGzN3B0xMoeSglmxdg7jgfYP5v_mE6tF2Lqmc,518
|
|
9
|
-
pyetp/utils_arrays.py,sha256=HHhw23La4SG7UJyd5Q_OJ5WlMq98QpwHBk553YyyYOk,4331
|
|
10
|
-
pyetp/utils_xml.py,sha256=VLTelVsUZrUDZEGES4xMU8MA9zSW-C83IDiHD_B8wT0,33861
|
|
11
|
-
pyetp-0.0.35.dist-info/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
-
pyetp-0.0.35.dist-info/METADATA,sha256=bPWvQUgMF77eVBwkMLjJefMKU2TtXnOzHvw9_JKu1zY,2344
|
|
13
|
-
pyetp-0.0.35.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
14
|
-
pyetp-0.0.35.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|