pytams.worker

A set of functions used by TAMS workers.

Functions

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

traj_advance_with_exception(traj: pytams.trajectory.Trajectory, walltime: float, a_db: pytams.database.Database | None) pytams.trajectory.Trajectory[source]

Advance a trajectory with exception handling.

Parameters:
  • traj – a trajectory

  • walltime – the time limit to advance the trajectory

  • a_db – a database

Returns:

The updated trajectory

pool_worker(traj: pytams.trajectory.Trajectory, end_date: datetime.date, 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

  • db_path – a path to a TAMS database or None

Returns:

The updated trajectory

ms_worker(from_traj: pytams.trajectory.Trajectory, rst_traj: pytams.trajectory.Trajectory, min_val: float, end_date: datetime.date, 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

  • end_date – the time limit to advance the trajectory

  • db_path – a database path or None

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