class DAGDetailSchema(DAGSchema): """DAG details""" owners = fields.Method("get_owners", dump_only=True) timezone = TimezoneField() catchup = fields.Boolean() orientation = fields.String() concurrency = fields.Method( "get_concurrency") # TODO: Remove in Airflow 3.0 max_active_tasks = fields.Integer() start_date = fields.DateTime() dag_run_timeout = fields.Nested(TimeDeltaSchema, attribute="dagrun_timeout") doc_md = fields.String() default_view = fields.String() params = fields.Method('get_params', dump_only=True) tags = fields.Method("get_tags", dump_only=True) # type: ignore is_paused = fields.Method("get_is_paused", dump_only=True) is_active = fields.Method("get_is_active", dump_only=True) is_paused_upon_creation = fields.Boolean() end_date = fields.DateTime(dump_only=True) template_search_path = fields.String(dump_only=True) render_template_as_native_obj = fields.Boolean(dump_only=True) last_loaded = fields.DateTime(dump_only=True, data_key='last_parsed') @staticmethod def get_concurrency(obj: DAG): return obj.max_active_tasks @staticmethod def get_tags(obj: DAG): """Dumps tags as objects""" tags = obj.tags if tags: return [DagTagSchema().dump(dict(name=tag)) for tag in tags] return [] @staticmethod def get_owners(obj: DAG): """Convert owners attribute to DAG representation""" if not getattr(obj, 'owner', None): return [] return obj.owner.split(",") @staticmethod def get_is_paused(obj: DAG): """Checks entry in DAG table to see if this DAG is paused""" return obj.get_is_paused() @staticmethod def get_is_active(obj: DAG): """Checks entry in DAG table to see if this DAG is active""" return obj.get_is_active() @staticmethod def get_params(obj: DAG): """Get the Params defined in a DAG""" params = obj.params return {k: v.dump() for k, v in params.items()}
class DAGDetailSchema(DAGSchema): """DAG details""" timezone = TimezoneField(dump_only=True) catchup = fields.Boolean(dump_only=True) orientation = fields.String(dump_only=True) concurrency = fields.Integer(dump_only=True) start_date = fields.DateTime(dump_only=True) dag_run_timeout = fields.Nested(TimeDeltaSchema, dump_only=True, attribute="dagrun_timeout") doc_md = fields.String(dump_only=True) default_view = fields.String(dump_only=True)
class DAGDetailSchema(DAGSchema): """DAG details""" owners = fields.Method("get_owners", dump_only=True) timezone = TimezoneField() catchup = fields.Boolean() orientation = fields.String() concurrency = fields.Integer() # TODO: Remove in Airflow 3.0 max_active_tasks = fields.Integer() start_date = fields.DateTime() dag_run_timeout = fields.Nested(TimeDeltaSchema, attribute="dagrun_timeout") doc_md = fields.String() default_view = fields.String() params = fields.Dict() tags = fields.Method("get_tags", dump_only=True) is_paused = fields.Method("get_is_paused", dump_only=True) is_active = fields.Method("get_is_active", dump_only=True) @staticmethod def get_tags(obj: DAG): """Dumps tags as objects""" tags = obj.tags if tags: return [DagTagSchema().dump(dict(name=tag)) for tag in tags] return [] @staticmethod def get_owners(obj: DAG): """Convert owners attribute to DAG representation""" if not getattr(obj, 'owner', None): return [] return obj.owner.split(",") @staticmethod def get_is_paused(obj: DAG): """Checks entry in DAG table to see if this DAG is paused""" return obj.get_is_paused() @staticmethod def get_is_active(obj: DAG): """Checks entry in DAG table to see if this DAG is active""" return obj.get_is_active()