maeser.admin_portal.design_model module#

This module is used by flask_admin_portal.py and contains several helper functions that handle designing and editing class chatbot models.

maeser.admin_portal.design_model.delete_datasets(model_dir: str)[source]#

Deletes specified datasets from a course model. The specified datasets are retrieved from the last request form.

Parameters:

model_dir (str) – The directory containing the model’s data.

maeser.admin_portal.design_model.get_model_config(upload_root: str) tuple[str, str, str, list[str], dict[str, list[werkzeug.datastructures.FileStorage]]][source]#

Retrieves config for a course model from a post request.

Parameters:

upload_root (str) – The root directory where all course models are created and modified.

Raises:

AttributeError – If the request form is missing ‘course_id’.

Returns:

str, model_dir: str, bot_path: str, rules: list[str], datasets: dict[str, list[FileStorage]] ): Parsed config data from the request form. See the parameters of save_model for more info.

Return type:

( course_id

maeser.admin_portal.design_model.load_datasets(model_dir: str) list[str][source]#

Loads the names of a course model’s existing datasets.

Parameters:

model_dir (str) – The directory containing the model’s data.

Returns:

The names of the model’s datasets.

Return type:

list[str]

maeser.admin_portal.design_model.load_rules(bot_path: str) list[str][source]#

Loads the rules for a course from the model’s ‘bot.txt’ file.

Parameters:

bot_path (str) – The path of the model’s ‘bot.txt’ file.

Returns:

A list of the model’s rules.

Return type:

list[str]

maeser.admin_portal.design_model.process_datasets(model_dir: str)[source]#
maeser.admin_portal.design_model.remove_class_model(upload_root: str, course_id: str)[source]#

Removes a course model from the root bot data directory.

Parameters:
  • upload_root (str) – The root directory where all course models are created and modified.

  • course_id (str) – The code used to identify the class.

Raises:

NotADirectoryError – If the model’s directory does not exist/cannot be found.

maeser.admin_portal.design_model.save_model(upload_root: str, course_id: str, model_dir: str, bot_path: str, rules: list[str], datasets: dict[str, list[werkzeug.datastructures.FileStorage]])[source]#

Saves the course model using the provided config.

Parameters:
  • upload_root (str) – The root directory where all course models are created and modified.

  • course_id (str) – The code used to identify the class.

  • model_dir (str) – The directory to where the model’s data will be saved.

  • bot_path (str) – The path to where the model’s ‘bot.txt’ file will be saved.

  • rules (list[str]) – The list of rules for the model’s chatbot to follow.

  • datasets (dict[str, list[FileStorage]]) – A dictionary containing the path to each dataset (key) and a list of its files (value).