@staticmethod<EOL><INDENT>def update_import_errors(session, dagbag):<DEDENT>
<EOL>for dagbag_file in dagbag.file_last_changed:<EOL><INDENT>session.query(errors.ImportError).filter(<EOL>errors.ImportError.filename == dagbag_file<EOL>).delete()<EOL><DEDENT>for filename, stacktrace in six.iteritems(dagbag.import_errors):<EOL><INDENT>session.add(errors.ImportError(<EOL>filename=filename,<EOL>stacktrace=stacktrace))<EOL><DEDENT>session.commit()<EOL>
For the DAGs in the given DagBag, record any associated import errors and clears
errors for files that no longer have them. These are usually displayed through the
Airflow UI so that users know that there are issues parsing DAGs.

:param session: session for ORM operations
:type session: sqlalchemy.orm.session.Session
:param dagbag: DagBag containing DAGs with import errors
:type dagbag: airflow.models.DagBag