henry3260 commented on code in PR #73936:
URL: https://github.com/apache/airflow/pull/73936#discussion_r4143871308
##########
go-sdk/airflow/spec.go:
##########
@@ -17,12 +17,38 @@
package airflow
-// DagSpec holds the attributes of a Dag other than its dag_id. [Dag] takes
one.
-type DagSpec struct{}
+// DagSpec and TaskSpec are generated from Airflow core's Dag serialization
schema,
+// which Python owns, so that neither struct drifts from it silently. genspec
+// rewrites the schema into the authoring shape, go-jsonschema writes the
structs,
+// and genspec puts the license header back on what it wrote. The rewritten
schema
+// is a build artifact under .build; spec.gen.go is committed.
+//
+// To change a field, change the schema on the Python side, or the exclusions,
type
+// overrides and injected properties in internal/genspec/authoring.go, and run
+// `just generate-specs`.
+
+//go:generate go run ../internal/genspec -schema
../../airflow-core/src/airflow/serialization/schema.json -out
../../.build/go-sdk/spec.schema.json
+//go:generate go run github.com/atombender/[email protected] --only-models
--struct-name-from-title --tags json --capitalization ID --capitalization JSON
-p airflow -o spec.gen.go ../../.build/go-sdk/spec.schema.json
Review Comment:
Agreed, and it is worse than it look, the tags are almost right, which is
the trap:
json.Marshal(DagSpec{DagrunTimeout: 5 * time.Minute})
→ {"dagrun_timeout":300000000000} // nanoseconds
schema wants {"dagrun_timeout":300} // seconds
Field names are all correct, so nothing gives it away except a timeout off
by a billion.
I would rather drop the tags than document them. `--tags ""` generates the
structs with no
tags at all (checked, it works), which removes the temptation instead of
warning about it.
That leaves the seconds conversion and `SchemaFields()` for their own PR,
where they can be
tested against core instead of reviewed next to 2k lines of generator. Does
that split work,
or would you rather this PR carried `SchemaFields()`?
--
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]