Skip to content

Commit

Permalink
Patch Pool.DEFAULT_POOL_NAME in BaseOperator (apache#8587)
Browse files Browse the repository at this point in the history
Co-authored-by: Vishesh Jain <visheshj@twitter.com>
  • Loading branch information
vshshjn7 and Vishesh Jain authored May 8, 2020
1 parent 58aefb2 commit b37ce29
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ https://developers.google.com/style/inclusive-documentation
-->

### Ability to patch Pool.DEFAULT_POOL_NAME in BaseOperator
It was not possible to patch pool in BaseOperator as the signature sets the default value of pool
as Pool.DEFAULT_POOL_NAME.
While using subdagoperator in unittest(without initializing the sqlite db), it was throwing the
following error:
```
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: slot_pool.
```
Fix for this, https://github.com/apache/airflow/pull/8587

### Change signature of BigQueryGetDatasetTablesOperator
Was:
```python
Expand Down
4 changes: 2 additions & 2 deletions airflow/models/baseoperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def __init__(
priority_weight: int = 1,
weight_rule: str = WeightRule.DOWNSTREAM,
queue: str = conf.get('celery', 'default_queue'),
pool: str = Pool.DEFAULT_POOL_NAME,
pool: Optional[str] = None,
pool_slots: int = 1,
sla: Optional[timedelta] = None,
execution_timeout: Optional[timedelta] = None,
Expand Down Expand Up @@ -385,7 +385,7 @@ def __init__(

self.retries = retries
self.queue = queue
self.pool = pool
self.pool = Pool.DEFAULT_POOL_NAME if pool is None else pool
self.pool_slots = pool_slots
if self.pool_slots < 1:
raise AirflowException("pool slots for %s in dag %s cannot be less than 1"
Expand Down
2 changes: 2 additions & 0 deletions tests/serialization/test_dag_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"bash_command": "echo {{ task.task_id }}",
"_task_type": "BashOperator",
"_task_module": "airflow.operators.bash",
"pool": "default_pool",
},
{
"task_id": "custom_task",
Expand All @@ -84,6 +85,7 @@
"template_fields": ['bash_command'],
"_task_type": "CustomOperator",
"_task_module": "tests.test_utils.mock_operators",
"pool": "default_pool",
},
],
"timezone": "UTC",
Expand Down

0 comments on commit b37ce29

Please sign in to comment.