swh.scheduler.model module

class swh.scheduler.model.BaseSchedulerModel[source]

Bases: object

Base class for database-backed objects.

These database-backed objects are defined through attrs-based attributes that match the columns of the database 1:1. This is a (very) lightweight ORM.

These attrs-based attributes have metadata specific to the functionality expected from these fields in the database:

  • primary_key: the column is a primary key; it should be filtered out when doing an update of the object

  • auto_primary_key: the column is a primary key, which is automatically handled by the database. It will not be inserted to. This must be matched with a database-side default value.

  • auto_now_add: the column is a timestamp that is set to the current time when the object is inserted, and never updated afterwards. This must be matched with a database-side default value.

  • auto_now: the column is a timestamp that is set to the current time when the object is inserted or updated.

classmethod primary_key_columns() → Tuple[str, ][source]

Get the primary key columns for this object type

classmethod select_columns() → Tuple[str, ][source]

Get all the database columns needed for a select on this object type

classmethod insert_columns_and_metavars() → Tuple[Tuple[str, ], Tuple[str, ]][source]
Get the database columns and metavars needed for an insert or update on

this object type.

This implements support for the auto_* field metadata attributes.

class swh.scheduler.model.Lister(name: str, instance_name: str, id: Optional[uuid.UUID] = None, current_state: Dict[str, Any] = NOTHING, created: Optional[datetime.datetime] = None, updated: Optional[datetime.datetime] = None)[source]

Bases: swh.scheduler.model.BaseSchedulerModel

class swh.scheduler.model.ListedOrigin(lister_id: uuid.UUID, url: str, visit_type: str, extra_loader_arguments: Dict[str, str] = NOTHING, last_update: Optional[datetime.datetime] = None, enabled: bool = True, first_seen: Optional[datetime.datetime] = None, last_seen: Optional[datetime.datetime] = None)[source]

Bases: swh.scheduler.model.BaseSchedulerModel

Basic information about a listed origin, output by a lister

swh.scheduler.model.convert_listed_origin_page_token(input: Union[None, Tuple[uuid.UUID, str], List[Union[uuid.UUID, str]]]) → Optional[Tuple[uuid.UUID, str]][source]
class swh.scheduler.model.PaginatedListedOriginList(origins: List[swh.scheduler.model.ListedOrigin], next_page_token=None)[source]

Bases: swh.scheduler.model.BaseSchedulerModel

A list of listed origins, with a continuation token