Skip to content

Commit 8616046

Browse files
committed
remove test log statement. Reorder gen_bridge_client.py
1 parent ea5d905 commit 8616046

File tree

2 files changed

+38
-40
lines changed

2 files changed

+38
-40
lines changed

scripts/gen_bridge_client.py

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,37 @@
1414
import temporalio.bridge.proto.health.v1.health_pb2 as health_service
1515

1616

17-
def generate_match_arm(trait_name: str, method: MethodDescriptor) -> str:
18-
match_template = Template("""\
19-
"$method_name" => {
20-
rpc_call!(retry_client, call, $trait_name, $method_name)
21-
}""")
17+
def generate_client_impl(
18+
file_descriptors: list[FileDescriptor],
19+
output_file: str = "temporalio/bridge/src/client_rpc_generated.rs",
20+
):
21+
print("generating bridge rpc calls")
2222

23-
return match_template.substitute(
24-
method_name=pascal_to_snake(method.name), trait_name=trait_name
25-
)
23+
service_calls = [
24+
generate_service_call(service_descriptor)
25+
for file_descriptor in file_descriptors
26+
for service_descriptor in file_descriptor.services_by_name.values()
27+
]
28+
29+
impl_template = Template("""// Generated file. DO NOT EDIT
30+
31+
use pyo3::exceptions::PyValueError;
32+
use pyo3::prelude::*;
33+
34+
use super::{
35+
client::{rpc_req, rpc_resp, ClientRef, RpcCall},
36+
rpc_call,
37+
};
38+
39+
#[pymethods]
40+
impl ClientRef {
41+
$service_calls
42+
}""")
43+
44+
with open(output_file, "w") as f:
45+
f.write(impl_template.substitute(service_calls="\n".join(service_calls)))
46+
47+
print(f"successfully generated client at {output_file}")
2648

2749

2850
def generate_service_call(service_descriptor: ServiceDescriptor) -> str:
@@ -75,37 +97,15 @@ def generate_service_call(service_descriptor: ServiceDescriptor) -> str:
7597
)
7698

7799

78-
def generate_client_impl(
79-
file_descriptors: list[FileDescriptor],
80-
output_file: str = "temporalio/bridge/src/client_rpc_generated.rs",
81-
):
82-
print("generating bridge rpc calls")
83-
84-
service_calls = [
85-
generate_service_call(service_descriptor)
86-
for file_descriptor in file_descriptors
87-
for service_descriptor in file_descriptor.services_by_name.values()
88-
]
89-
90-
impl_template = Template("""// Generated file. DO NOT EDIT
91-
92-
use pyo3::exceptions::PyValueError;
93-
use pyo3::prelude::*;
94-
95-
use super::{
96-
client::{rpc_req, rpc_resp, ClientRef, RpcCall},
97-
rpc_call,
98-
};
99-
100-
#[pymethods]
101-
impl ClientRef {
102-
$service_calls
103-
}""")
104-
105-
with open(output_file, "w") as f:
106-
f.write(impl_template.substitute(service_calls="\n".join(service_calls)))
100+
def generate_match_arm(trait_name: str, method: MethodDescriptor) -> str:
101+
match_template = Template("""\
102+
"$method_name" => {
103+
rpc_call!(retry_client, call, $trait_name, $method_name)
104+
}""")
107105

108-
print(f"successfully generated client at {output_file}")
106+
return match_template.substitute(
107+
method_name=pascal_to_snake(method.name), trait_name=trait_name
108+
)
109109

110110

111111
def pascal_to_snake(input: str) -> str:

temporalio/bridge/client.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ async def call(
132132
timeout_millis = round(timeout.total_seconds() * 1000) if timeout else None
133133
call = RpcCall(rpc, req.SerializeToString(), retry, metadata, timeout_millis)
134134

135-
print(f"calling rpc '{rpc}'")
136-
137135
# Do call (this throws an RPCError on failure)
138136
if service == "workflow":
139137
resp_fut = self._ref.call_workflow_service(call)

0 commit comments

Comments
 (0)