Skip to content

orcalib.curate.runs_handle#

RunsHandle #

1
2
3
RunsHandle(
    database_name, model_id=None, model_version=None
)

A handle to query runs of a model.

Parameters:

  • database_name (str) –

    The name of the database the runs are stored in.

  • model_id (str | None, default: None ) –

    The model id to filter the model runs by.

  • model_version (str | None, default: None ) –

    The model version to filter the model runs by.

select #

select(*args)

A thin peewee wrapper method for selecting columns in the query.

Parameters:

  • args (str | Column | Alias, default: () ) –

    The columns to select

Returns:

Examples:

>>> my_query.select("id", "timestamp")

ModelRunsSelectQuery #

ModelRunsSelectQuery(table, *args)

Bases: BaseSelectQuery

having #

having(*args)

Thin peewee wrapper method for having filters on aggregate function results.

Parameters:

  • args (Any, default: () ) –

    The conditions to filter by

Returns:

  • BaseSelectQuery

    The query object for chaining

Examples:

>>> my_query.having(sql("avg_model_feedback") == 1.0)

limit #

limit(limit)

Thin peewee wrapper method to limit the number of rows returned.

Parameters:

  • limit (int) –

    The maximum number of rows to return

Returns:

  • BaseSelectQuery

    The query object for chaining

Examples:

>>> my_query.limit(5)

offset #

offset(offset)

Thin peewee wrapper method for applying an offset to the query.

Parameters:

  • offset (int) –

    The number of rows to skip

Returns:

  • BaseSelectQuery

    The query object for chaining

Examples:

>>> my_query.offset(5)

order_by #

order_by(*args)

Thin peewee wrapper method for ordering the results.

Parameters:

  • args (Any, default: () ) –

    The columns to order by

Returns:

  • BaseSelectQuery

    The query object for chaining

Examples:

>>> my_query.order_by(runs_handle.id.desc())

where #

where(*args)

Thin peewee wrapper method for filtering the results.

Parameters:

  • args (Any, default: () ) –

    The conditions to filter by

Returns:

  • BaseSelectQuery

    The query object for chaining

Examples:

>>> my_query.where(runs_handle.id == 42)

df #

df(limit=None, offset=None)

Fetch rows from the table and return as a DataFrame

Parameters:

  • limit (int | None, default: None ) –

    The maximum number of rows to return, if None returns all rows

  • offset (int | None, default: None ) –

    The number of rows to skip, if None starts from the beginning

Returns:

  • DataFrame

    A pandas data frame containing the rows

sql #

sql()

Debugging method to get the SQL query and parameters.

Returns:

  • query ( str ) –

    The SQL query

  • params ( tuple[Any, ...] ) –

    The parameters for the query

aggregate_memory_lookups #

aggregate_memory_lookups(*args)

Thin peewee wrapper method for aggregating the memory lookups.

Parameters:

  • args (str | Column | Alias, default: () ) –

    The columns to aggregate by

Returns:

Examples:

>>> my_query.aggregate_memory_lookups(
...     fn.avg(runs.lookups.score).alias("avg_score"),
... )

select_all_feedback #

select_all_feedback()

Method for returning all feedback with the run. This sets a flag to fetch all feedback.

Returns:

join_memory_lookups #

join_memory_lookups()

Thin peewee wrapper method for joining the memory lookups.

Returns:

fetch #

fetch(limit=None, offset=None)

Fetches the runs from the database.

Parameters:

  • limit (int | None, default: None ) –

    The number of rows to fetch

  • offset (int | None, default: None ) –

    The number of rows to skip

Returns:

  • list[dict[str, Any]]

    A list of dictionaries mapping column names to values.

Examples:

>>> my_query.fetch(1)
[{'id': 42, tags: ['tag1', 'tag2'], ...}]