Skip to content

Commit 8a2f1d8

Browse files
Clean Jupyter Notebooks
Also fix regression of 6e48e72
1 parent 98ae973 commit 8a2f1d8

6 files changed

Lines changed: 64 additions & 48 deletions

File tree

cmake/swigEtp1_2Include.i.in

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,7 @@ namespace ETP_NS
19221922
/**
19231923
* A customer sends to a store to discover all dataspaces available on the store.
19241924
* This function should be used with caution if Dataspace Handlers have been overidden.
1925-
* It actually sends a message and block the current thread untill a response has been received from the store.
1925+
* It actually sends a message and block the current thread until a response has been received from the store.
19261926
*
19271927
* @param storeLastWriteFilter An optional filter to limit the dataspaces returned by date/time last saved to the store.
19281928
* The store returns a list of dataspaces whose last changed date/time is greater than the specified date/time.
@@ -1934,7 +1934,7 @@ namespace ETP_NS
19341934
/**
19351935
* A customer sends to a store to create one or more dataspaces.
19361936
* This function should be used with caution if Dataspace Handlers have been overidden.
1937-
* It actually sends a message and block the current thread untill a response has been received from the store.
1937+
* It actually sends a message and block the current thread until a response has been received from the store.
19381938
*
19391939
* @param dataspaces ETP general map : One each for each dataspace the customer wants to add or update.
19401940
* @param return The map keys corresponding to the dataspaces which have been put successfully into the store.
@@ -1944,7 +1944,7 @@ namespace ETP_NS
19441944
/**
19451945
* A customer sends to a store to delete one or more dataspaces.
19461946
* This function should be used with caution if Dataspace Handlers have been overidden.
1947-
* It actually sends a message and block the current thread untill a response has been received from the store.
1947+
* It actually sends a message and block the current thread until a response has been received from the store.
19481948
*
19491949
* @param dataspaceUris ETP general map where the values must be the URIs for the dataspaces the customer wants to delete.
19501950
* @param return The map keys corresponding to the dataspaces which have been deleted successfully.
@@ -1958,7 +1958,7 @@ namespace ETP_NS
19581958
/**
19591959
* A customer sends to a store to discover information of particular dataspaces.
19601960
* This function should be used with caution if Dataspace OSDU Handlers have been overidden.
1961-
* It actually sends a message and block the current thread untill a response has been received from the store.
1961+
* It actually sends a message and block the current thread until a response has been received from the store.
19621962
*
19631963
* @param dataspaceUris ETP general map : One each for each dataspace, identified by their URI, the customer wants to get info about.
19641964
* @param return The dataspaces the store could return.
@@ -1968,7 +1968,7 @@ namespace ETP_NS
19681968
/**
19691969
* Copy by reference some dataspaces into another one.
19701970
* This function should be used with caution if Dataspace OSDU Handlers have been overidden.
1971-
* It actually sends a message and block the current thread untill a response has been received from the store.
1971+
* It actually sends a message and block the current thread until a response has been received from the store.
19721972
*
19731973
* @param sourceDataspaceUris ETP general map : One each for each source dataspace to be copied. They are identified by their URI.
19741974
* @param targetDataspaceUri The URI of the ETP dataspace where the sourceDataspaces have to be copied by reference.
@@ -1979,7 +1979,7 @@ namespace ETP_NS
19791979
/**
19801980
* A customer sends to a store to lock or unlock one or more dataspaces.
19811981
* This function should be used with caution if Dataspace OSDU Handlers have been overidden.
1982-
* It actually sends a message and block the current thread untill a response has been received from the store.
1982+
* It actually sends a message and block the current thread until a response has been received from the store.
19831983
*
19841984
* @param dataspaceUris ETP general map where the values must be the URIs for the dataspaces the customer wants to lock or unlock.
19851985
* @param lock true for locking the dataspaces, false to unlock the dataspaces
@@ -1990,7 +1990,7 @@ namespace ETP_NS
19901990
/**
19911991
* Copy by reference some dataobjects into another dataspace.
19921992
* This function should be used with caution if Dataspace OSDU Handlers have been overidden.
1993-
* It actually sends a message and block the current thread untill a response has been received from the store.
1993+
* It actually sends a message and block the current thread until a response has been received from the store.
19941994
*
19951995
* @param sourceUris ETP general map : One each for each source dataobject to be copied. They are identified by their URI.
19961996
* @param targetDataspaceUri The URI of the ETP dataspace where the source dataobjects have to be copied by reference.
@@ -2005,7 +2005,7 @@ namespace ETP_NS
20052005
/**
20062006
* A Customer sends this message to a store to discover data objects in the store.
20072007
* This function should be used with caution if Discovery Handlers have been overidden.
2008-
* It actually sends a message and block the current thread untill a response has been received from the store.
2008+
* It actually sends a message and block the current thread until a response has been received from the store.
20092009
*
20102010
* @param context Includes the URI of the dataspace or data object to begin the discovery, what specific types of data objects are of interest,
20112011
* and how many "levels" of relationships in the model to discover, among others.
@@ -2026,7 +2026,7 @@ namespace ETP_NS
20262026
/**
20272027
* A customer sends to a store to discover data objects that have been deleted (which are sometimes called "tombstones").
20282028
* This function should be used with caution if Discovery Handlers have been overidden.
2029-
* It actually sends a message and block the current thread untill a response has been received from the store.
2029+
* It actually sends a message and block the current thread until a response has been received from the store.
20302030
*
20312031
* @param dataspaceUri The URI of the dataspace where the objects were deleted.
20322032
* @param deleteTimeFilter An optional filter to filter the discovery on a date when the data object was deleted in a particular store.
@@ -2047,7 +2047,7 @@ namespace ETP_NS
20472047
/**
20482048
* A customer sends to a store to get one or more data objects, each identified by a URI.
20492049
* This function should be used with caution if Store Handlers have been overidden.
2050-
* It actually sends a message and block the current thread untill a response has been received from the store.
2050+
* It actually sends a message and block the current thread until a response has been received from the store.
20512051
*
20522052
* @param uris ETP general map where the values MUST be the URIs of a data object to be retrieved.
20532053
* @param return The received dataobjects in a map where the key makes the link between the asked uris and the received dataobjects.
@@ -2057,7 +2057,7 @@ namespace ETP_NS
20572057
/**
20582058
* A customer sends to a store to add or update one or more data objects.
20592059
* This function should be used with caution if Store Handlers have been overidden.
2060-
* It actually sends a message and block the current thread untill a response has been received from the store.
2060+
* It actually sends a message and block the current thread until a response has been received from the store.
20612061
*
20622062
* @param uris ETP general map where the values MUST be the data for each data object in the request, including each one's URI.
20632063
* @param return The map keys corresponding to the dataObjects which have been put successfully.
@@ -2067,7 +2067,7 @@ namespace ETP_NS
20672067
/**
20682068
* A customer sends to a store to delete one or more data objects from the store.
20692069
* This function should be used with caution if Store Handlers have been overidden.
2070-
* It actually sends a message and block the current thread untill a response has been received from the store.
2070+
* It actually sends a message and block the current thread until a response has been received from the store.
20712071
*
20722072
* @param uris ETP general map where the values MUST be the URIs of a data object to be deleted.
20732073
* @param return The map keys corresponding to the dataObjects which have been deleted successfully.
@@ -2081,26 +2081,29 @@ namespace ETP_NS
20812081
/**
20822082
* A customer sends to a store to begin a transaction.
20832083
* This function should be used with caution if Transaction Handlers have been overidden.
2084-
* It actually sends a message and block the current thread untill a response has been received from the store.
2084+
* It actually sends a message and block the current thread until a response has been received from the store.
20852085
*
20862086
* @param dataspaceUris Indicates the dataspaces involved in the transaction. An empty STRING means the default dataspace. An empty LIST means all dataspaces.
2087-
* @param readOnly Indicates that the request in the transaction is read-only (i.e., "get" messages).
2087+
* @param readOnly Indicates that the request in the transaction is read-only (i.e., "get" messages).
2088+
* @return Failure message or empty string if success
20882089
*/
20892090
std::string startTransaction(std::vector<std::string> dataspaceUris = {}, bool readOnly = false);
20902091

