Meehai opened a new issue, #42931:
URL: https://github.com/apache/airflow/issues/42931
### Apache Airflow version
Other Airflow 2 version (please specify below)
### If "Other Airflow 2 version" selected, which one?
2.5.3
### What happened?
Is this the intended behaviour? It seems that airflow clones the task group
object which is different from regular python semantic, leading to potentially
hidden bugs. I got bitten by it and spent a good few hours before realizing. I
can try newer airflow versions too, if requested.
```python
class RunnerTaskGroup(TaskGroup):
def __init__(self...):
super().__init__()
self.skipped_because_not_trained = True
@task(task_group=self)
def some_task():
if random.random() < 0.5:
self.skipped_because_not_trained = False
print(self, id(self))
# <RunnerTaskGroup object at 0x7f7a2d3c5be0> 140162721668064 <- see
object address
(
some_task
)
.... in main dag .....
with DAG(dag_id=....):
def update_inference_table_label(_groups):
for group in _groups:
print(group, id(group), group.skipped_because_not_trained)
# <RunnerTaskGroup object at 0x7f7a2d3cbb50> 140162721692496 <- OTHER
OBJECT
# group.skipped_because_not_trained=True <- always TRUE
affinities_groups = []
for affinity in customer.
affn_runner_tg = RunnerTaskGroup()
affinities_group.append(affn_runner_tg)
(
affinities_groups >>
update_inference_table_label(affinities_groups)
)
```
### What you think should happen instead?
_No response_
### How to reproduce
run the code above
### Operating System
Ubuntu 22.04.3 LTS
### Versions of Apache Airflow Providers
_No response_
### Deployment
Docker-Compose
### Deployment details
_No response_
### Anything else?
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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]