pytams.sqldb¶
A class for the TAMS data as an SQL database using SQLAlchemy.
Attributes¶
Classes¶
A base class for the tables. |
|
A table storing the trajectories. |
|
A table storing the archived trajectories. |
|
An SQL file. |
Module Contents¶
- class SQLFile(file_name: str)[source]¶
An SQL file.
Allows atomic access to an SQL database from all the workers.
Note: TAMS works with Python indexing starting at 0, while SQL indexing starts at 1. Trajectory ID is updated accordingly when accessing/updating the DB.
- Variables:
_file_name – The file name
- add_trajectory(traj_file: str) None [source]¶
Add a new trajectory to the DB.
- Parameters:
traj_file – The trajectory file of that trajectory
- Raises:
SQLAlchemyError if the DB could not be accessed –
- update_trajectory_file(traj_id: int, traj_file: str) None [source]¶
Update a trajectory file in the DB.
- Parameters:
traj_id – The trajectory id
traj_file – The new trajectory file of that trajectory
- Raises:
SQLAlchemyError if the DB could not be accessed –
- lock_trajectory(traj_id: int, allow_completed_lock: bool = False) bool [source]¶
Set the status of a trajectory to “locked” if possible.
- Parameters:
traj_id – The trajectory id
allow_completed_lock – Allow to lock a “completed” trajectory
- Returns:
True if the trajectory was successfully locked, False otherwise
- Raises:
ValueError if the trajectory with the given id does not exist –
SQLAlchemyError if the DB could not be accessed –
- mark_trajectory_as_completed(traj_id: int) None [source]¶
Set the status of a trajectory to “completed” if possible.
- Parameters:
traj_id – The trajectory id
- Raises:
ValueError if the trajectory with the given id does not exist –
SQLAlchemyError if the DB could not be accessed –
- release_trajectory(traj_id: int) None [source]¶
Set the status of a trajectory to “idle” if possible.
- Parameters:
traj_id – The trajectory id
- Raises:
ValueError if the trajectory with the given id does not exist –
- get_trajectory_count() int [source]¶
Get the number of trajectories in the DB.
- Returns:
The number of trajectories
- fetch_trajectory(traj_id: int) str [source]¶
Get the trajectory file of a trajectory.
- Parameters:
traj_id – The trajectory id
- Returns:
The trajectory file
- Raises:
ValueError if the trajectory with the given id does not exist –
- archive_trajectory(traj_file: str) None [source]¶
Add a new trajectory to the archive container.
- Parameters:
traj_file – The trajectory file of that trajectory
- fetch_archived_trajectory(traj_id: int) str [source]¶
Get the trajectory file of a trajectory in the archive.
- Parameters:
traj_id – The trajectory id
- Returns:
The trajectory file
- Raises:
ValueError if the trajectory with the given id does not exist –