Skip to content

Commit 6b723c6

Browse files
author
Matthias Zimmermann
committed
enhance test_parallel_entity_creation
1 parent 815460a commit 6b723c6

File tree

4 files changed

+419
-76
lines changed

4 files changed

+419
-76
lines changed

.env.testing

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,10 @@ WALLET_PASSWORD_17=s3cret
4747
WALLET_PASSWORD_18=s3cret
4848
WALLET_PASSWORD_19=s3cret
4949
WALLET_PASSWORD_20=s3cret
50+
51+
# Parallel operations configuration
52+
# E.g. test_entity_create_parallel.py
53+
NUM_CLIENTS = 20
54+
NUM_TX = 10
55+
BATCH_SIZE = 100
56+
VERIFY_SAMPLE_SIZE = 5

src/arkiv/module.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def execute(
8282
receipt: TransactionReceipt = to_receipt(
8383
client.arkiv.contract, tx_hash, tx_receipt
8484
)
85-
logger.info(f"Arkiv receipt: {receipt}")
85+
logger.debug(f"Arkiv receipt: {receipt}")
8686
return receipt
8787

8888
def create_entity(
@@ -179,23 +179,26 @@ def get_entity(self, entity_key: EntityKey, fields: int = ALL) -> Entity:
179179

180180
# HINT: rpc methods to fetch entity content might change this is the place to adapt
181181
# get and decode payload if requested
182-
if fields & PAYLOAD:
183-
payload = self._get_storage_value(entity_key)
184-
185-
# get and decode annotations and/or metadata if requested
186-
if fields & METADATA or fields & ANNOTATIONS:
187-
metadata_all = self._get_entity_metadata(entity_key)
188-
189-
if fields & METADATA:
190-
# Convert owner address to checksummed format
191-
owner = self._get_owner(metadata_all)
192-
expires_at_block = self._get_expires_at_block(metadata_all)
193-
194-
if fields & ANNOTATIONS:
195-
annotations = merge_annotations(
196-
string_annotations=metadata_all.get("stringAnnotations", []),
197-
numeric_annotations=metadata_all.get("numericAnnotations", []),
198-
)
182+
try:
183+
if fields & PAYLOAD:
184+
payload = self._get_storage_value(entity_key)
185+
186+
# get and decode annotations and/or metadata if requested
187+
if fields & METADATA or fields & ANNOTATIONS:
188+
metadata_all = self._get_entity_metadata(entity_key)
189+
190+
if fields & METADATA:
191+
# Convert owner address to checksummed format
192+
owner = self._get_owner(metadata_all)
193+
expires_at_block = self._get_expires_at_block(metadata_all)
194+
195+
if fields & ANNOTATIONS:
196+
annotations = merge_annotations(
197+
string_annotations=metadata_all.get("stringAnnotations", []),
198+
numeric_annotations=metadata_all.get("numericAnnotations", []),
199+
)
200+
except Exception as e:
201+
logger.warning(f"Error fetching entity[{entity_key}]: {e}")
199202

200203
# Create and return entity
201204
return Entity(

src/arkiv/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def merge_annotations(
301301
if string_annotations:
302302
# example: [AttributeDict({'key': 'type', 'value': 'Greeting'})]
303303
for element in string_annotations:
304-
logger.info(f"String annotation element: {element}")
304+
logger.debug(f"String annotation element: {element}")
305305
if isinstance(element.value, str):
306306
annotations[element.key] = element.value
307307
else:
@@ -312,7 +312,7 @@ def merge_annotations(
312312
if numeric_annotations:
313313
# example: [AttributeDict({'key': 'version', 'value': 1})]
314314
for element in numeric_annotations:
315-
logger.info(f"Numeric annotation element: {element}")
315+
logger.debug(f"Numeric annotation element: {element}")
316316
if isinstance(element.value, int):
317317
annotations[element.key] = element.value
318318
else:

0 commit comments

Comments
 (0)