uranusjr commented on code in PR #75267:
URL: https://github.com/apache/airflow/pull/75267#discussion_r4715251507
##########
airflow-core/src/airflow/serialization/serialized_objects.py:
##########
@@ -2178,10 +2178,15 @@ def fill_config_defaults(cls, serialized_obj: dict[str,
Any]) -> None:
):
if key not in dag:
dag[key] = get(section, option)
- if (execution_timeout := conf.gettimedelta("core",
"default_task_execution_timeout")) is not None:
- task_defaults = serialized_obj.setdefault("client_defaults",
{}).setdefault("tasks", {})
- task_defaults.setdefault("execution_timeout",
execution_timeout.total_seconds())
+ task_defaults = OperatorSerialization.generate_client_defaults().copy()
+ if (execution_timeout := conf.gettimedelta("core",
"default_task_execution_timeout")) is None:
+ task_defaults.pop("execution_timeout", None)
+ else:
+ task_defaults["execution_timeout"] =
execution_timeout.total_seconds()
Review Comment:
This repeats `generate_client_defaults()`; `copy()` is only there because
the cached dict gets changed.
##########
go-sdk/airflow/serialize.go:
##########
@@ -234,10 +230,9 @@ var taskSpecRules = specRules{
// from the defaults of Python's TaskGroup instead.
var taskGroupSpecRules = specRules{fields: taskGroupSpecFields}
-// writeSpecFields writes into data each field of spec that rules does not
skip. It leaves out a
-// field that is unset or that holds its schema default. A field is unset when
it holds its zero
-// value. A pointer field is unset only when it is nil, so a pointer field can
set the zero value of
-// the type it points to, such as false or 0.
+// writeSpecFields writes into data each field of spec that rules does not
skip.
+// A field is unset when it holds its zero value. A pointer field is unset
only when nil,
+// so it can explicitly set the zero value of its type, such as false or 0.
Review Comment:
The wording now is a bit too weak; Jason’s was a bit better IMO. Same for
the one in TypeScript serde.
##########
scripts/ci/lang_sdk_serialization/compare.py:
##########
@@ -206,23 +212,24 @@ def compare_fields(
"""
Compare two serialized objects key by key.
- A key the SDK leaves out is fine when Python wrote its schema default.
Python keeps such a value
- when its ``client_defaults`` table disagrees with the schema, a table a
language SDK is never sent,
- and Airflow reads a missing field as its default anyway.
+ A key either side leaves out is fine when the value the other side writes
equals the schema
+ default. Python may omit a value matching its ``client_defaults`` table,
and native SDKs now preserve
Review Comment:
```suggestion
default. Python may omit a value matching its ``client_defaults`` table.
Language SDKs preserve
```
Or use Jason’s suggestion.
##########
go-sdk/airflow/serialize.go:
##########
@@ -306,28 +301,6 @@ func encodeSpecValue(value reflect.Value, set bool) (any,
bool) {
panic(fmt.Sprintf("airflow: the serializer cannot write a spec field of
type %s", value.Type()))
}
-// isSameJSON reports whether two encoded values are the same JSON value. Like
Python, it takes 1
-// and 1.0 for the same number.
-func isSameJSON(a, b any) bool {
- if x, ok := jsonNumber(a); ok {
- y, ok := jsonNumber(b)
- return ok && x == y
- }
- return a == b
-}
-
-func jsonNumber(value any) (float64, bool) {
- switch v := value.(type) {
- case int:
- return float64(v), true
- case float64:
- return v, true
- }
- return 0, false
-}
-
-// encodeTime returns t as Python's serializer writes a datetime: the seconds
since the Unix epoch,
-// to the microsecond. A Python datetime holds nothing finer than a
microsecond.
func encodeTime(t time.Time) float64 { return float64(t.UnixMicro()) / 1e6 }
Review Comment:
Why is the comment deleted?
--
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]