Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ public final class SmithyPythonDependency {
Type.DEPENDENCY,
false);

/**
* The awscrt package.
*/
public static final PythonDependency AWS_CRT = new PythonDependency(
"awscrt",
">=0.23.10",
Type.DEPENDENCY,
false);

/**
* The aiohttp package.
*/
public static final PythonDependency AIO_HTTP = new PythonDependency(
"aiohttp",
"~=3",
Type.DEPENDENCY,
false);

/**
* The core smithy-json python package.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,17 @@ private static List<ConfigProperty> getHttpProperties(GenerationContext context)
if (usesHttp2(context)) {
clientBuilder
.initialize(writer -> {
writer.addDependency(SmithyPythonDependency.SMITHY_HTTP.withOptionalDependencies("awscrt"));
writer.addDependency(SmithyPythonDependency.SMITHY_HTTP);
writer.addDependency(SmithyPythonDependency.AWS_CRT);
writer.addImport("smithy_http.aio.crt", "AWSCRTHTTPClient");
writer.write("self.http_client = http_client or AWSCRTHTTPClient()");
});

} else {
clientBuilder
.initialize(writer -> {
writer.addDependency(SmithyPythonDependency.SMITHY_HTTP.withOptionalDependencies("aiohttp"));
writer.addDependency(SmithyPythonDependency.SMITHY_HTTP);
writer.addDependency(SmithyPythonDependency.AIO_HTTP);
Comment on lines +150 to +151
Copy link
Contributor

@nateprewitt nateprewitt Mar 6, 2025

Choose a reason for hiding this comment

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

rereading this, I think this is slightly incorrect, but assuming the other conditional triggers now, it isn't a hard blocker.

What we want this to look like eventually is:

smithy-http[awscrt]
or
smithy-http[aiohttp]

where the http client version is declared in smithy-http and we're not taking additional dependencies. I think we can track that as follow up work, I'm not sure .withOptionalDependencies("aiohttp") was actually working before.

writer.addImport("smithy_http.aio.aiohttp", "AIOHTTPClient");
writer.write("self.http_client = http_client or AIOHTTPClient()");
});
Expand All @@ -171,11 +173,12 @@ private static boolean usesHttp2(GenerationContext context) {
return true;
}

// Bidirectional streaming REQUIRES h2 inherently
// enable CRT/http2 client if the service supports any event streams (single or bi-directional)
// TODO: Long term, only bi-directional evenstreams strictly require h2
var eventIndex = EventStreamIndex.of(context.model());
var topDownIndex = TopDownIndex.of(context.model());
for (OperationShape operation : topDownIndex.getContainedOperations(context.settings().service())) {
if (eventIndex.getInputInfo(operation).isPresent() && eventIndex.getOutputInfo(operation).isPresent()) {
if (eventIndex.getInputInfo(operation).isPresent() || eventIndex.getOutputInfo(operation).isPresent()) {
return true;
}
}
Expand Down
Loading