Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions scripts/gen_protos.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
re.compile(r"'__module__' : 'temporal\.api\.").sub,
r"'__module__' : 'temporalio.api.",
),
partial(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replacement didn't seem to be needed for me, do we know what it's about?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't happen for the other dependency, protoc_gen_openapiv2

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might not be needed, I just followed the pattern for the other replacements w/ the new module name

re.compile(r"'__module__' : 'nexusannotations\.").sub,
r"'__module__' : 'temporalio.api.dependencies.nexusannotations.",
),
]

pyi_fixes = [
Expand Down Expand Up @@ -201,10 +205,11 @@ def generate_protos(output_dir: Path):
fix_generated_output(output_dir)
# Move dependency protos
deps_out_dir = api_out_dir / "dependencies"
shutil.rmtree(deps_out_dir / "protoc_gen_openapiv2", ignore_errors=True)
shutil.rmtree(deps_out_dir / "nexusannotations", ignore_errors=True)
deps_out_dir.mkdir(exist_ok=True)
for dep in ["protoc_gen_openapiv2", "nexusannotations"]:
shutil.rmtree(deps_out_dir / dep, ignore_errors=True)
(output_dir / dep).replace(deps_out_dir / dep)
(output_dir / "protoc_gen_openapiv2").replace(deps_out_dir / "protoc_gen_openapiv2")
(output_dir / "nexusannotations").replace(deps_out_dir / "nexusannotations")
(deps_out_dir / "__init__.py").touch()
# Move protos
for p in (output_dir / "temporal" / "api").iterdir():
Expand Down
22 changes: 17 additions & 5 deletions scripts/gen_protos_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,28 @@
)
image_id = result.stdout.strip()

subprocess.run(
docker_run_command = [
Comment thread
tconley1428 marked this conversation as resolved.
"docker",
"run",
"--rm",
]

getuid = getattr(os, "getuid", None)
getgid = getattr(os, "getgid", None)
if callable(getuid) and callable(getgid):
docker_run_command.extend(["--user", f"{getuid()}:{getgid()}"])

docker_run_command.extend(
[
"docker",
"run",
"--rm",
"-v",
os.path.join(os.getcwd(), "temporalio", "api") + ":/api_new",
"-v",
os.path.join(os.getcwd(), "temporalio", "bridge", "proto") + ":/bridge_new",
image_id,
],
]
)

subprocess.run(
docker_run_command,
check=True,
)

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 36 additions & 37 deletions temporalio/bridge/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions temporalio/bridge/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class ClientConfig:
client_version: str
http_connect_proxy_config: ClientHttpConnectProxyConfig | None
dns_load_balancing_config: ClientDnsLoadBalancingConfig | None
grpc_compression: str


@dataclass
Expand Down
14 changes: 13 additions & 1 deletion temporalio/bridge/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use temporalio_client::tonic::{
};
use temporalio_client::{
ClientKeepAliveOptions as CoreClientKeepAliveConfig, Connection, ConnectionOptions,
DnsLoadBalancingOptions, HttpConnectProxyOptions, RetryOptions,
DnsLoadBalancingOptions, GrpcCompression, HttpConnectProxyOptions, RetryOptions,
};
use tracing::warn;
use url::Url;
Expand Down Expand Up @@ -37,6 +37,7 @@ pub struct ClientConfig {
keep_alive_config: Option<ClientKeepAliveConfig>,
http_connect_proxy_config: Option<ClientHttpConnectProxyConfig>,
dns_load_balancing_config: Option<ClientDnsLoadBalancingConfig>,
grpc_compression: String,
}

#[derive(FromPyObject)]
Expand Down Expand Up @@ -266,6 +267,7 @@ impl ClientConfig {
.keep_alive(self.keep_alive_config.map(Into::into))
.maybe_http_connect_proxy(self.http_connect_proxy_config.map(Into::into))
.dns_load_balancing(dns_load_balancing)
.grpc_compression(grpc_compression_from_str(&self.grpc_compression)?)
.headers(ascii_headers)
.binary_headers(binary_headers)
.maybe_api_key(self.api_key)
Expand All @@ -279,6 +281,16 @@ impl ClientConfig {
}
}

fn grpc_compression_from_str(value: &str) -> PyResult<GrpcCompression> {
match value {
"none" => Ok(GrpcCompression::None),
"gzip" => Ok(GrpcCompression::Gzip),
_ => Err(PyValueError::new_err(format!(
"invalid grpc_compression: {value}"
))),
}
}

impl TryFrom<ClientTlsConfig> for temporalio_client::TlsOptions {
type Error = PyErr;

Expand Down
2 changes: 2 additions & 0 deletions temporalio/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from temporalio.service import (
ConnectConfig,
DnsLoadBalancingConfig,
GrpcCompression,
HttpConnectProxyConfig,
KeepAliveConfig,
RetryConfig,
Expand Down Expand Up @@ -355,6 +356,7 @@
"WorkflowSerializationContext",
"ConnectConfig",
"DnsLoadBalancingConfig",
"GrpcCompression",
"HttpConnectProxyConfig",
"KeepAliveConfig",
"RetryConfig",
Expand Down
Loading
Loading