Rewrite the Clear workflow in Python