Skip to content

Commit

Permalink
Replace usage of model_construct where not needed (apache#45775)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaxil authored and got686-yandex committed Jan 30, 2025
1 parent 33fe443 commit d520445
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion airflow/executors/workloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def make(cls, ti: TIModel, dag_rel_path: Path | None = None) -> ExecuteTask:
from airflow.utils.helpers import log_filename_template_renderer

ser_ti = TaskInstance.model_validate(ti, from_attributes=True)
bundle_info = BundleInfo.model_construct(
bundle_info = BundleInfo(
name=ti.dag_model.bundle_name,
version=ti.dag_run.bundle_version,
)
Expand Down
2 changes: 1 addition & 1 deletion task_sdk/tests/execution_time/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def _create_task_instance(
id=ti_id, task_id=task.task_id, dag_id=dag_id, run_id=run_id, try_number=try_number
),
dag_rel_path="",
bundle_info=BundleInfo.model_construct(name="anything", version="any"),
bundle_info=BundleInfo(name="anything", version="any"),
requests_fd=0,
ti_context=ti_context,
)
Expand Down
4 changes: 2 additions & 2 deletions task_sdk/tests/execution_time/test_supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def test_run_simple_dag(self, test_dags_dir, captured_logs, time_machine):
run_id="c",
try_number=1,
)
bundle_info = BundleInfo.model_construct(name="my-bundle", version=None)
bundle_info = BundleInfo(name="my-bundle", version=None)
with patch.dict(os.environ, local_dag_bundle_cfg(test_dags_dir, bundle_info.name)):
exit_code = supervise(
ti=ti,
Expand Down Expand Up @@ -323,7 +323,7 @@ def test_supervise_handles_deferred_task(
instant = tz.datetime(2024, 11, 7, 12, 34, 56, 0)
time_machine.move_to(instant, tick=False)

bundle_info = BundleInfo.model_construct(name="my-bundle", version=None)
bundle_info = BundleInfo(name="my-bundle", version=None)
with patch.dict(os.environ, local_dag_bundle_cfg(test_dags_dir, bundle_info.name)):
exit_code = supervise(
ti=ti,
Expand Down
6 changes: 3 additions & 3 deletions task_sdk/tests/execution_time/test_task_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
)
from airflow.utils import timezone

FAKE_BUNDLE = BundleInfo.model_construct(name="anything", version="any")
FAKE_BUNDLE = BundleInfo(name="anything", version="any")


def get_inline_dag(dag_id: str, task: BaseOperator) -> DAG:
Expand Down Expand Up @@ -114,7 +114,7 @@ def test_recv_StartupDetails(self):
assert msg.ti.task_id == "a"
assert msg.ti.dag_id == "c"
assert msg.dag_rel_path == "/dev/null"
assert msg.bundle_info == BundleInfo.model_construct(name="any-name", version="any-version")
assert msg.bundle_info == BundleInfo(name="any-name", version="any-version")

# Since this was a StartupDetails message, the decoder should open the other socket
assert decoder.request_socket is not None
Expand All @@ -127,7 +127,7 @@ def test_parse(test_dags_dir: Path, make_ti_context):
what = StartupDetails(
ti=TaskInstance(id=uuid7(), task_id="a", dag_id="super_basic", run_id="c", try_number=1),
dag_rel_path="super_basic.py",
bundle_info=BundleInfo.model_construct(name="my-bundle", version=None),
bundle_info=BundleInfo(name="my-bundle", version=None),
requests_fd=0,
ti_context=make_ti_context(),
)
Expand Down
2 changes: 1 addition & 1 deletion tests/dag_processing/test_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def fake_collect_dags(self, *args, **kwargs):
spy_agency.spy_on(DagBag.collect_dags, call_fake=fake_collect_dags, owner=DagBag)

requests = [
TaskCallbackRequest.model_construct(
TaskCallbackRequest(
full_filepath="A",
msg="Message",
ti=None,
Expand Down

0 comments on commit d520445

Please sign in to comment.