20912092
/**
20922093
* A customer sends to a store to commit and end a transaction. This message implies that the customer
20932094
* has received from or sent to the store all the data required for some purpose. The customer asserts that
20942095
* the data sent in the scope of this transaction is a consistent unit of work.
2095-
* It actually sends a message and block the current thread untill a response has been received from the store.
2096+
* It actually sends a message and block the current thread until a response has been received from the store.
2097+
* @return Failure message or empty string if success
20962098
*/
20972099
std::string rollbackTransaction();
20982100

20992101
/*
21002102
* A customer sends to a store to cancel a transaction. The store MUST disregard any requests or data sent
21012103
* with that transaction. The current transaction (the one being canceled) MUST NOT change the state of
21022104
* the store.
2103-
* It actually sends a message and block the current thread untill a response has been received from the store.
2105+
* It actually sends a message and block the current thread until a response has been received from the store.
2106+
* @return Failure message or empty string if success
21042107
*/
21052108
std::string commitTransaction();
21062109

python/example/PutHorizon.ipynb

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"id": "a16222c5-064e-431d-9dae-d3d6c535a6b9",
1414
"metadata": {},
1515
"source": [
16-
"Once FETPAPI wheel installed, you need to first import FESAPI (required dependency) and then fetpapi it in order to be able to call its API."
16+
"Once FETPAPI wheel installed, you need to first import FESAPI (required dependency) and then fetpapi in order to be able to call its API."
1717
]
1818
},
1919
{
@@ -176,7 +176,7 @@
176176
"if (len(successKeys) == 1):\n",
177177
" print(\"Dataspace has been put\")\n",
178178
"else:\n",
179-
" print(\"Error when putting dataspace\")"
179+
" print(\"Error when putting dataspace. Already present?\")"
180180
]
181181
},
182182
{
@@ -203,7 +203,7 @@
203203
" fesapi.eml20__LengthUom_m, \"Unknown\",\n",
204204
" False)\n",
205205
"repo.setDefaultCrs(local_3d_crs)\n",
206-
"repo.setHdfProxyFactory(fetpapi.FesapiHdfProxyFactory(client_session));\n",
206+
"repo.setHdfProxyFactory(fetpapi.FesapiHdfProxyFactory(client_session))\n",
207207
"hdf_proxy = repo.createHdfProxy(\"f8160b8f-0517-4c55-ab6e-ed8bcdc87111\", \"Hdf Proxy\",\n",
208208
" \".\", \"fake.h5\",\n",
209209
" fesapi.DataObjectRepository.openingMode_OVERWRITE)\n",
@@ -233,7 +233,9 @@
233233
"# Create first a transaction in order to be able to rollback if necessary and to easier resolve dependencies to put\n",
234234
"dataspacesToLock = fetpapi.StringVector()\n",
235235
"dataspacesToLock.append(dataspace.uri)\n",
236-
"client_session.startTransaction(dataspacesToLock)\n",
236+
"transactionFailure = client_session.startTransaction(dataspacesToLock)\n",
237+
"if (transactionFailure):\n",
238+
" print (transactionFailure)\n",
237239
"# And let's set a 2x3 geometry on this 2d grid where the Z values equal hundred times the node index.\n",
238240
"# The first (aka I) axis of this 2d grid is aligned on X and the second (aka J) axis of this 2d grid is aligned on Y.\n",
239241
"# The spacing on the first axis between two node is 25m and the spacing on the second axis between two node is 50m\n",
@@ -266,9 +268,13 @@
266268
"allUuids = repo.getUuids()\n",
267269
"for i, uuid in enumerate(allUuids):\n",
268270
" dataobjects[str(i)] = fetpapi.buildEtpDataObjectFromEnergisticsObject(repo, uuid)\n",
269-
"client_session.putDataObjects(dataobjects)\n",
270-
"# Finally commit the tansaction now that we have put everything we wanted\n",
271-
"client_session.commitTransaction()"
271+
"successKeys = client_session.putDataObjects(dataobjects)\n",
272+
"#for successKey in successKeys:\n",
273+
"# print(successKey)\n",
274+
"# Finally commit the transaction now that we have put everything we wanted\n",
275+
"transactionFailure = client_session.commitTransaction()\n",
276+
"if (transactionFailure):\n",
277+
" print (transactionFailure)"
272278
]
273279
},
274280
{
@@ -286,7 +292,8 @@
286292
"metadata": {},
287293
"outputs": [],
288294
"source": [
289-
"client_session.close();"
295+
"repo.clear()\n",
296+
"client_session.close()"
290297
]
291298
}
292299
],

