uranusjr commented on code in PR #76967:
URL: https://github.com/apache/airflow/pull/76967#discussion_r4677540405
##########
go-sdk/pkg/execution/task_runner.go:
##########
@@ -211,6 +220,35 @@ func convertArgBindings(specsPtr *genmodels.ArgBindings)
([]binding.Arg, error)
return args, nil
}
+func errMappedTaskNotImplemented(i int, name, what string) error {
+ return fmt.Errorf(
+ "arg_bindings[%d] (%q): %s needs mapped task support, which
this version of the Go SDK "+
+ "does not implement; version 1.1.0 will add it",
+ i,
+ name,
+ what,
+ )
+}
+
+// unsupportedBindingFields resolve an argument per map index, which this SDK
does not do yet.
+// A literal never carries map_index or element_index, so one list serves both
kinds.
Review Comment:
The first sentence is not strictly accurate. The second is not needed at all.
##########
go-sdk/pkg/execution/task_runner.go:
##########
@@ -176,7 +176,16 @@ func convertArgBindings(specsPtr *genmodels.ArgBindings)
([]binding.Arg, error)
if err != nil {
return nil, fmt.Errorf("arg_bindings[%d] (%q): %w", i,
name, err)
}
- switch kind, _ := m["kind"].(string); kind {
+ kind, _ := m["kind"].(string)
+ if kind == "sequence" || kind == "tuple" {
+ return nil, errMappedTaskNotImplemented(i, name,
fmt.Sprintf("binding kind %q", kind))
+ }
+ if kind == "xcom" || kind == "literal" {
+ if field := findUnsupportedBindingField(m); field != ""
{
+ return nil, errMappedTaskNotImplemented(i,
name, field)
+ }
+ }
Review Comment:
Each new field or kind means editing this. Validate against the set of keys
this SDK binds and refuse any other key with a non-null, non-false value. Then
a future field fails here instead of being silently dropped. Same for TS and
Java below.
##########
java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/execution/ArgBinding.kt:
##########
@@ -88,3 +95,16 @@ internal fun decodeArgBindings(raw: Any?): List<ArgBinding> {
}
}
}
+
+/**
+ * Fields that resolve an argument per map index in a way this SDK does not
+ * support yet; ignoring one would bind the argument to the wrong value.
+ */
+private val UNSUPPORTED_FIELDS = listOf("apply_map", "kwarg", "fallback")
Review Comment:
This leaves out map_index and element_index because Client honors them. It’s
not wrong, but the different implementation between this and Go/TS is awkward.
##########
go-sdk/pkg/execution/task_runner.go:
##########
@@ -211,6 +220,35 @@ func convertArgBindings(specsPtr *genmodels.ArgBindings)
([]binding.Arg, error)
return args, nil
}
+func errMappedTaskNotImplemented(i int, name, what string) error {
+ return fmt.Errorf(
+ "arg_bindings[%d] (%q): %s needs mapped task support, which
this version of the Go SDK "+
+ "does not implement; version 1.1.0 will add it",
Review Comment:
This doesn’t really make sense for the user seeing the message IMO. If 1.1.0
is not released yet, the message is useless; if it is, and the user is looking
for the feature, they will upgrade without this message. (Also “will” would
simply be the wrong tense at that point.) It can just say the feature is not
available in the current version.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]