-
Notifications
You must be signed in to change notification settings - Fork 14.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove execution_date and logical_date from arguments in api_connexion #43678
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -63,7 +63,7 @@ class Meta: | |||
|
||||
run_id = auto_field(data_key="dag_run_id") | ||||
dag_id = auto_field(dump_only=True) | ||||
execution_date = auto_field(data_key="logical_date", validate=validate_istimezone) | ||||
logical_date = auto_field(data_key="logical_date", validate=validate_istimezone) | ||||
start_date = auto_field(dump_only=True) | ||||
end_date = auto_field(dump_only=True) | ||||
state = DagStateField(dump_only=True) | ||||
|
@@ -81,22 +81,14 @@ def autogenerate(self, data, **kwargs): | |||
""" | ||||
Auto generate run_id and logical_date if they are not provided. | ||||
|
||||
For compatibility, if `execution_date` is submitted, it is converted | ||||
For compatibility, if `logical_date` is submitted, it is converted | ||||
to `logical_date`. | ||||
""" | ||||
logical_date = data.get("logical_date", _MISSING) | ||||
execution_date = data.pop("execution_date", _MISSING) | ||||
if logical_date is execution_date is _MISSING: # Both missing. | ||||
|
||||
# Auto-generate logical_date if missing | ||||
if logical_date is _MISSING: | ||||
data["logical_date"] = str(timezone.utcnow()) | ||||
elif logical_date is _MISSING: # Only logical_date missing. | ||||
data["logical_date"] = execution_date | ||||
elif execution_date is _MISSING: # Only execution_date missing. | ||||
pass | ||||
elif logical_date != execution_date: # Both provided but don't match. | ||||
raise BadRequest( | ||||
"logical_date conflicts with execution_date", | ||||
detail=f"{logical_date!r} != {execution_date!r}", | ||||
) | ||||
|
||||
if "dag_run_id" not in data: | ||||
try: | ||||
|
@@ -109,9 +101,9 @@ def autogenerate(self, data, **kwargs): | |||
|
||||
@post_dump | ||||
def autofill(self, data, **kwargs): | ||||
"""Populate execution_date from logical_date for compatibility.""" | ||||
"""Populate logical_date from logical_date for compatibility.""" | ||||
ret_data = {} | ||||
data["execution_date"] = data["logical_date"] | ||||
data["logical_date"] = data["logical_date"] | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think we probably don't need this line? |
||||
if self.context.get("fields"): | ||||
ret_fields = self.context.get("fields") | ||||
for ret_field in ret_fields: | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ class Meta: | |
dag_id = auto_field() | ||
run_id = auto_field(data_key="dag_run_id") | ||
map_index = auto_field() | ||
execution_date = auto_field() | ||
logical_date = auto_field() | ||
start_date = auto_field() | ||
end_date = auto_field() | ||
duration = auto_field() | ||
|
@@ -196,7 +196,7 @@ class SetTaskInstanceStateFormSchema(Schema): | |
|
||
dry_run = fields.Boolean(load_default=True) | ||
task_id = fields.Str(required=True) | ||
execution_date = fields.DateTime(validate=validate_istimezone) | ||
logical_date = fields.DateTime(validate=validate_istimezone) | ||
dag_run_id = fields.Str() | ||
include_upstream = fields.Boolean(required=True) | ||
include_downstream = fields.Boolean(required=True) | ||
|
@@ -212,8 +212,8 @@ class SetTaskInstanceStateFormSchema(Schema): | |
@validates_schema | ||
def validate_form(self, data, **kwargs): | ||
"""Validate set task instance state form.""" | ||
if not exactly_one(data.get("execution_date"), data.get("dag_run_id")): | ||
raise ValidationError("Exactly one of execution_date or dag_run_id must be provided") | ||
if not exactly_one(data.get("logical_date"), data.get("dag_run_id")): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this still needed after the removal in airflow/api_connexion/openapi/v1.yaml |
||
raise ValidationError("Exactly one of logical_date or dag_run_id must be provided") | ||
|
||
|
||
class SetSingleTaskInstanceStateFormSchema(Schema): | ||
|
@@ -234,7 +234,7 @@ class TaskInstanceReferenceSchema(Schema): | |
task_id = fields.Str() | ||
run_id = fields.Str(data_key="dag_run_id") | ||
dag_id = fields.Str() | ||
execution_date = fields.DateTime() | ||
logical_date = fields.DateTime() | ||
|
||
|
||
class TaskInstanceReferenceCollection(NamedTuple): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,7 +285,7 @@ def stats_tags(self) -> dict[str, str]: | |
return prune_dict({"dag_id": self.dag_id, "run_type": self.run_type}) | ||
|
||
@property | ||
def logical_date(self) -> datetime: | ||
def logical_date(self): | ||
return self.execution_date | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is going to be removed in another PR? |
||
|
||
def get_state(self): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to replace it?