<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def interactive_rewrite_schema(r, df, doc=None):
 """Rebuild the schema for a resource based on a dataframe and re-write the doc, but only if running the notebook interactively, not while building"""


    if 'metatab_doc' in caller_locals():
        return False

    if doc is None:
        doc = open_source_package()

    rewrite_schema(r, df, doc)

    return True