From c499bd4a433210465dc4c89adef0db4c03267ed4 Mon Sep 17 00:00:00 2001 From: d-shree <101096921+d-shree@users.noreply.github.com> Date: Thu, 16 Nov 2023 16:35:17 +0530 Subject: [PATCH] Fix flow id format issues (#26) --- skit_calls/calls.py | 5 +---- skit_calls/cli.py | 11 +++++++++-- skit_calls/utils.py | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/skit_calls/calls.py b/skit_calls/calls.py index 58f299f..3a33608 100644 --- a/skit_calls/calls.py +++ b/skit_calls/calls.py @@ -9,7 +9,6 @@ from skit_calls import constants as const from skit_calls.data import mutators, query from skit_calls.data.model import Turn -from skit_calls.utils import convert_str_to_int_list def save_turns_in_memory(stream: Iterable[Dict[str, Any]]) -> pd.DataFrame: return pd.DataFrame(list(stream)) @@ -146,11 +145,9 @@ def sample( :rtype: str """ start_time = time.time() - logger.info(f"Flow ids: {flow_ids}") - flow_ids = convert_str_to_int_list(flow_ids) random_id_limit = min(30*call_quantity, 75000) all_call_ids = [] - org_ids = convert_str_to_int_list(org_ids) + logger.info(f"Flow ids: {flow_ids}") for flow_id in flow_ids: flow_id_list = [] flow_id_list.append(flow_id) diff --git a/skit_calls/cli.py b/skit_calls/cli.py index 4c15652..d3ee20e 100644 --- a/skit_calls/cli.py +++ b/skit_calls/cli.py @@ -10,7 +10,7 @@ from skit_calls import calls from skit_calls import constants as const -from skit_calls import utils +from skit_calls.utils import configure_logger, process_ids_to_int def to_datetime(date_string: Optional[str]) -> datetime: @@ -282,6 +282,13 @@ def random_sample_calls(args: argparse.Namespace) -> Union[str, pd.DataFrame]: args.start_date, args.end_date = process_date_filters( args.start_date, args.end_date, timezone=args.timezone ) + + args.flow_ids = process_ids_to_int(args.flow_ids) + args.org_ids = process_ids_to_int(args.org_ids) + + logger.info(f"args.flow_id {args.flow_ids}") + logger.info(f"args.org_ids {args.org_ids}") + validate_date_ranges(args.start_date, args.end_date) start = time.time() maybe_df = calls.sample( @@ -313,7 +320,7 @@ def random_sample_calls(args: argparse.Namespace) -> Union[str, pd.DataFrame]: def cmd_to_str(args: argparse.Namespace) -> str: - utils.configure_logger(args.verbose) + configure_logger(args.verbose) maybe_df = None if args.command == "sample": diff --git a/skit_calls/utils.py b/skit_calls/utils.py index d56004f..fe18082 100644 --- a/skit_calls/utils.py +++ b/skit_calls/utils.py @@ -92,9 +92,9 @@ def optimal_paging_params(total_count: int, page_size: int, delay: int) -> Tuple page_size //= 1.8 return int(page_size), delay -def convert_str_to_int_list(str_values): +def process_ids_to_int(str_values): int_list = [] - if str_values and len(str_values[0])>0: + if str_values and isinstance(str_values[0], str): str_list = str_values[0].strip("[]").split(',') int_list = [int(value) for value in str_list] return int_list \ No newline at end of file