zcloud.console_scripts.order_uploader module

zcloud.console_scripts.order_uploader.ask_for_new_value(query_val, metadata_table_id, max_attempts=3)[source]

Prompt the user for a new value when the original cannot be resolved.

Parameters:
  • query_val (str) – The original value that could not be resolved.

  • metadata_table_id (str) – The ID of the metadata table being queried.

  • max_attempts (int, optional) – Maximum number of attempts before exiting, by default 3.

Returns:

A new value provided by the user.

Return type:

str

Raises:

SystemExit – If max attempts are reached or user provides the same value repeatedly.

zcloud.console_scripts.order_uploader.ask_user_to_confirm_fuzzy_match(query_val, fuzzy_matches, metadata_table_id)[source]

Ask the user to confirm a fuzzy match selection from a list of candidates.

Parameters:
  • query_val (str) – The original query value that did not match exactly.

  • fuzzy_matches (Iterable[str]) – A list of fuzzy match candidates.

  • metadata_table_id (str) – The ID of the metadata table being queried.

Returns:

The value selected by the user (either from fuzzy matches or a new value).

Return type:

str

Raises:

SystemExit – If user chooses to exit during the selection process.

zcloud.console_scripts.order_uploader.ask_user_to_decide_what_to_do_with_name_resolution(df, generated_design_names, original_input_columns)[source]

Ask the user to decide how to handle design name resolution conflicts.

When generated design names clash with expectations, this function presents the user with options to either use the generated names, save them to a file, or exit the process.

Parameters:
  • df (pd.DataFrame) – The main DataFrame containing the order data.

  • generated_design_names (pd.Series) – The generated design names that caused the conflict.

  • original_input_columns (pd.Index) – The original column names from the input CSV.

Returns:

The DataFrame with design names updated if user chose to use generated names.

Return type:

pd.DataFrame

Raises:

SystemExit – If user chooses to save names to file or exit.

zcloud.console_scripts.order_uploader.check_metadata_against_oracle_with_fuzzy_find_on_fail(metadata_table_id, query_value, allowed_other_ids=None, try_to_find_monday_id=None, fuzzy_match_threshold=70, _recursion_depth=0)[source]

Check metadata value against oracle with fuzzy matching fallback.

Attempts to validate a metadata value against the oracle database. If the exact match fails, falls back to fuzzy matching and user confirmation. Uses recursion to handle multiple validation attempts.

Parameters:
  • metadata_table_id (str) – The ID of the metadata table to check against.

  • query_value (str) – The value to validate.

  • allowed_other_ids (Optional[List[str]], optional) – Additional IDs that are allowed for validation, by default None.

  • try_to_find_monday_id (Optional[str], optional) – Monday ID to try to match against, by default None.

  • fuzzy_match_threshold (int, optional) – Threshold for fuzzy matching (0-100), by default 70.

  • _recursion_depth (int, optional) – Internal recursion depth counter, by default 0.

Returns:

A tuple containing the validated metadata information. The exact structure depends on the metadata checker function used.

Return type:

Tuple[Any, …]

Raises:
  • SystemExit – If maximum recursion depth is reached.

  • ValueError – If there are errors retrieving metadata tables.

zcloud.console_scripts.order_uploader.check_scu_against_oracle_with_fuzzy_find_on_fail(score_columns_to_check, _recursion_depth=0, all_tables=None, keymap=None)[source]

Check score columns against SCU oracle with fuzzy matching fallback.

Validates score column names against the SCU (Score Column Unit) schema. If exact matches fail, provides fuzzy matching and user interaction to resolve column names. Handles orphaned columns that cannot be matched.

Parameters:
  • score_columns_to_check (Set[str]) – Set of score column names to validate.

  • _recursion_depth (int, optional) – Internal recursion depth counter, by default 0.

  • all_tables (Optional[Dict[str, List[Dict[str, str]]]], optional) – Cached SCU tables data to avoid repeated API calls, by default None.

  • keymap (Optional[Dict[str, str]], optional) – Mapping of original column names to corrected names, by default None.

