batch_ops#
Batch RPC service.
Classes:
|
Provides for executing operations in batch in CFX. |
|
Provides class wrapping methods in the batch RPC service. |
- class ansys.cfx.core.services.batch_ops.BatchOps(session)#
Bases:
objectProvides for executing operations in batch in CFX.
Examples
>>> import ansys.cfx.core as pycfx >>> pypost = pycfx.PostProcessing.from_install() >>> with pycfx.BatchOps(pypost): ... pypost.file.load_results(file_name=<results_name>) ... pypost.results.plane["Plane 1"] = {}
The preceding code executes both operations through a single gRPC call upon exiting the
withblock.Operations that perform queries in CFX are executed immediately, while others are queued for batch execution. Some queries are executed behind the scenes while queuing an operation for batch execution. Developers must ensure that they do not depend on previously queued operations.
For example, the following code throws a
KeyErroraspypost.results.plane["Plane 1"]attempts to access thePlane 1named object which has not been created yet.>>> pypost = pycfx.PostProcessing.from_install() >>> with pycfx.BatchOps(pypost): ... pypost.file.load_results(file_name="StaticMixer_001.res") ... pypost.results.plane["Plane 1"] = {} ... pypost.results.plane["Plane 1"].option = "ZX Plane" Traceback (most recent call last): ... KeyError: "'plane' has no attribute 'Plane 1'.\n"
Classes:
Op(package, service, method, request_body)Provides for creating a single batch operation.
Methods:
add_op(package, service, method, request)Queue a single batch operation.
Clear all queued batch operations.
instance()Get the
BatchOpsinstance.- class Op(package: str, service: str, method: str, request_body: bytes)#
Bases:
objectProvides for creating a single batch operation.
Methods:
__init__(package, service, method, request_body)Initialize an instance of the
Opclass.update_result(status, data)Update results after the batch operation is executed.
- class ansys.cfx.core.services.batch_ops.BatchOpsService(channel: Channel, metadata: list[tuple[str, str]])#
Bases:
objectProvides class wrapping methods in the batch RPC service.
Methods:
__init__(channel, metadata)Initialize an instance of the
BatchOpsServiceclass.execute(request)Execute RPC of the
BatchOpsservice.- __init__(channel: Channel, metadata: list[tuple[str, str]]) None#
Initialize an instance of the
BatchOpsServiceclass.
- execute(request: ExecuteRequest) ExecuteResponse#
Execute RPC of the
BatchOpsservice.