tools/athena/loadtoathena.py
def parse_inputs() -> dict:
    """
    parse the input command line arguments
    and return dictionary
    """

    parser = argparse.ArgumentParser(
        prog="loadtoathena.py",
        formatter_class=argparse.RawTextHelpFormatter,
        description=textwrap.dedent(
            """\
            Helps setting up the athena database, table and view
            that in turn helps to query the Datastream2 logs
            stored in S3 buckets
            """
        ),
    )

    parser.add_argument(
        "--loglevel",
        default="info",
        type=str,
        choices=["critical", "error", "warn", "info", "debug"],
        help=textwrap.dedent(
            """\
            logging level.
            (default: %(default)s)
            \n"""
        ),
    )

    parser.add_argument(
        "--dryrun",
        action="store_true",
        help=textwrap.dedent(
            """\
            shows the commands that will be executed by this script
            without actually running it.
            the default loglevel for this mode is debug.
            (default: %(default)s)
            \n"""
        ),
    )

    parser.add_argument(
        "--log_field_maps",
        default="conf/log_fields.json",
        type=str,
        help=textwrap.dedent(
            """\
            json file with field id to name mapping and aggregate functions.
            (default: %(default)s)
            \n"""
        ),
    )
    parser.add_argument(
        "--formulas_json",
        default="conf/formulas.json",
        type=str,
        help=textwrap.dedent(
            """\
            json file with formulas for the aggregate functions.
            (default: %(default)s)
            \n"""
        ),
    )
    parser.add_argument(
        "--stream_json",
        default="conf/sample_stream.json",
        type=str,
        help=textwrap.dedent(
            """\
            json file with stream details.
            (default: %(default)s)
            \n"""
        ),
    )
    parser.add_argument(
        "--out_bucket",
        default="athena-result-bucket",
        type=str,
        help=textwrap.dedent(
            """\
            output bucket to store athena query results.
            (default: %(default)s-<STREAM_JSON:streamId>)
            \n"""
        ),
    )
    parser.add_argument(
        "--out_bucket_path",
        default="",
        type=str,
        help=textwrap.dedent(
            """\
            output bucket path to store athena query results.
            (default: %(default)s)
            \n"""
        ),
    )
    parser.add_argument(
        "--out_bucket_region",
        type=str,
        help=textwrap.dedent(
            """\
            s3 region for the output bucket that stores query results.
            if not provided, the default region will be parsed from the stream json file.
            (default: STREAM_JSON:connectors["region"]
            \n"""
        ),
        default="",
    )
    parser.add_argument(
        "--db_name",
        default="athena_db",
        type=str,
        help=textwrap.dedent(
            """\
            database name to create.
            (default: %(default)s_<STREAM_JSON:streamId>)
            \n"""
        ),
    )
    parser.add_argument(
        "--table_name",
        default="athena_table",
        type=str,
        help=textwrap.dedent(
            """\
            table name to create.
            (default: %(default)s_<STREAM_JSON:streamId>_<STREAM_JSON:streamVersionId>)
            \n"""
        ),
    )
    parser.add_argument(
        "--view_name",
        default="athena_view",
        type=str,
        help=textwrap.dedent(
            """\
            view name to create.
            (default: %(default)s_<STREAM_JSON:streamId>_<STREAM_JSON:streamVersionId>)
            \n"""
        ),
    )
    parser.add_argument(
        "--workgroup",
        default="athena_workgroup",
        type=str,
        help=textwrap.dedent(
            """\
            The workgroup name to create to execute athena queries.
            In order to store the query results in the provided s3://<out_bucket>/<out_bucket_path>,
            ensure to switch to this workgroup while running queries.
            (default: %(default)s_<STREAM_JSON:streamId>)
            \n"""
        ),
    )

    return vars(parser.parse_args())

    parse the input command line arguments
    and return dictionary
    
