def __validate_and_fix_spark_args(spark_args):
    """
    Prepares spark arguments. In the command-line script, they are passed as for example
    `-s master=local[4] deploy-mode=client verbose`, which would be passed to spark-submit as
    `--master local[4] --deploy-mode client --verbose`

    Parameters
    ----------
    spark_args (List): List of spark arguments

    Returns
    -------
    fixed_args (List): List of fixed and validated spark arguments
    """
    pattern = re.compile(r'[\w\-_]+=.+')
    fixed_args = []
    for arg in spark_args:
        if arg not in SPARK_SUBMIT_FLAGS:
            if not pattern.match(arg):
                raise SystemExit('Spark argument `%s` does not seem to be in the correct format '
                                 '`ARG_NAME=ARG_VAL`, and is also not recognized to be one of the'
                                 'valid spark-submit flags (%s).' % (arg, str(SPARK_SUBMIT_FLAGS)))
            eq_pos = arg.find('=')
            fixed_args.append('--' + arg[:eq_pos])
            fixed_args.append(arg[eq_pos + 1:])
        else:
            fixed_args.append('--' + arg)

    return fixed_args
def __validate_and_fix_spark_args ( spark_args ) : pattern = re . compile ( r'[\w\-_]+=.+' ) fixed_args = [ ] for arg in spark_args : if arg not in SPARK_SUBMIT_FLAGS : if not pattern . match ( arg ) : raise SystemExit ( 'Spark argument `%s` does not seem to be in the correct format ' '`ARG_NAME=ARG_VAL`, and is also not recognized to be one of the' 'valid spark-submit flags (%s).' % ( arg , str ( SPARK_SUBMIT_FLAGS ) ) ) eq_pos = arg . find ( '=' ) fixed_args . append ( '--' + arg [ : eq_pos ] ) fixed_args . append ( arg [ eq_pos + 1 : ] ) else : fixed_args . append ( '--' + arg ) return fixed_args
Prepares spark arguments. In the command-line script, they are passed as for example
    `-s master=local[4] deploy-mode=client verbose`, which would be passed to spark-submit as
    `--master local[4] --deploy-mode client --verbose`

    Parameters
    ----------
    spark_args (List): List of spark arguments

    Returns
    -------
    fixed_args (List): List of fixed and validated spark arguments