

from invoke import task


@task
def clean(ctx):
    """
    Clean Spark artifacts, coverage reports.
    """
    # Clean build / test artifacts.
    patterns = [
        'metastore_db',
        'spark-warehouse',
        'htmlcov',
        '.coverage',
        '.coverage.*',
        '*.log',
        '.cache',
    ]

    for pattern in patterns:
        ctx.run('rm -rf %s' % pattern)

    # Clean __pycache__, etc.
    ctx.run('py3clean osp_pipeline')
    ctx.run('py3clean tests')