python/example/etp_client_example.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ def start_etp_server(client_session):
1818
additionalHeaderField["data-partition-id"] = "osdu"
1919
initialization_params.setAdditionalHandshakeHeaderFields(additionalHeaderField)
2020

21+
print("Creating the session...")
2122
client_session = fetpapi.createClientSession(initialization_params, authorization)
2223
t = Thread(target=start_etp_server, args=(client_session,), daemon=True)
24+
print("Trying to connect to " + etp_server_url + " ...")
2325
t.start()
2426
start_time = perf_counter()
2527
while client_session.isEtpSessionClosed() and perf_counter() - start_time < 5:
26-
sleep(0.25)
28+
sleep(0.25)
29+
print("Trying to connect to " + etp_server_url + " ...")
2730
if client_session.isEtpSessionClosed():
2831
print("The ETP session could not be established in 5 seconds.")
2932
sys.exit()
@@ -59,7 +62,6 @@ def start_etp_server(client_session):
5962
hdf_proxy_factory = fetpapi.FesapiHdfProxyFactory(client_session)
6063
print("Set specialized HdfProxy to deal with ETP DataArray subprotocol")
6164
repo.setHdfProxyFactory(hdf_proxy_factory)
62-
print(type(hdf_proxy_factory))
6365

6466
print("Get dataobjects from the resources to the DataObjectRepository");
6567
uriMap = fetpapi.MapStringString();
@@ -102,7 +104,6 @@ def start_etp_server(client_session):
102104
else:
103105
print("This dataspace has no 2d Grid")
104106

