Utilities API¶
Core utility functions for BioML-bench.
authenticate_kaggle_api ¶
Authenticates the Kaggle API and returns an authenticated API object, or raises an error if authentication fails.
read_jsonl ¶
Read a JSONL file and return a list of dictionaries of its content.
Args: file_path (str): Path to the JSONL file. skip_commented_out_lines (bool): If True, skip commented out lines.
Returns: list[dict]: List of dictionaries parsed from the JSONL file.
generate_run_id ¶
Creates a unique run ID for a specific task and agent combo
create_run_dir ¶
Creates a directory for the run.
compress ¶
Compresses the contents of a source directory to a compressed file.
extract ¶
Extracts the contents of a compressed file to a destination directory.
import_fn ¶
Imports a function from a module given a string in the format
potentially.nested.module_name:fn_name
.
Basically equivalent to from potentially.nested.module_name import fn_name
.
get_path_to_callable ¶
Retrieves the file path of the module where the given callable is defined.
Args: callable (Callable): The callable for which the module path is required.
Returns: Path: The relative path to the module file from the current working directory.
Raises: AssertionError: If the module does not have a file path.
get_diff ¶
Finds the differences between two nested dictionaries and returns a diff string.
read_csv ¶
Reads a CSV file and returns a DataFrame with custom default kwargs.
generate_submission_from_metadata ¶
generate_submission_from_metadata(
metadata_path,
output_path=None,
rel_log_path=Path("logs/"),
rel_code_path=Path("code/"),
)
Generate a submission.jsonl file from agent run metadata.
This function reads the metadata.json file created by run_agent_async()
and creates a JSONL file mapping task IDs to their submission file paths,
which can be used directly with the biomlbench grade
command.
Args: metadata_path: Path to the metadata.json file output_path: Path for the output submission.jsonl file (defaults to same directory as metadata) rel_log_path: Path to logfile relative to run directory rel_code_path: Path to code file relative to run directory
Returns: Path to the generated submission.jsonl file