Models Package#
Submodules#
Base Class#
- class server.models.base.Base(**kwargs: Any)[source]#
Bases:
DeclarativeBaseThis class is needed to create all the database tables and establish the database session. This is why it’s inherited in all base classes in the
modelsfolder. All models inherit fromDeclarativeBase, so this helps simplify the inheritance and import slightly.- metadata: ClassVar[MetaData] = MetaData()#
Refers to the
_schema.MetaDatacollection that will be used for new_schema.Tableobjects.See also
orm_declarative_metadata
- registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>#
Refers to the
_orm.registryin use where new_orm.Mapperobjects will be associated.
Run Class#
- class server.models.run.Run(**kwargs)[source]#
Bases:
BaseRun Model Class - Shapes the ‘run’ table in the database run_id: primary key tournament_id: foreign key run_time seed
- Related tables:
submission_run_info
tournament
turn
- results: Mapped[str]#
- run_id: Mapped[int]#
- run_time: Mapped[str]#
- seed: Mapped[int]#
- submission_run_infos: Mapped[list['SubmissionRunInfo']]#
- tournament: Mapped[Tournament]#
- tournament_id: Mapped[int]#
- turns: Mapped[list['Turn']]#
Submission Class#
- class server.models.submission.Submission(**kwargs)[source]#
Bases:
Base‘Submission’ Model Class - Shapes the ‘submission’ table in the database submission_id: primary key team_uuid: foreign key submission_time file_txt
- Related tables:
team
submission_run_info
NOTE: team_uuid is used to refer back to the team that made the submission. When retrieving a submission(s), a team can only access their own submissions
- file_txt: Mapped[str]#
- submission_id: Mapped[int]#
- submission_run_infos: Mapped[list['SubmissionRunInfo']]#
- submission_time: Mapped[str]#
- team: Mapped['Team']#
- team_uuid: Mapped[str]#
Submission Run Info Class#
- class server.models.submission_run_info.SubmissionRunInfo(**kwargs)[source]#
Bases:
Base‘Submission Run Info’ Model Class - Shapes the ‘submission_run_info’ table in the database submission_run_info: primary key run_id: foreign key submission_id: foreign key error_text player_num points_awarded
- Related tables:
submission
run
- error_txt: Mapped[str]#
- player_num: Mapped[int]#
- points_awarded: Mapped[int]#
- run: Mapped['Run']#
- run_id: Mapped[int]#
- submission: Mapped['Submission']#
- submission_id: Mapped[int]#
- submission_run_info_id: Mapped[int]#
Team Class#
- class server.models.team.Team(**kwargs)[source]#
Bases:
BaseTeam Model Class - Shapes the ‘team’ table in the database team_uuid: primary key uni_id: foreign key team_type_id: foreign key team_name: must be unique
- Related tables:
submissions
university
team_type
NOTE: team_uuid is very important and must be protected. Tables that use it are only have it when the team that generated the uuid can access their own information.
- submissions: Mapped[list['Submission']]#
- team_name: Mapped[str]#
- team_type: Mapped['TeamType']#
- team_type_id: Mapped[int]#
- team_uuid: Mapped[str]#
- uni_id: Mapped[int]#
- university: Mapped['University']#
Team Type Class#
- class server.models.team_type.TeamType(**kwargs)[source]#
Bases:
Base‘Team Type’ Model Class - Shapes the ‘team_type’ table in the database team_type_id: primary key team_type_name: must be unique - uniqueness prevents confusion when giving prizes at end of competition eligible
- Related table:
teams
- eligible: Mapped[bool]#
- team_type_id: Mapped[int]#
- team_type_name: Mapped[str]#
- teams: Mapped[list['Team']]#
Timestamp Class#
- class server.models.timestamp.TimeStamp(*args: Any, **kwargs: Any)[source]#
Bases:
TypeDecoratorThis class is used to create time stamps for things like when clients submit code during the competiton.
- impl#
alias of
DateTime
- process_bind_param(value: datetime, dialect)[source]#
Receive a bound parameter value to be converted.
Custom subclasses of
_types.TypeDecoratorshould override this method to provide custom behaviors for incoming data values. This method is called at statement execution time and is passed the literal Python data value which is to be associated with a bound parameter in the statement.The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.
- Parameters:
value – Data to operate upon, of any type expected by this method in the subclass. Can be
None.dialect – the
Dialectin use.
See also
types_typedecorator
_types.TypeDecorator.process_result_value()
- process_result_value(value: datetime, dialect)[source]#
Receive a result-row column value to be converted.
Custom subclasses of
_types.TypeDecoratorshould override this method to provide custom behaviors for data values being received in result rows coming from the database. This method is called at result fetching time and is passed the literal Python data value that’s extracted from a database result row.The operation could be anything desired to perform custom behavior, such as transforming or deserializing data.
- Parameters:
value – Data to operate upon, of any type expected by this method in the subclass. Can be
None.dialect – the
Dialectin use.
See also
types_typedecorator
_types.TypeDecorator.process_bind_param()
Tournament Class#
- class server.models.tournament.Tournament(**kwargs)[source]#
Bases:
Base‘Tournament’ Model Class - Shapes the ‘tournament’ table in the database tournament_id: primary key start_run launcher_version runs_per_client is_finished
- Related table:
runs
- is_finished: Mapped[bool]#
- launcher_version: Mapped[str]#
- runs: Mapped[list['Run']]#
- runs_per_client: Mapped[int]#
- start_run: Mapped[str]#
- tournament_id: Mapped[int]#