Skip to content

Commit b37ce29

Browse files
vshshjn7Vishesh Jain
and
Vishesh Jain
authored
Patch Pool.DEFAULT_POOL_NAME in BaseOperator (#8587)
Co-authored-by: Vishesh Jain <visheshj@twitter.com>
1 parent 58aefb2 commit b37ce29

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

UPDATING.md

+10
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ https://developers.google.com/style/inclusive-documentation
6262
6363
-->
6464

65+
### Ability to patch Pool.DEFAULT_POOL_NAME in BaseOperator
66+
It was not possible to patch pool in BaseOperator as the signature sets the default value of pool
67+
as Pool.DEFAULT_POOL_NAME.
68+
While using subdagoperator in unittest(without initializing the sqlite db), it was throwing the
69+
following error:
70+
```
71+
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: slot_pool.
72+
```
73+
Fix for this, https://github.com/apache/airflow/pull/8587
74+
6575
### Change signature of BigQueryGetDatasetTablesOperator
6676
Was:
6777
```python

airflow/models/baseoperator.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def __init__(
316316
priority_weight: int = 1,
317317
weight_rule: str = WeightRule.DOWNSTREAM,
318318
queue: str = conf.get('celery', 'default_queue'),
319-
pool: str = Pool.DEFAULT_POOL_NAME,
319+
pool: Optional[str] = None,
320320
pool_slots: int = 1,
321321
sla: Optional[timedelta] = None,
322322
execution_timeout: Optional[timedelta] = None,
@@ -385,7 +385,7 @@ def __init__(
385385

386386
self.retries = retries
387387
self.queue = queue
388-
self.pool = pool
388+
self.pool = Pool.DEFAULT_POOL_NAME if pool is None else pool
389389
self.pool_slots = pool_slots
390390
if self.pool_slots < 1:
391391
raise AirflowException("pool slots for %s in dag %s cannot be less than 1"

tests/serialization/test_dag_serialization.py

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"bash_command": "echo {{ task.task_id }}",
7171
"_task_type": "BashOperator",
7272
"_task_module": "airflow.operators.bash",
73+
"pool": "default_pool",
7374
},
7475
{
7576
"task_id": "custom_task",
@@ -84,6 +85,7 @@
8485
"template_fields": ['bash_command'],
8586
"_task_type": "CustomOperator",
8687
"_task_module": "tests.test_utils.mock_operators",
88+
"pool": "default_pool",
8789
},
8890
],
8991
"timezone": "UTC",

0 commit comments

Comments
 (0)