pyrevs.strategies.ams.sql¶
An extension class for the AMS data as an SQL database using SQLAlchemy.
Classes¶
A table storing the splitting iterations. |
|
An extension of the core database holding AMS iterations repertoire. |
Module Contents¶
- class SplittingIterations[source]¶
Bases:
pyrevs.core.CoreBaseA table storing the splitting iterations.
- class AMSDB(engine: sqlalchemy.engine.Engine)[source]¶
An extension of the core database holding AMS iterations repertoire.
Allows atomic access to an SQL database from all the workers.
- Variables:
_file_name – The file name
- session_scope() collections.abc.Generator[sqlalchemy.orm.Session, None, None][source]¶
Provide a transactional scope around a series of operations.
- add_splitting_data(k: int, bias: int, weight: float, discarded_ids: list[int], ancestor_ids: list[int], min_vals: list[float], min_max: list[float]) None[source]¶
Add a new splitting data to the DB.
- Parameters:
k – The splitting iteration index
bias – The number of restarted trajectories
weight – Weight of the ensemble at the current iteration
discarded_ids – The list of discarded trajectory ids
ancestor_ids – The list of trajectories used to restart
min_vals – The list of minimum values
min_max – The score minimum and maximum values
- update_splitting_data(k: int, bias: int, weight: float, discarded_ids: list[int], ancestor_ids: list[int], min_vals: list[float], min_max: list[float]) None[source]¶
Update the last splitting data row to the DB.
- Parameters:
k – The splitting iteration index
bias – The number of restarted trajectories
weight – Weight of the ensemble at the current iteration
discarded_ids – The list of discarded trajectory ids
ancestor_ids – The list of trajectories used to restart
min_vals – The list of minimum values
min_max – The score minimum and maximum values
- mark_last_iteration_as_completed() None[source]¶
Mark the last splitting iteration as complete.
By default, iteration data append to the SQL table with a state “locked” to indicate an iteration being worked on. Upon completion, mark it as “completed” otherwise the iteration is considered incomplete, i.e. interrupted by some error or wall clock limit.
- get_k_split() int[source]¶
Get the current splitting iteration counter.
- Returns:
The ksplit from the last entry in the SplittingIterations table
- check_new_min_of_maxes(newmin: float) None[source]¶
Compare the incoming min to the last entry.
When running pyREVS with AMS, at each new iteration the ensemble minimum of maximum should be strictly above the previous iteration’s one.
- Parameters:
newmin – the new minimum of maximums
- get_iteration_count() int[source]¶
Get the number of splitting iteration stored.
- Returns:
The length of the SplittingIterations table
- fetch_splitting_data(k_id: int) tuple[int, int, float, list[int], list[int], list[float], list[float], str] | None[source]¶
Get the splitting iteration data for a given iteration.
- Parameters:
k_id – The iteration id
- Returns:
The splitting iteration data
- Raises:
ValueError if the splitting iteration with the given id does not exist –
- get_ongoing() list[int] | None[source]¶
Get the list of ongoing trajectories if any.
- Returns:
Either a list trajectories or None if nothing was left to do
- get_weights() numpy.typing.NDArray[numpy.number][source]¶
Read the weights from the database.
- Returns:
the weight for each splitting iteration as a numpy array
- get_biases() numpy.typing.NDArray[numpy.number][source]¶
Read the biases from the database.
- Returns:
the bias for each splitting iteration as a numpy array
- get_minmax() numpy.typing.NDArray[numpy.number][source]¶
Read the min/max from the database.
- Returns:
the 2D Numpy array with k_index, min, max