105-
print(type(hdf_proxy_factory))
106107
repo.clear()
107108
client_session.close()
108109
print("FINISHED")

python/example/fetpapi.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"id": "a16222c5-064e-431d-9dae-d3d6c535a6b9",
1414
"metadata": {},
1515
"source": [
16-
"Once FETPAPI wheel installed, you need to first import FESAPI (required dependency) and then fetpapi it in order to be able to call its API."
16+
"Once FETPAPI wheel installed, you need to first import FESAPI (required dependency) and then fetpapi in order to be able to call its API."
1717
]
1818
},
1919
{
@@ -198,7 +198,7 @@
198198
"metadata": {},
199199
"outputs": [],
200200
"source": [
201-
"client_session.close();"
201+
"client_session.close()"
202202
]
203203
}
204204
],

src/etp/AbstractSession.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ std::vector<std::string> AbstractSession::putDataObjects(const std::map<std::str
379379

380380
if (messageSize + dataObjectSize > maxWebSocketMessagePayloadSize) {
381381
const int64_t sentMessageId = send(msg, correlationId);
382-
result.insert(result.end(), handlers->getSuccessKeys().begin(), handlers->getSuccessKeys().end());
382+
auto successKeys = handlers->getSuccessKeys();
383+
result.insert(result.end(), successKeys.begin(), successKeys.end());
383384
handlers->clearSuccessKeys();
384385

385386
msg.dataObjects.clear();
@@ -393,7 +394,8 @@ std::vector<std::string> AbstractSession::putDataObjects(const std::map<std::str
393394
++it;
394395
}
395396
sendAndBlock(msg, correlationId, 0x02);
396-
result.insert(result.end(), handlers->getSuccessKeys().begin(), handlers->getSuccessKeys().end());
397+
auto successKeys = handlers->getSuccessKeys();
398+
result.insert(result.end(), successKeys.begin(), successKeys.end());
397399
handlers->clearSuccessKeys();
398400
return result;
399401
}

0 commit comments

Comments
 (0)