biolmai.core package#

Subpackages#

Submodules#

biolmai.core.asynch module#

biolmai.core.auth module#

biolmai.core.const module#

biolmai.core.expression_evaluator module#

Template expression evaluation for protocol outputs.

This module provides safe evaluation of template expressions like ${{ field_name }} and ${{ score > 0.5 }} used in protocol output configurations.

biolmai.core.expression_evaluator.evaluate_expression(expr: str, context: Dict[str, Any]) Any[source]#

Evaluate a template expression safely.

Args:

expr: The expression to evaluate (without ${{ }} wrapper) context: Dictionary of variables available in the expression

Returns:

The evaluated result

Raises:

ValueError: If expression evaluation fails KeyError: If a required variable is missing from context

biolmai.core.expression_evaluator.evaluate_template_value(value: Any, context: Dict[str, Any]) Any[source]#

Evaluate a value that may contain a template expression.

Args:

value: Value that may be a template expression or literal context: Dictionary of variables available for evaluation

Returns:

The evaluated value (or original value if not a template expression)

biolmai.core.expression_evaluator.evaluate_where_clause(expr: str, row: Dict[str, Any]) bool[source]#

Evaluate a where clause expression row-by-row.

Args:

expr: The filter expression (may include ${{ }} wrapper) row: The row data to evaluate against

Returns:

True if row matches the filter, False otherwise

Raises:

ValueError: If expression evaluation fails

biolmai.core.expression_evaluator.extract_template_expr(value: Any) Tuple[bool, str][source]#

Extract template expression from a value if present.

Args:

value: Value that may contain a template expression

Returns:

Tuple of (is_template_expr, expression_string) - is_template_expr: True if value is a template expression - expression_string: The inner expression (without ${{ }} wrapper)

biolmai.core.http module#

biolmai.core.payloads module#

biolmai.core.payloads.INST_DAT_TXT(batch, include_batch_size=False)[source]#
biolmai.core.payloads.PARAMS_ITEMS(batch, key='sequence', params=None, include_batch_size=False)[source]#
biolmai.core.payloads.predict_resp_many_in_one_to_many_singles(resp_json, status_code, batch_id, local_err, batch_size, response_key='results')[source]#

biolmai.core.seqflow_auth module#

MLflow RequestHeaderProvider that uses biolmai credentials for authentication.

This provider reads OAuth tokens from ~/.biolmai/credentials and adds them as Bearer tokens to MLflow requests.

class biolmai.core.seqflow_auth.BiolmaiRequestHeaderProvider[source]#

Bases: object

MLflow RequestHeaderProvider that uses biolmai credentials.

Reads OAuth tokens from ~/.biolmai/credentials (JSON format: {“access”: “…”, “refresh”: “…”}) and adds Authorization header with Bearer token to all MLflow requests.

in_context() bool[source]#

Return True if provider should be used.

Checks if: 1. biolmai package is installed 2. Credentials file exists 3. Credentials file contains access token

request_headers() dict[source]#

Return headers to add to MLflow requests.

Returns Authorization header with Bearer token from biolmai credentials.

biolmai.core.utils module#

Utility functions for BioLM SDK.

biolmai.core.utils.batch_iterable(iterable, batch_size)[source]#
biolmai.core.utils.is_list_of_lists(items, check_n=10)[source]#
biolmai.core.utils.prepare_items_for_api(items: Any | List[Any], type: str | None = None, check_n: int = 10) Tuple[List[dict] | List[List[dict]] | Any, bool][source]#

Normalize items for API calls. Supports list, tuple, single value, and iterables (e.g. generators). Returns (data, is_lol) where is_lol is True for list-of-lists; data is iterable of dicts or list of lists.

biolmai.core.validate module#

class biolmai.core.validate.AAExtended[source]#

Bases: object

class biolmai.core.validate.AAExtendedPlusExtra(extra: List[str])[source]#

Bases: object

class biolmai.core.validate.AAUnambiguous[source]#

Bases: object

class biolmai.core.validate.AAUnambiguousEmpty[source]#

Bases: object

class biolmai.core.validate.AAUnambiguousPlusExtra(extra: List[str])[source]#

Bases: object

class biolmai.core.validate.DNAUnambiguous[source]#

Bases: object

class biolmai.core.validate.PDB[source]#

Bases: object

class biolmai.core.validate.SingleOccurrenceOf(single_token: str)[source]#

Bases: object

class biolmai.core.validate.SingleOrMoreOccurrencesOf(token: str)[source]#

Bases: object

biolmai.core.validate.aa_extended_validator(text: str) str[source]#
biolmai.core.validate.aa_unambiguous_validator(text: str) str[source]#
biolmai.core.validate.dna_unambiguous_validator(text: str) str[source]#
biolmai.core.validate.empty_or_aa_unambiguous_validator(text: str) str[source]#
biolmai.core.validate.empty_or_dna_unambiguous_validator(text: str) str[source]#
biolmai.core.validate.pdb_validator(text: str) str[source]#

Module contents#

Core package for BioLM SDK.