parse the input command line arguments
and return dictionary
parse the input command line arguments and return dictionary
def parse_inputs() -> dict:
    parser = argparse.ArgumentParser(
        prog="loadtoathena.py",
        formatter_class=argparse.RawTextHelpFormatter,
        description=textwrap.dedent(
            """\
            Helps setting up the athena database, table and view
            that in turn helps to query the Datastream2 logs
            stored in S3 buckets
            """
        ),
    )
    parser.add_argument(
        "--loglevel",
        default="info",
        type=str,
        choices=["critical", "error", "warn", "info", "debug"],
        help=textwrap.dedent(
            """\
            logging level.
            (default: %(default)s)
            \n"""
        ),
    )
    parser.add_argument(
        "--dryrun",
        action="store_true",
        help=textwrap.dedent(
            """\
            shows the commands that will be executed by this script
            without actually running it.
            the default loglevel for this mode is debug.
            (default: %(default)s)
            \n"""
        ),
    )
    parser.add_argument(
        "--log_field_maps",
        default="conf/log_fields.json",
        type=str,
        help=textwrap.dedent(
            """\
            json file with field id to name mapping and aggregate functions.
            (default: %(default)s)
            \n"""
        ),
    )
    parser.add_argument(
        "--formulas_json",
        default="conf/formulas.json",
        type=str,
        help=textwrap.dedent(
            """\
            json file with formulas for the aggregate functions.
            (default: %(default)s)
            \n"""
        ),
    )
    parser.add_argument(
        "--stream_json",
        default="conf/sample_stream.json",
        type=str,
        help=textwrap.dedent(
            """\
            json file with stream details.
            (default: %(default)s)
            \n"""
        ),
    )
    parser.add_argument(
        "--out_bucket",
        default="athena-result-bucket",
        type=str,
        help=textwrap.dedent(
            """\
            output bucket to store athena query results.
            (default: %(default)s-<STREAM_JSON:streamId>)
            \n"""
        ),
    )
    parser.add_argument(
        "--out_bucket_path",
        default="",
        type=str,
        help=textwrap.dedent(
            """\
            output bucket path to store athena query results.
            (default: %(default)s)
            \n"""
        ),
    )
    parser.add_argument(
        "--out_bucket_region",
        type=str,
        help=textwrap.dedent(
            """\
            s3 region for the output bucket that stores query results.
            if not provided, the default region will be parsed from the stream json file.
            (default: STREAM_JSON:connectors["region"]
            \n"""
        ),
        default="",
    )
    parser.add_argument(
        "--db_name",
        default="athena_db",
        type=str,
        help=textwrap.dedent(
            """\
            database name to create.
            (default: %(default)s_<STREAM_JSON:streamId>)
            \n"""
        ),
    )
    parser.add_argument(
        "--table_name",
        default="athena_table",
        type=str,
        help=textwrap.dedent(
            """\
            table name to create.
            (default: %(default)s_<STREAM_JSON:streamId>_<STREAM_JSON:streamVersionId>)
            \n"""
        ),
    )
    parser.add_argument(
        "--view_name",
        default="athena_view",
        type=str,
        help=textwrap.dedent(
            """\
            view name to create.
            (default: %(default)s_<STREAM_JSON:streamId>_<STREAM_JSON:streamVersionId>)
            \n"""
        ),
    )
    parser.add_argument(
        "--workgroup",
        default="athena_workgroup",
        type=str,
        help=textwrap.dedent(
            """\
            The workgroup name to create to execute athena queries.
            In order to store the query results in the provided s3://<out_bucket>/<out_bucket_path>,
            ensure to switch to this workgroup while running queries.
            (default: %(default)s_<STREAM_JSON:streamId>)
            \n"""
        ),
    )
    return vars(parser.parse_args())
def parse_inputs ( ) -> dict : parser = argparse . ArgumentParser ( prog = "loadtoathena.py" , formatter_class = argparse . RawTextHelpFormatter , description = textwrap . dedent ( """\
            Helps setting up the athena database, table and view
            that in turn helps to query the Datastream2 logs
            stored in S3 buckets
            """ ) , ) parser . add_argument ( "--loglevel" , default = "info" , type = str , choices = [ "critical" , "error" , "warn" , "info" , "debug" ] , help = textwrap . dedent ( """\
            logging level.
            (default: %(default)s)
            \n""" ) , ) parser . add_argument ( "--dryrun" , action = "store_true" , help = textwrap . dedent ( """\
            shows the commands that will be executed by this script
            without actually running it.
            the default loglevel for this mode is debug.
            (default: %(default)s)
            \n""" ) , ) parser . add_argument ( "--log_field_maps" , default = "conf/log_fields.json" , type = str , help = textwrap . dedent ( """\
            json file with field id to name mapping and aggregate functions.
            (default: %(default)s)
            \n""" ) , ) parser . add_argument ( "--formulas_json" , default = "conf/formulas.json" , type = str , help = textwrap . dedent ( """\
            json file with formulas for the aggregate functions.
            (default: %(default)s)
            \n""" ) , ) parser . add_argument ( "--stream_json" , default = "conf/sample_stream.json" , type = str , help = textwrap . dedent ( """\
            json file with stream details.
            (default: %(default)s)
            \n""" ) , ) parser . add_argument ( "--out_bucket" , default = "athena-result-bucket" , type = str , help = textwrap . dedent ( """\
            output bucket to store athena query results.
            (default: %(default)s-<STREAM_JSON:streamId>)
            \n""" ) , ) parser . add_argument ( "--out_bucket_path" , default = "" , type = str , help = textwrap . dedent ( """\
            output bucket path to store athena query results.
            (default: %(default)s)
            \n""" ) , ) parser . add_argument ( "--out_bucket_region" , type = str , help = textwrap . dedent ( """\
            s3 region for the output bucket that stores query results.
            if not provided, the default region will be parsed from the stream json file.
            (default: STREAM_JSON:connectors["region"]
            \n""" ) , default = "" , ) parser . add_argument ( "--db_name" , default = "athena_db" , type = str , help = textwrap . dedent ( """\
            database name to create.
            (default: %(default)s_<STREAM_JSON:streamId>)
            \n""" ) , ) parser . add_argument ( "--table_name" , default = "athena_table" , type = str , help = textwrap . dedent ( """\
            table name to create.
            (default: %(default)s_<STREAM_JSON:streamId>_<STREAM_JSON:streamVersionId>)
            \n""" ) , ) parser . add_argument ( "--view_name" , default = "athena_view" , type = str , help = textwrap . dedent ( """\
            view name to create.
            (default: %(default)s_<STREAM_JSON:streamId>_<STREAM_JSON:streamVersionId>)
            \n""" ) , ) parser . add_argument ( "--workgroup" , default = "athena_workgroup" , type = str , help = textwrap . dedent ( """\
            The workgroup name to create to execute athena queries.
            In order to store the query results in the provided s3://<out_bucket>/<out_bucket_path>,
            ensure to switch to this workgroup while running queries.
            (default: %(default)s_<STREAM_JSON:streamId>)
            \n""" ) , ) return vars ( parser . parse_args ( ) )
parse the input command line arguments
and return dictionary
parse the input command line arguments and return dictionary
"""
    parse the input command line arguments
    and return dictionary
    """