RDDMS Client
The class RDDMSClient is an asynchronous
client that contains high-level methods for interacting with the
open-etp-server.
To set up a connection use rddms_connect as
an awaitable, a context manager, or generator returning an instance of
RDDMSClient.
An alternative is to use
RDDMSClientSync for a synchronous
alternative to RDDMSClient.
This avoids the need for using await and async at the cost of lower
efficiency, and slighly less flexibility.
However, for many use-cases this will be more than enough.
Setting up a connection
rddms_io.client.rddms_connect
rddms_connect(
uri: str,
data_partition_id: str | None = None,
authorization: str | SecretStr | None = None,
etp_timeout: float | None = None,
max_message_size: float = 2**20,
use_compression: bool = True,
)
Connect to an RDDMS server via ETP.
This class can act as:
- A context manager handling setup and tear-down of the connection.
- An asynchronous iterator which can be used to persistently retry to connect if the websockets connection drops.
- An awaitable connection that must be manually closed by the user.
See below for examples of all three cases.
| PARAMETER | DESCRIPTION |
|---|---|
uri
|
The uri to the RDDMS server. This should be the uri to a websockets endpoint to an ETP server.
TYPE:
|
data_partition_id
|
The data partition id used when connecting to the OSDU open-etp-server
in multi-partition mode. Default is
TYPE:
|
authorization
|
Bearer token used for authenticating to the RDDMS server. This token
should be on the form
TYPE:
|
etp_timeout
|
The timeout in seconds for when to stop waiting for a message from the
server. Setting it to
TYPE:
|
max_message_size
|
The maximum number of bytes for a single websockets message. Default is
TYPE:
|
use_compression
|
Flag to toggle if compression of the messages should be applied. So far
the client (and the server) only supports compression with gzip.
Default is
TYPE:
|
Examples:
An example of connecting to an RDDMS server using
rddms_connect as a context manager is:
async with rddms_connect(...) as rddms_client:
...
In this case the closing message is sent and the websockets connection is closed once the program exits the context manager.
To persist a connection if the websockets connection is dropped (for any
reason), use :func:rddms_connect as an asynchronous generator, viz.:
import websockets
async for rddms_client in rddms_connect(...):
try:
...
except websockets.ConnectionClosed:
continue
# Include `break` to avoid re-running the whole block if the
# iteration runs without any errors.
break
Note that in this case the whole program under the try-block is re-run
from the start if the iteration completes normally, or if the websockets
connection is dropped. Therefore, make sure to include a break at the end
of the try-block (as in the example above).
The third option is to set up a connection via await and then manually
close the connection once done:
rddms_client = await rddms_connect(...)
...
await rddms_client.close()
See Also
pyetp.client.etp_connect:
The rddms_connect-class is a thin
wrapper around etp_connect.
Source code in src/rddms_io/client.py
__await__
__await__() -> RDDMSClient
__aenter__
async
__aenter__() -> RDDMSClient
Source code in src/rddms_io/client.py
__aexit__
async
Client implementation
rddms_io.client.RDDMSClient
RDDMSClient(etp_client: ETPClient)
Client using ETP to communicate with an RDDMS (Reservoir Domain Data Management Services) server. It is specifically tailored towards the OSDU open-etp-server and made with the intention to make it easier to interact with RDDMS by exposing ergonomic user-facing functions.
Notes
The client is meant to be set up via
rddms_connect.
| PARAMETER | DESCRIPTION |
|---|---|
etp_client
|
An instance of
TYPE:
|
Source code in src/rddms_io/client.py
close
async
Method used for manual closing of the ETP-connection when the client
has been set up outside a context manager. For example, if the client
has been made via an await-statement then this method should be used
to stop the connection.
Examples:
rddms_client = await rddms_connect(...)
...
await rddms_client.close()
Source code in src/rddms_io/client.py
list_dataspaces
async
list_dataspaces(
store_last_write_filter: datetime | int | None = None,
) -> list[Dataspace]
Method used to list all dataspaces on the ETP-server.
| PARAMETER | DESCRIPTION |
|---|---|
store_last_write_filter
|
A parameter that can be used to limit the results to only include
dataspaces that were written to after the time specified in the
filter. The default is
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Dataspace]
|
A list of ETP |
Source code in src/rddms_io/client.py
delete_dataspace
async
Method deleting a dataspace.
| PARAMETER | DESCRIPTION |
|---|---|
dataspace_uri
|
The ETP dataspace uri, or path, for the dataspace to delete. If it
is a dataspace path (on the form
TYPE:
|
Source code in src/rddms_io/client.py
create_dataspace
async
create_dataspace(
dataspace_uri: str | DataspaceURI,
legal_tags: list[str] = [],
other_relevant_data_countries: list[str] = [],
owners: list[str] = [],
viewers: list[str] = [],
ignore_if_exists: bool = False,
) -> None
Method creating a new dataspace on the ETP server. This function is limited to creating a single dataspace with optional access-control list (ACL) information.
| PARAMETER | DESCRIPTION |
|---|---|
dataspace_uri
|
The ETP dataspace uri, or path, to create. If it is a dataspace
path (on the form
TYPE:
|
legal_tags
|
List of legal tag strings for the ACL. The default is an empty list.
TYPE:
|
other_relevant_data_countries
|
List of data countries for the ACL. The default is an empty list.
TYPE:
|
owners
|
List of owners ACL. The default is an empty list.
TYPE:
|
viewers
|
List of viewers ACL. The default is an empty list.
TYPE:
|
ignore_if_exists
|
When
TYPE:
|
Source code in src/rddms_io/client.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
start_transaction
async
start_transaction(
dataspace_uri: str | DataspaceURI,
read_only: bool,
debounce: bool | float = False,
) -> UUID
Method issuing a StartTransaction-ETP message, with optional
debouncing to retry in case the dataspace is occupied with a different
write transaction. Note that this method (unlike the raw ETP-message)
is limited to starting a transaction on a single dataspace.
| PARAMETER | DESCRIPTION |
|---|---|
dataspace_uri
|
A dataspace URI, either as a string or a
TYPE:
|
read_only
|
Set to
TYPE:
|
debounce
|
Flag to toggle debouncing or maximum total debouncing time.
If set to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UUID
|
A standard library UUID with the transaction uuid. |
Source code in src/rddms_io/client.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 | |
commit_transaction
async
commit_transaction(transaction_uuid: bytes | str | UUID | Uuid) -> None
Method for commiting a transaction after completing all tasks that needs to be synchronized between the client and the server.
| PARAMETER | DESCRIPTION |
|---|---|
transaction_uuid
|
The transaction uuid for the current transaction. This will
typically be the uuid from the
TYPE:
|
Source code in src/rddms_io/client.py
rollback_transaction
async
rollback_transaction(transaction_uuid: bytes | str | UUID | Uuid) -> None
Method for cancelling a running transaction. This will tell the server that it should disregard any changes incurred by the current transaction.
| PARAMETER | DESCRIPTION |
|---|---|
transaction_uuid
|
The transaction uuid for the current transaction. This will
typically be the uuid from the
TYPE:
|
Source code in src/rddms_io/client.py
list_objects_under_dataspace
async
list_objects_under_dataspace(
dataspace_uri: DataspaceURI | str,
data_object_types: list[str | Type[AbstractCitedDataObject]] = [],
count_objects: bool = True,
store_last_write_filter: int | None = None,
) -> list[Resource]
This method will list all objects under a given dataspace.
| PARAMETER | DESCRIPTION |
|---|---|
dataspace_uri
|
The uri of the dataspace to list objects.
TYPE:
|
data_object_types
|
Object types to look for. This can either be a list of strings,
e.g.,
TYPE:
|
count_objects
|
Toggle if the number of target and source objects should be
counted. Default is
TYPE:
|
store_last_write_filter
|
Filter to only include objects that are written after the provided
datetime or timestamp. Default is
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Resource]
|
A list of
|
Source code in src/rddms_io/client.py
list_linked_objects
async
list_linked_objects(
start_uri: DataObjectURI | str,
data_object_types: list[str | Type[AbstractCitedDataObject]] = [],
store_last_write_filter: datetime | int | None = None,
depth: int = 1,
) -> LinkedObjects
Method listing all objects that are linked to the provided object uri.
That is, starting from the object indexed by the uri start_uri it
finds all objects (sources) that links to it, and all objects (targets)
it links to.
| PARAMETER | DESCRIPTION |
|---|---|
start_uri
|
An ETP data object uri to start the query from.
TYPE:
|
data_object_types
|
A filter to limit which types of objects to include in the results.
As a string it is on the form
TYPE:
|
store_last_write_filter
|
Filter to only include objects that are written after the provided
datetime or timestamp. Default is
TYPE:
|
depth
|
The number of links to return. Setting
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LinkedObjects
|
A container ( |
Source code in src/rddms_io/client.py
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 | |
list_array_metadata
async
list_array_metadata(
ml_uris: list[str | DataObjectURI],
) -> dict[str, dict[str, DataArrayMetadata]]
Method used for listing array metadata for all connected arrays to the
provided data object uris. This method downloads the data objects from
the uris, and calls RDDMSClient.list_object_array_metadata to get the
actual metadata. If the objects have already been downloaded, then
using RDDMSClient.list_object_array_metadata will be more efficient.
The purpose of this method is to provide a more convenient way of
exploring an RDDMS server without needing to handle data objects. It is
recommended to use RDDMSClient.list_object_array_metadata if the
objects have already been downloaded.
| PARAMETER | DESCRIPTION |
|---|---|
ml_uris
|
A list of ETP data object uris.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, dict[str, DataArrayMetadata]]
|
A dictionary indexed by the data object uri, containing a new
dictionary with the path in resource as the key and the metadata
(the ETP datatype |
See Also
RDDMSClient.list_object_array_metadata:
A similar method that fetches the metadata from the objects
themselves along with a dataspace uri. It is recommended to use
list_object_array_metadata if you already have the objects in
memory.
Source code in src/rddms_io/client.py
list_object_array_metadata
async
list_object_array_metadata(
dataspace_uri: str | DataspaceURI,
ml_objects: Sequence[AbstractCitedDataObject],
) -> dict[str, dict[str, DataArrayMetadata]]
Method used for listing array metadata for all connected arrays to the provided RESQML-objects. This method works by taking in a dataspace uri and the objects themselves (instead of their uris) as they would need to be downloaded to look up which arrays they link to.
| PARAMETER | DESCRIPTION |
|---|---|
dataspace_uri
|
The ETP dataspace uri where the objects are located.
TYPE:
|
ml_objects
|
A list (or any sequence) of objects that links to arrays.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, dict[str, DataArrayMetadata]]
|
A dictionary indexed by the data object uri, containing a new
dictionary with the path in resource as the key and the metadata
(the ETP datatype |
See Also
RDDMSClient.list_array_metadata:
A similar method that looks up array metadata needing only the uris
of the objects.
Source code in src/rddms_io/client.py
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 | |
upload_array
async
upload_array(
epc_uri: str | DataObjectURI,
path_in_resource: str,
data: NDArray[LogicalArrayDTypes],
) -> None
Method used for uploading a single array to an ETP server. This method
will not work without the user setting up a transaction for writing to
the relevant dataspace. It should not be necessary for a user to call
this method, prefer RDDMSClient.upload_model instead.
| PARAMETER | DESCRIPTION |
|---|---|
epc_uri
|
An ETP data object uri to an
TYPE:
|
path_in_resource
|
A key (typically a HDF5-key) that uniquely identifies the array
along with the
TYPE:
|
data
|
A NumPy-array with the data.
TYPE:
|
See Also
RDDMSClient.upload_model:
A higher-level method that wraps transaction handling, data object
uploading and array uploading in one go.
Source code in src/rddms_io/client.py
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 | |
download_object_arrays
async
download_object_arrays(
dataspace_uri: str | DataspaceURI, ml_object: AbstractCitedDataObject
) -> dict[str, NDArray[LogicalArrayDTypes]]
Method accepting a dataspace_uri (or dataspace path) and a
RESQML-object, and downloading all attached arrays (if any). This
method is mainly used as a helper method for
RDDMSClient.download_models.
| PARAMETER | DESCRIPTION |
|---|---|
dataspace_uri
|
An ETP dataspace uri or path. This can be a string or a
[
TYPE:
|
ml_object
|
An instance of a RESQML-object.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, NDArray[LogicalArrayDTypes]]
|
A dictionary mapping the |
See Also
RDDMSClient.download_models:
The "full" method downloading objects, arrays and potentially
linked objects.
Source code in src/rddms_io/client.py
download_array
async
download_array(
epc_uri: str | DataObjectURI, path_in_resource: str
) -> NDArray[LogicalArrayDTypes]
Method used for downloading a single array from an ETP server. It
should not be necessary for a user to call this method, prefer
RDDMSClient.download_models instead.
| PARAMETER | DESCRIPTION |
|---|---|
epc_uri
|
An ETP data object uri to an
TYPE:
|
path_in_resource
|
A key (typically a HDF5-key) that uniquely identifies the array
along with the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
data
|
A NumPy-array with the data.
TYPE:
|
See Also
RDDMSClient.download_models:
A higher-level method that wraps, data object and array downloading
in one go.
Source code in src/rddms_io/client.py
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 | |
upload_model
async
upload_model(
dataspace_uri: str | DataspaceURI,
ml_objects: Sequence[AbstractCitedDataObject],
data_arrays: Mapping[str, Sequence[NDArray[LogicalArrayDTypes]]] = {},
handle_transaction: bool = True,
debounce: bool | float = False,
) -> list[str]
The main driver method for uploading data to an ETP server. This method
takes in a dataspace uri (for uploading to multiple dataspaces you need
to call RDDMSClient.upload_model multiple times), a set of
RESQML-objects, and a mapping of data arrays that are indexed by their
path in resource (which is found in the RESQML-objects as well).
| PARAMETER | DESCRIPTION |
|---|---|
dataspace_uri
|
An ETP dataspace uri.
TYPE:
|
ml_objects
|
A sequence of RESQML v2.0.1-objects.
TYPE:
|
data_arrays
|
A mapping, e.g., a dictionary, of data arrays where the path in
resources (found in the RESQML-objects) are the keys. Default is
TYPE:
|
handle_transaction
|
A flag to toggle if
TYPE:
|
debounce
|
Parameter to decide if
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
A list of ETP data object uris to the uploaded objects. |
See Also
RDDMSClient.download_models:
The reverse operation.
RDDMSClient.start_transaction:
Method for setting up a transaction. It is only necessary to
interact with this method if handle_transaction=False.
RDDMSClient.commit_transaction:
Method for committing a transaction. It is only necessary to
interact with this method if handle_transaction=False.
Source code in src/rddms_io/client.py
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 | |
download_models
async
download_models(
ml_uris: list[str | DataObjectURI],
download_arrays: bool = False,
download_linked_objects: bool = False,
) -> list[RDDMSModel]
Download RESQML-models from the RDDMS server. A model in this sense is a RESQML-object (with a given uri) and possibly with any connected arrays and referenced objects.
| PARAMETER | DESCRIPTION |
|---|---|
ml_uris
|
A list of ETP data object uris.
TYPE:
|
download_arrays
|
A flag to toggle if any referenced arrays should be download
alongside the RESQML-objects. Setting to
TYPE:
|
download_linked_objects
|
Flag to toggle if linked objects (target-objects), i.e., objects
referenced by objects from
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[RDDMSModel]
|
A list of |
Source code in src/rddms_io/client.py
delete_model
async
delete_model(
ml_uris: list[str | DataObjectURI],
prune_contained_objects: bool = False,
handle_transaction: bool = True,
debounce: bool | float = False,
) -> None
Method used for deleting a set of objects on an ETP server. In order for the deletion to be successful the objects to be deleted can not leave any dangling source-objects. That is, there can be no objects left on the ETP server that references the deleted objects.
| PARAMETER | DESCRIPTION |
|---|---|
ml_uris
|
A list of ETP data object uris to delete.
TYPE:
|
prune_contained_objects
|
See section 9.3.4 in the ETP v1.2 standards documentation for an
accurate description of this parameter. Default is
TYPE:
|
handle_transaction
|
A flag to toggle if
TYPE:
|
debounce
|
Parameter to decide if
TYPE:
|
Source code in src/rddms_io/client.py
Synchronous client implementation
The synchronous client RDDMSClientSync is a thin wrapper around
RDDMSClient. The main difference is that every
method on the synchronous client will set up a connection towards the server,
call the relevant method, and then tear down the connection. If you find
yourself running multiple methods after one another, it might be beneficial to
use RDDMSClient instead.
rddms_io.sync_client.RDDMSClientSync
RDDMSClientSync(
uri: str,
data_partition_id: str | None = None,
authorization: str | SecretStr | None = None,
etp_timeout: float | None = None,
max_message_size: float = 2**20,
use_compression: bool = True,
)
Synchronized version of the RDDMSClient.
The purpose of this client is to serve the same high-level endpoints
towards the RDDMS server as RDDMSClient, but without the need to use
async and await. Only the methods (and parameters) that can be wrapped
in a single call are included in RDDMSClientSync. The client works by
passing in the same parameters as
rddms_connect to the constructor, and
then calling the methods without using await. The parameters to
RDDMSClientSync are the same as to rddms_connect.
| PARAMETER | DESCRIPTION |
|---|---|
uri
|
The uri to the RDDMS server. This should be the uri to a websockets endpoint to an ETP server.
TYPE:
|
data_partition_id
|
The data partition id used when connecting to the OSDU open-etp-server
in multi-partition mode. Default is
TYPE:
|
authorization
|
Bearer token used for authenticating to the RDDMS server. This token
should be on the form
TYPE:
|
etp_timeout
|
The timeout in seconds for when to stop waiting for a message from the
server. Setting it to
TYPE:
|
max_message_size
|
The maximum number of bytes for a single websockets message. Default is
TYPE:
|
use_compression
|
Flag to toggle if compression of the messages should be applied. So far
the client (and the server) only supports compression with gzip.
Default is
TYPE:
|
Notes
The authorization-token (if using, e.g.,
msal` will have an
expiration time. If this expiration time is met, the client needs to be
updated with a fresh token.
Whenever you call one of the methods of this client, it will set up a new ETP session, call the relevant method from the asynchronous client, and then tear down the connection. If you find yourself repeatedly calling multiple methods in a succesive fashion, consider switching to the asynchronous client as this will be much faster.
See Also
RDDMSClient:
The asynchronous driver class which RDDMSClientSync wraps.
rddms_connect:
The connection class to set up the asynchronous RDDMSClient.
Source code in src/rddms_io/sync_client.py
connection_args
instance-attribute
connection_args = dict(
uri=uri,
data_partition_id=data_partition_id,
authorization=authorization,
etp_timeout=etp_timeout,
max_message_size=max_message_size,
use_compression=use_compression,
)
create_dataspace
create_dataspace(
dataspace_uri: str | DataspaceURI,
legal_tags: list[str] = [],
other_relevant_data_countries: list[str] = [],
owners: list[str] = [],
viewers: list[str] = [],
ignore_if_exists: bool = False,
) -> None
Method creating a new dataspace on the ETP server. This function is limited to creating a single dataspace with optional access-control list (ACL) information.
| PARAMETER | DESCRIPTION |
|---|---|
dataspace_uri
|
The ETP dataspace uri, or path, to create. If it is a dataspace
path (on the form
TYPE:
|
legal_tags
|
List of legal tag strings for the ACL. The default is an empty list.
TYPE:
|
other_relevant_data_countries
|
List of data countries for the ACL. The default is an empty list.
TYPE:
|
owners
|
List of owners ACL. The default is an empty list.
TYPE:
|
viewers
|
List of viewers ACL. The default is an empty list.
TYPE:
|
ignore_if_exists
|
When
TYPE:
|
See Also
RDDMSClient.create_dataspace:
The asynchronous counterpart.
Source code in src/rddms_io/sync_client.py
delete_dataspace
Method deleting a dataspace.
| PARAMETER | DESCRIPTION |
|---|---|
dataspace_uri
|
The ETP dataspace uri, or path, for the dataspace to delete. If it
is a dataspace path (on the form
TYPE:
|
See Also
RDDMSClient.delete_dataspace:
The asynchronous version of this method.
Source code in src/rddms_io/sync_client.py
list_dataspaces
list_dataspaces(
store_last_write_filter: datetime | int | None = None,
) -> list[Dataspace]
Method used to list all dataspaces on the ETP-server.
| PARAMETER | DESCRIPTION |
|---|---|
store_last_write_filter
|
A parameter that can be used to limit the results to only include
dataspaces that were written to after the time specified in the
filter. The default is
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Dataspace]
|
A list of ETP |
See Also
RDDMSClient.list_dataspaces:
The asynchronous version of this method.
Source code in src/rddms_io/sync_client.py
list_objects_under_dataspace
list_objects_under_dataspace(
dataspace_uri: DataspaceURI | str,
data_object_types: list[str | Type[AbstractCitedDataObject]] = [],
count_objects: bool = True,
store_last_write_filter: int | None = None,
) -> list[Resource]
This method will list all objects under a given dataspace.
| PARAMETER | DESCRIPTION |
|---|---|
dataspace_uri
|
The uri of the dataspace to list objects.
TYPE:
|
data_object_types
|
Object types to look for. This can either be a list of strings,
e.g.,
TYPE:
|
count_objects
|
Toggle if the number of target and source objects should be
counted. Default is
TYPE:
|
store_last_write_filter
|
Filter to only include objects that are written after the provided
datetime or timestamp. Default is
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Resource]
|
A list of
|
See Also
RDDMSClient.list_objects_under_dataspace:
The asynchronous version of this method.
Source code in src/rddms_io/sync_client.py
list_linked_objects
list_linked_objects(
start_uri: DataObjectURI | str,
data_object_types: list[str | Type[AbstractCitedDataObject]] = [],
store_last_write_filter: datetime | int | None = None,
depth: int = 1,
) -> LinkedObjects
Method listing all objects that are linked to the provided object uri.
That is, starting from the object indexed by the uri start_uri it
finds all objects (sources) that links to it, and all objects (targets)
it links to.
| PARAMETER | DESCRIPTION |
|---|---|
start_uri
|
An ETP data object uri to start the query from.
TYPE:
|
data_object_types
|
A filter to limit which types of objects to include in the results.
As a string it is on the form
TYPE:
|
store_last_write_filter
|
Filter to only include objects that are written after the provided
datetime or timestamp. Default is
TYPE:
|
depth
|
The number of links to return. Setting
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LinkedObjects
|
A container ( |
See Also
RDDMSClient.list_linked_objects:
The asynchronous version of this method.
Source code in src/rddms_io/sync_client.py
list_array_metadata
list_array_metadata(
ml_uris: list[str | DataObjectURI],
) -> dict[str, dict[str, DataArrayMetadata]]
Method used for listing array metadata for all connected arrays to the
provided data object uris. This method downloads the data objects from
the uris, and calls RDDMSClient.list_object_array_metadata to get the
actual metadata. If the objects have already been downloaded, then
using RDDMSClientSync.list_object_array_metadata will be more
efficient.
The purpose of this method is to provide a more convenient way of
exploring an RDDMS server without needing to handle data objects. It is
recommended to use RDDMSClientSync.list_object_array_metadata if the
objects have already been downloaded.
| PARAMETER | DESCRIPTION |
|---|---|
ml_uris
|
A list of ETP data object uris.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, dict[str, DataArrayMetadata]]
|
A dictionary indexed by the data object uri, containing a new
dictionary with the path in resource as the key and the metadata
(the ETP datatype |
See Also
RDDMSClient.list_array_metadata:
The asynchronous version of this method.
RDDMSClientSync.list_object_array_metadata:
A similar method that fetches the metadata from the objects
themselves along with a dataspace uri. It is recommended to use
list_object_array_metadata if you already have the objects in
memory.
Source code in src/rddms_io/sync_client.py
list_object_array_metadata
list_object_array_metadata(
dataspace_uri: str | DataspaceURI,
ml_objects: Sequence[AbstractCitedDataObject],
) -> dict[str, dict[str, DataArrayMetadata]]
Method used for listing array metadata for all connected arrays to the provided RESQML-objects. This method works by taking in a dataspace uri and the objects themselves (instead of their uris) as they would need to be downloaded to look up which arrays they link to.
| PARAMETER | DESCRIPTION |
|---|---|
dataspace_uri
|
The ETP dataspace uri where the objects are located.
TYPE:
|
ml_objects
|
A list (or any sequence) of objects that links to arrays.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, dict[str, DataArrayMetadata]]
|
A dictionary indexed by the data object uri, containing a new
dictionary with the path in resource as the key and the metadata
(the ETP datatype |
See Also
RDDMSClient.list_object_array_metadata:
The asynchronous version of this method.
RDDMSClientSync.list_array_metadata:
A similar method that looks up array metadata needing only the uris
of the objects.
Source code in src/rddms_io/sync_client.py
delete_model
delete_model(
ml_uris: list[str | DataObjectURI],
prune_contained_objects: bool = False,
debounce: bool | float = False,
) -> None
Method used for deleting a set of objects on an ETP server. In order for the deletion to be successful the objects to be deleted can not leave any dangling source-objects. That is, there can be no objects left on the ETP server that references the deleted objects.
| PARAMETER | DESCRIPTION |
|---|---|
ml_uris
|
A list of ETP data object uris to delete.
TYPE:
|
prune_contained_objects
|
See section 9.3.4 in the ETP v1.2 standards documentation for an
accurate description of this parameter. Default is
TYPE:
|
debounce
|
Parameter to decide if
TYPE:
|
See Also
RDDMSClient.delete_model:
The asynchronous version of this method.
Source code in src/rddms_io/sync_client.py
upload_model
upload_model(
dataspace_uri: str | DataspaceURI,
ml_objects: Sequence[AbstractCitedDataObject],
data_arrays: Mapping[str, Sequence[NDArray[LogicalArrayDTypes]]] = {},
debounce: bool | float = False,
) -> list[str]
Method for uploading data to an ETP server. This method takes in a
dataspace uri (for uploading to multiple dataspaces you need to call
RDDMSClient.upload_model multiple times), a set of RESQML-objects,
and a mapping of data arrays that are indexed by their path in resource
(which is found in the RESQML-objects as well).
| PARAMETER | DESCRIPTION |
|---|---|
dataspace_uri
|
An ETP dataspace uri.
TYPE:
|
ml_objects
|
A sequence of RESQML v2.0.1-objects.
TYPE:
|
data_arrays
|
A mapping, e.g., a dictionary, of data arrays where the path in
resources (found in the RESQML-objects) are the keys. Default is
TYPE:
|
debounce
|
Parameter to decide if
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
A list of ETP data object uris to the uploaded objects. |
See Also
RDDMSClient.upload_model:
The asynchronous version of this method.
RDDMSClientSync.download_models:
The reverse operation.
Source code in src/rddms_io/sync_client.py
download_models
download_models(
ml_uris: list[str | DataObjectURI],
download_arrays: bool = False,
download_linked_objects: bool = False,
) -> list[RDDMSModel]
Download RESQML-models from the RDDMS server. A model in this sense is a RESQML-object (with a given uri) and possibly with any connected arrays and referenced objects.
| PARAMETER | DESCRIPTION |
|---|---|
ml_uris
|
A list of ETP data object uris.
TYPE:
|
download_arrays
|
A flag to toggle if any referenced arrays should be download
alongside the RESQML-objects. Setting to
TYPE:
|
download_linked_objects
|
Flag to toggle if linked objects (target-objects), i.e., objects
referenced by objects from
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[RDDMSModel]
|
A list of |
See Also
RDDMSClient.download_models:
The asynchronous version of this method.
Source code in src/rddms_io/sync_client.py
Data types
Data types returned by RDDMSClient in various
methods.
rddms_io.data_types
RDDMSModel
Bases: NamedTuple
Container for results after calling
RDDMSClient.download_models.
| ATTRIBUTE | DESCRIPTION |
|---|---|
obj |
The main object in the model, i.e., the object that is referenced by a
passed in uri in the argument
TYPE:
|
arrays |
A dictionary with arrays referenced by
TYPE:
|
linked_models |
A list of
TYPE:
|
LinkedObjects
Bases: NamedTuple
Container for results after calling
RDDMSClient.list_linked_objects.
Objects in RESQML are structured as graphs. Objects can point to other
objects. If object A has a reference to object B, we say that A is a
source to B, but B is also a target to A.
| ATTRIBUTE | DESCRIPTION |
|---|---|
start_uri |
The uri of the object that we are looking for links to.
TYPE:
|
self_resource |
The
TYPE:
|
source_resources |
A list of
TYPE:
|
source_edges |
A list of
TYPE:
|
target_resources |
A list of
TYPE:
|
target_edges |
A list of
TYPE:
|