GitHub user tgrandje added a comment to the discussion: sqlalchemy 2 set in a 
virtualenv breaks variable access

I know that (I think I stated this first hand with the reference to the airflow 
3 roadmap) ; that's even the reason why I had'nt posted the traceback in the 
first place.

I still this needs to be referenced as :
* using a virtualenv with sqlalchemy > 2 in airflow it currently the only way 
to work with recent data libraries (like polars), and that's going to stay as 
it is until airflow 3 is released ;
* we have unconsistent behaviour, as variables set with the 
`os.environ["AIRFLOW_VAR_..."]` **are** accessible (is this through the 
SecretCache?). Again, I know this is *by design*, but I still think this info 
is needed.

For instance, that dag works just fine:

```
from airflow.decorators import dag, task


@dag()
def sqlalchemy_test():

    import os

    os.environ["AIRFLOW_VAR_BACON"] = "sausage"

    @task
    def get_variable():
        from airflow.models import Variable

        print(Variable.get("bacon"))

    @task.virtualenv(requirements=["sqlalchemy>2.0.0"])
    def get_variable2():
        from airflow.models import Variable

        print(Variable.get("bacon"))

    get_variable()
    get_variable2()


sqlalchemy_test()

```


GitHub link: 
https://github.com/apache/airflow/discussions/46266#discussioncomment-12003941

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to