Skip to content

Commit c78fc9a

Browse files
authored
Merge pull request #23051: Fixes RunInference test failure
2 parents de35279 + 62dd4b4 commit c78fc9a

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

sdks/java/extensions/python/src/main/java/org/apache/beam/sdk/extensions/python/PythonExternalTransform.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ public PythonExternalTransform<InputT, OutputT> withOutputCoder(Coder<?> outputC
286286
* @return updated wrapper for the cross-language transform.
287287
*/
288288
public PythonExternalTransform<InputT, OutputT> withExtraPackages(List<String> extraPackages) {
289+
if (extraPackages.isEmpty()) {
290+
return this;
291+
}
289292
Preconditions.checkState(
290293
Strings.isNullOrEmpty(expansionService),
291294
"Extra packages only apply to auto-started expansion service.");

sdks/java/extensions/python/src/main/java/org/apache/beam/sdk/extensions/python/transforms/RunInference.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ public RunInference<OutputT> withKwarg(String key, Object arg) {
130130
/**
131131
* Specifies any extra Pypi packages required by the RunInference model handler.
132132
*
133+
* <p>This should only be specified when using the default expansion service, i.e. when not using
134+
* {@link #withExpansionService(String)} to provide an expansion service.
135+
*
133136
* <p>For model handlers provided by Beam Python SDK, the implementation will automatically try to
134137
* infer correct packages needed, so this may be omitted.
135138
*
@@ -192,7 +195,7 @@ public PCollection<OutputT> expand(PCollection<?> input) {
192195
outputCoder = (Coder<OutputT>) KvCoder.of(keyCoder, RowCoder.of(schema));
193196
}
194197

195-
if (this.extraPackages.isEmpty()) {
198+
if (this.expansionService.isEmpty() && this.extraPackages.isEmpty()) {
196199
this.extraPackages.addAll(inferExtraPackagesFromModelHandler());
197200
}
198201

0 commit comments

Comments
 (0)