Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update to support up to 10K partitions #1139

Merged
merged 11 commits into from
May 22, 2024
18 changes: 14 additions & 4 deletions data_validation/cli_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import sys
import uuid
import os
import re
from argparse import Namespace
from typing import Dict, List
from yaml import Dumper, Loader, dump, load
Expand Down Expand Up @@ -954,6 +955,16 @@ def _add_common_arguments(optional_arguments, required_arguments):
)


def _check_no_partitions(value):
sundar-mudupalli-work marked this conversation as resolved.
Show resolved Hide resolved
"""Check that number of partitions less than limit
sundar-mudupalli-work marked this conversation as resolved.
Show resolved Hide resolved
Using function to validate rather than choices as error message prints all choices."""
if not (re.match(r"\d*$", value) and int(value) < 10001 and int(value) > 1):
sundar-mudupalli-work marked this conversation as resolved.
Show resolved Hide resolved
raise argparse.ArgumentTypeError(
f"{value} is not valid for number of partitions, use number in range 2 to 10000"
)
return int(value)


def _add_common_partition_arguments(optional_arguments, required_arguments):
"""Add all arguments common to get-partition command"""

Expand All @@ -978,10 +989,9 @@ def _add_common_partition_arguments(optional_arguments, required_arguments):
"--partition-num",
"-pn",
required=True,
help="Number of partitions/config files to generate",
type=int,
choices=range(1, 1001),
metavar="[1-1000]",
help="Number of partitions/config files to generate, a number from 1 to 10,000",
sundar-mudupalli-work marked this conversation as resolved.
Show resolved Hide resolved
type=_check_no_partitions,
sundar-mudupalli-work marked this conversation as resolved.
Show resolved Hide resolved
metavar="[2-10000]",
)

# Optional arguments
Expand Down