pytams.worker

A set of functions used by TAMS workers.

Functions

update_trajectory_in_sql(→ None)

Wrapper for update SQL trajectory info.

traj_advance_with_exception(→ pytams.trajectory.Trajectory)

Advance a trajectory with exception handling.

pool_worker(→ pytams.trajectory.Trajectory)

A worker to generate each initial trajectory.

ms_worker(→ pytams.trajectory.Trajectory)

A worker to restart trajectories.

worker_async(→ None)

An async worker for the asyncio taskrunner.

Module Contents

update_trajectory_in_sql(traj: pytams.trajectory.Trajectory, sqldb: pytams.sqldb.SQLFile | None = None, db_path: str | None = None) None[source]

Wrapper for update SQL trajectory info.

Parameters:
  • sqldb – the SQL database to update

  • traj – the traj to get the information from

  • db_path – an optional TAMS database path

traj_advance_with_exception(traj: pytams.trajectory.Trajectory, walltime: float, sqldb: pytams.sqldb.SQLFile | None = None, db_path: str | None = None) pytams.trajectory.Trajectory[source]

Advance a trajectory with exception handling.

Parameters:
  • traj – a trajectory

  • walltime – the time limit to advance the trajectory

  • sqldb – a handle to the SQL database

  • db_path – an optional path to the run database

Returns:

The updated trajectory

pool_worker(traj: pytams.trajectory.Trajectory, end_date: datetime.date, sql_path: str | None = None, db_path: str | None = None) pytams.trajectory.Trajectory[source]

A worker to generate each initial trajectory.

Parameters:
  • traj – a trajectory

  • end_date – the time limit to advance the trajectory

  • sql_path – an optional path to the SQL database

  • db_path – an optional path to the run database

Returns:

The updated trajectory

ms_worker(from_traj: pytams.trajectory.Trajectory, rst_traj: pytams.trajectory.Trajectory, min_val: float, new_weight: float, end_date: datetime.date, sql_path: str | None = None, db_path: str | None = None) pytams.trajectory.Trajectory[source]

A worker to restart trajectories.

Parameters:
  • from_traj – a trajectory to restart from

  • rst_traj – the trajectory being restarted

  • min_val – the value of the score function to restart from

  • new_weight – the weight of the new child trajectory

  • end_date – the time limit to advance the trajectory

  • sql_path – a path to the SQL database

  • db_path – an optional path to the run database

async worker_async(queue: asyncio.Queue[tuple[collections.abc.Callable[Ellipsis, Any], pytams.trajectory.Trajectory, float, bool, str]], res_queue: asyncio.Queue[asyncio.Future[pytams.trajectory.Trajectory]], executor: concurrent.futures.Executor) None[source]

An async worker for the asyncio taskrunner.

It wraps the call to one of the above worker functions with access to the queue.

Parameters:
  • queue – a queue from which to get tasks

  • res_queue – a queue to put the results in

  • executor – an executor to launch the work in