Tm1Batch
from skipcheck_tm1 import Tm1Batch A JSON $batch being put together, from Tm1Client.batch: calls made
through client are queued rather than sent, and run sends them
together. Each call's result is there once the batch has run. Every service's methods
work through it unchanged. TM1 (11.8) runs the calls in the order they were made, so a
later call sees an earlier one's writes. See Tm1SessionBatch for what else TM1
does with a batch.
Read three things in one round trip:
# Each call is queued as it's made, and has its result once the block has run the batch
with tm1.batch() as batch:
sales = batch.client.cubes.get("Sales")
region = batch.client.dimensions.get("Region")
processes = batch.client.processes.list(ODataQuery.none().select(Process.NAME))
return sales.result(), region.result(), processes.result()
Create many elements in batches of 200, each failure kept to its own element:
# One request per element, 200 to a $batch; one element's failure is its own
batch = tm1.batch()
created = {city: batch.client.elements.create("City", "City", ElementPatch.builder().name(city).build()) for city in cities}
batch.run(200)
results = []
for city, element in created.items():
try:
results.append(element.result().name)
except Tm1Error as e:
results.append(f"{city} failed: {e}")
return results
Members
__init__ constructor | |
client property | The client whose calls join this batch. |
size | How many requests have joined. |
run | Sends the queued calls, at most per_request to each $batch. |
__init__
constructor__init__(batch: Tm1SessionBatch)client
propertyclient: Tm1ClientThe client whose calls join this batch.
size
size() -> intHow many requests have joined.
run
run(per_request: int = AsyncTm1SessionBatch.DEFAULT_PER_REQUEST) -> NoneSends the queued calls, at most per_request to each $batch.