Server Package#
Subpackages#
- Crud Package
- Models Package
- Schemas Package
- Server Unit Tests Package
Submodules#
Client Runner Class#
- class server.client_runner.ClientRunner[source]#
Bases:
objectThis class is responsible for running submitted client bots against each other and getting the results from the games.
- buffUpData() None[source]#
This will create the different universities and team types to add to the database. This can be modified for different competitions; add or subtract from it as needed. :return: None
- close_server() None[source]#
This method will delete the tournament from the database if it exists and is not finished with all the games. Regardless, the
runner_tempfolder will be deleted. :return: None
- count_number_of_game_appearances(games: list[tuple[server.models.submission.Submission, server.models.submission.Submission]]) int[source]#
Returns the number of games a client appears in. :param games: :return: the count of games a client appears in
- delete_runner_temp() None[source]#
Continually tries to delete the
runner_tempfolder. :return: None
- delete_tournament_cascade(tournament_id: int) None[source]#
Deletes the specified Tournament from the database by using the given id. :param tournament_id: :return: None
- external_runner() None[source]#
This method is extensive and has different steps to it. Print statements help show where the runner is in the process.
Step 1: Get the most recent submission for every team that is in the database.
- Step 2:
If there are less than 2 total submissions, end the method; nothing can be done
Otherwise, proceed to the next step
Step 3: Get all team pairings based on all clients in the database. This will be the pairings for each game.
#. Step 4: Assign a value to
self.total_number_of_games_for_one_clientbased on what’s returned from theself.count_number_of_game_appearances()method. #. Step 5: Insert a new tournament into the database and assign it toself.tournament. #. Step 6: Delete all turns from the database. Witihout doing so, the Turns table will continue to accumulate data for each new tournament and become very cumbersome. #. Step 7: Make therunner_tempandseedsfolders #. Step 8: For the amount of games against the same client specified inserver_config.py, run the runner. #. Step 9: Run the games in parallel with each other to increase performance. :return: None
- get_version_number() str[source]#
runs a script in the runner folder. end path is where the runner is located runner is the name of the script (no extension)
- insert_logs(logs: list[server.schemas.turn.turn_base.TurnBase]) None[source]#
Inserts the given logs in the database. :param logs: a list of Turn objects to insert into the database :return: None
- insert_new_tournament() Tournament[source]#
Inserts a new Tournament in the database and returns it. Relates all the runs in this process together :return: a Tournament object
- insert_run(tournament_id: int, seed_id: int, results: dict) int[source]#
Inserts a new Run in the database and returns it. :param tournament_id: :param seed_id: :param results: :return: the newly inserted Run’s id
- insert_submission_run_info(submission_id: int, run_id: int, error: str | None, player_num: int, points_awarded: int) None[source]#
Inserts a new SubmissionRunInfo entry in the database. :param submission_id: :param run_id: :param error: :param player_num: :param points_awarded: :return: None
- internal_runner(submission_tuple, index) None[source]#
- Parameters:
submission_tuple –
index –
- Returns:
- read_best_logs_and_insert() None[source]#
Finds the best logs from the client and inserts them into the database :return: None
- return_team_parings(submissions: list[server.models.submission.Submission]) list[tuple[server.models.submission.Submission, server.models.submission.Submission]][source]#
This method will take a list of Submission entries and a list with every pairing of them. Also considers the number of games against the same team and increases the pairings by that value. :param submissions: :return: a list of tuples that has the submissions of each team pairing
Database Class#
Main Class#
This file is the main entry point for the server, creating endpoints for the clients. It should be noted that the runners do not require endpoints as they run on the server and utilize the crud files to interact with the DB.
- server.main.get_latest_tournament(db: Session = Depends(get_db))[source]#
An endpoint to retrieve the latest tournament. :param db: DB session. :return:
- server.main.get_runs(db: Session = Depends(get_db))[source]#
Gets the runs in the DB. This is currently unused and would be a resource intensive call if it was used. :param db: DB session. :return:
- server.main.get_submission(submission_id: int, team_uuid: str, db: Session = Depends(get_db))[source]#
Gets the submission information for an id provided. :param submission_id: An int representing the submission id. :param team_uuid: A string representing the team Universally Unique Identifier. :param db: DB session. :return:
- server.main.get_submissions(team_uuid: str, db: Session = Depends(get_db))[source]#
Gets the submissions for a given team. :param team_uuid: A string representing the team Universally Unique Identifier. :param db: DB session. :return:
- server.main.get_team_info(uuid: str, db: Session = Depends(get_db))[source]#
This endpoint is currently unused, this endpoint could be used to get the team information. :param uuid: UUID of the team, also known as vID. :param db: DB session. :return:
- server.main.get_team_types(db: Session = Depends(get_db))[source]#
Gets the team types in the DB. :param db: DB session. :return:
- server.main.get_tournament(tournament_id: int, db: Session = Depends(get_db))[source]#
Gets a single tournament from the DB by id. :param tournament_id: An int representing the id of a tournament. :param db: DB session. :return:
- server.main.get_tournaments(db: Session = Depends(get_db))[source]#
Gets the tournaments from the DB. :param db: DB session. :return:
- server.main.get_universities(db: Session = Depends(get_db))[source]#
Gets the universities in the DB. :param db: DB session. :return:
- server.main.post_submission(submission: SubmissionWTeam, db: Session = Depends(get_db))[source]#
Submission post endpoint. :param submission: Submission with Team schema (dict) is what is expected in the request body. :param db: DB session. :return:
Runner Utils Class#
Server Config Class#
- class server.server_config.Config[source]#
Bases:
objectNumber Of Games Against Same Team#
The Number Of Games Against Same Team is an int representing how many runs should be repeated. It is worth noting that this should be 1 if the development team has ensured that randomness is seeded, ensuring that two games with the same seed play out the same way. Competitor randomness is their own liability and not the development team’s responsibility.
The Sleep Time Between Runs is an int representing the number of seconds between each run of the client runner. Each time the client runner is run, it will generate an entire tournament. The run time of the client runner is not factored into this time.
The End DateTime is an ISO formatted string representing the end of the competition. This will need to be changed for every competition. Ex. ‘YYYY-mm-dd HH:MM’, like ‘2030-01-01 00:00’
The Sleep Time Between Vis is an int representing the number of seconds between each run of the visualizer. Each time the visualizer is run, it will visualize the best runs for each team of the tournament. The run time of the visualizer is not factored into this time. If the visualizer isn’t running on the server, increase this parameter as a potential solution.
- property END_DATETIME: str#
The End DateTime is an ISO formatted string representing the end of the competition. This will need to be changed for every competition. :return: str
- property NUMBER_OF_GAMES_AGAINST_SAME_TEAM: int#
The Number Of Games Against Same Team is an int representing how many runs should be repeated. It is worth noting that this should be 1 if the development team has ensured that randomness is seeded, ensuring that two games with the same seed play out the same way. Competitor randomness is their own liability and not the development team’s responsibility. :return: int
- property SLEEP_TIME_SECONDS_BETWEEN_RUNS: int#
The Sleep Time Between Runs is an int representing the number of seconds between each run of the client runner. Each time the client runner is run, it will generate an entire tournament. The run time of the client runner is not factored into this time. :return: int
- property SLEEP_TIME_SECONDS_BETWEEN_VIS: int#
The Sleep Time Between Vis is an int representing the number of seconds between each run of the visualizer. Each time the visualizer is run, it will visualize the best runs for each team of the tournament. The run time of the visualizer is not factored into this time. If the visualizer isn’t running on the server, increase this parameter as a potential solution. :return: int
Visualizer Runner Class#
- class server.visualizer_runner.VisualizerRunner[source]#
Bases:
object- get_latest_log_files(tournament: Tournament) None[source]#
- get_latest_tournament() Tournament | None[source]#