Hi Ramit,

Thanks for digging into this - a deprecation warning that the user never
sees is pretty much useless, so this is worth fixing properly.

1. A, by category. The category filter is exactly right here: the
   warning should be shown because of what it is, not because of which
   module it is attributed to - and it keeps the location pointing at
   the user's line in the Dag file. B changes the class hierarchy that
   users and test setups rely on (catching or filtering
   DeprecationWarning, -W error::DeprecationWarning), only to work around
   a filter we control ourselves. C pushes the work to every provider and
   points at the wrong line.

2. Yes, include RemovedInAirflow4Warning - those are precisely the
   warnings Dag authors need to see before upgrading. But note there are
   two classes with that name: airflow.exceptions.RemovedInAirflow4Warning
   in core and airflow.sdk.exceptions.RemovedInAirflow4Warning in the Task
   SDK, and they are not related. Your "email" example is raised from the
   Task SDK's BaseOperator with the SDK class, so a filter on core's class
   alone would not show it. The filter needs both classes (or one of them
   should become an alias of the other).

3. Where the filter is installed. Today it lives in
   airflow/configuration.py, which the Dag processor imports. The task
   runner in the Task SDK does not set any warning filters, so on workers
   that only run the Task SDK, the parse-time warnings in the task log
   would still depend on what happens to be imported. I'd put the filter
   setup in one helper used by both core and the Task SDK (the shared
   libraries are the natural place), and keep the existing
   "if not sys.warnoptions" guard so that users who configure warnings
   themselves (PYTHONWARNINGS / -W) still win.

4. Tests. As you noticed, pytest.warns records regardless of filters, so
   I'd add a test that checks that the warning is actually emitted under
   the filters we install - for example in a subprocess with default
   warning settings - for both a provider warning and an SDK one.

Longer term, it might be nicer to also surface these parse-time
deprecations as Dag warnings in the UI rather than only in logs, but
that is a separate discussion - A plus the points above would already fix
the actual problem.

So from my side: +1 for A, covering AirflowProviderDeprecationWarning and
both RemovedInAirflow4Warning classes, installed for both the Dag
processor and the task runner.

J.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to