job_utils

Job-specific utility functions for job submission and management.

Module Contents

job_utils.coerce_bool_param(value: Any, default: bool = False) bool

Coerce common HTML/JSON boolean representations to a Python bool.

job_utils.canonicalise_targets(targets: List[str]) List[str]

Return deduplicated targets in canonical display/execution order.

job_utils.canonical_prediction_type(targets: List[str]) str

Build a compact, human-readable prediction_type label for persisted jobs.

job_utils.validate_prediction_parameters(targets: List[str], methods: Dict[str, str]) str | None

Validate target and method parameters against the method registry.

Returns an error message if validation fails, None if valid.

job_utils.validate_sequence_handling_option(handle_long_seq: str) str | None

Validate the sequence handling option parameter.

Returns an error message if invalid, None if valid.

job_utils.determine_required_columns(targets: List[str], methods: Dict[str, str]) List[str]

Determine strict required columns for the selected target/method set.

The result always includes “Protein Sequence”. Additional columns are derived from each selected descriptor’s col_to_kwarg mapping.

job_utils.validate_required_columns_for_methods(dataframe: pandas.DataFrame, targets: List[str], methods: Dict[str, str]) str | None

Validate CSV columns for selected methods.

Pair-based methods accept either Substrate or Substrates. CatPred kcat accepts semicolon-separated Substrates natively, while TurNup requires both Substrates and Products.

job_utils.create_job_directory(public_id: str) str

Create directory structure for a job.

Returns the path to the created job directory.

job_utils.save_job_input_file(file, job_dir: str) str

Save the input CSV file to the job directory.

Returns the path to the saved file.

job_utils.get_experimental_results(use_experimental: bool, methods: Dict[str, str], targets: List[str], dataframe: pandas.DataFrame) Dict[str, list[dict[str, Any]]] | None

Look up experimental kinetic values when the user has opted in.

Experimental lookup is skipped for native full-reaction methods (TurNup). For pair-based methods, Substrates rows are expanded positionally and each protein/substrate pair is looked up independently.

Returns a dict keyed by target (“kcat”, “Km”), or None.

job_utils.extract_job_parameters_from_request(request) Dict[str, Any]

Extract job parameters from an HTTP request.

Returns a parameters dictionary used by process_job_submission_from_params.

job_utils.create_rate_limit_headers(daily_limit: int, remaining: int, ttl: int) Dict[str, str]

Create standard rate-limiting headers for HTTP responses.

job_utils.get_queue_position(job) int | None

Return the 1-based queue position for a Pending job. Returns None if the job is not Pending.

job_utils.create_job_status_response_data(job) Dict[str, Any]

Create a response data dictionary for the job-status endpoint.