Returns:

A tuple containing: - Dictionary mapping table IDs to lists of found field names - Set of orphaned score columns that couldn’t be matched - Dictionary mapping original column names to corrected names

Return type:

Tuple[Dict[str, List[str]], Set[str], Dict[str, str]]

Raises:
  • SystemExit – If maximum recursion depth is reached.

  • ValueError – If there are errors retrieving SCU tables.

zcloud.console_scripts.order_uploader.check_tag_location_with_fuzzy_find_on_fail(df, tag_column_name='tag_location')[source]

Check tag location with fuzzy matching fallback.

Validates tag location as one of two values: “N-term” or “C-term”. No others are allowed.

Parameters:
  • df (pd.DataFrame) – The input DataFrame containing the tag location column.

  • tag_column_name (str) – The name of the tag location column.

Returns:

The input DataFrame with the tag location column fixed.

Return type:

pd.DataFrame

zcloud.console_scripts.order_uploader.confirm_set_of_values_from_user(value_type, df, cli_value, allow_cli_override)[source]

Confirm and resolve a set of values from user input or DataFrame.

This function attempts to resolve values from the DataFrame first, and if that fails, prompts the user for input or uses CLI override values.

Parameters:
  • value_type (str) – The type of value to resolve (e.g., ‘binding_site_id’, ‘fusion_id’).

  • df (pd.DataFrame) – The input DataFrame containing the data to analyze.

  • cli_value (Optional[str]) – Optional CLI-provided value to use as override.

  • allow_cli_override (bool) – Whether to allow CLI values to override DataFrame values.

Returns:

A set of resolved values for the specified type.

Return type:

Set[str]

Raises:

SystemExit – If user chooses to exit during the confirmation process.

zcloud.console_scripts.order_uploader.confirm_single_value_from_user(value_type, df, cli_value, allow_cli_override)[source]

Confirm and resolve a single value from user input or DataFrame.

This function attempts to resolve a value from the DataFrame first, and if that fails, prompts the user for input or uses CLI override values.

Parameters:
  • value_type (str) – The type of value to resolve (e.g., ‘program_id’, ‘target_id’).

  • df (pd.DataFrame) – The input DataFrame containing the data to analyze.

  • cli_value (Optional[str]) – Optional CLI-provided value to use as override.

  • allow_cli_override (bool) – Whether to allow CLI values to override DataFrame values.

Returns:

The resolved value for the specified type.

Return type:

str

Raises:

SystemExit – If user chooses to exit during the confirmation process.

zcloud.console_scripts.order_uploader.get_candidate_resolver_set_of_values(value)[source]

Get a candidate resolver function for set-value metadata fields.

Parameters:

value (str) – The field name to get a resolver for. Must be one of: ‘binding_site_id’, ‘fusion_id’.

Returns:

A function that can be used to resolve the specified metadata field, returning a set of values.

Return type:

Callable

Raises:

KeyError – If the provided value is not a valid field name.

zcloud.console_scripts.order_uploader.get_candidate_resolver_single_value(value)[source]

Get a candidate resolver function for single-value metadata fields.

Parameters:

value (str) – The field name to get a resolver for. Must be one of: ‘iteration_number’, ‘program_id’, ‘target_id’.

Returns:

A function that can be used to resolve the specified metadata field.

Return type:

Callable

Raises:

KeyError – If the provided value is not a valid field name.

zcloud.console_scripts.order_uploader.get_metadata_checker(value)[source]

Get a metadata checker function for validating metadata values.

Parameters:

value (str) – The metadata table name to get a checker for. Must be one of: ‘binding_site_table’, ‘fusion_table’, ‘program_table’, ‘target_table’.

Returns:

A function that can be used to validate metadata values against the specified table.

Return type:

Callable

Raises:

KeyError – If the provided value is not a valid metadata table name.