tirkarthi commented on issue #27228:
URL: https://github.com/apache/airflow/issues/27228#issuecomment-1298204265

   During AirflowApp instantiation `read_dags_from_db` is set to True. This 
causes serialized dags to be loaded from database. Meanwhile collecting it from 
`DagBag` without flask app context makes it read from files. My first guess is 
the below approach to deserialize the param value before passing them to 
resolve. I can make a PR with tests for this.
   
   
https://github.com/apache/airflow/blob/b29ca4e77d4d80fb1f4d6d4b497a3a14979dd244/airflow/www/extensions/init_dagbag.py#L33
   
   
https://github.com/apache/airflow/blob/b29ca4e77d4d80fb1f4d6d4b497a3a14979dd244/airflow/models/dagbag.py#L184-L191
   
   ```patch
   diff --git a/airflow/www/views.py b/airflow/www/views.py
   index bc03f42f04..541dc49a6f 100644
   --- a/airflow/www/views.py
   +++ b/airflow/www/views.py
   @@ -104,6 +104,7 @@ from airflow.models.serialized_dag import 
SerializedDagModel
    from airflow.models.taskinstance import TaskInstance
    from airflow.providers_manager import ProvidersManager
    from airflow.security import permissions
   +from airflow.serialization.serialized_objects import BaseSerialization
    from airflow.ti_deps.dep_context import DepContext
    from airflow.ti_deps.dependencies_deps import RUNNING_DEPS, 
SCHEDULER_QUEUED_DEPS
    from airflow.timetables.base import DataInterval, TimeRestriction
   @@ -1864,7 +1865,8 @@ class Airflow(AirflowBaseView):
                else:
                    try:
                        default_conf = json.dumps(
   -                        {str(k): v.resolve(suppress_exception=True) for k, 
v in dag.params.items()}, indent=4
   +                        {str(k): 
v.resolve(value=BaseSerialization.deserialize(v.value), suppress_exception=True)
   +                         for k, v in dag.params.items()}, indent=4
                        )
                    except TypeError:
                        flash("Could not pre-populate conf field due to 
non-JSON-serializable data-types")
   ```


-- 
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]

Reply via email to