src.utils package
Submodules
src.utils.cleanup module
Empty specified folder or file.
src.utils.config_loader module
src.utils.custom_storage module
Extend TinyDB to use YAML as storage.
src.utils.get_bodyweight module
Get the bodyweight from the google sheet.
src.utils.get_breath_holding module
Get breath holding data from Google Sheet and plot min, max, and mean duration.
- src.utils.get_breath_holding.get_breath_holding(sheet_title: str) DataFrame[source]
Get the breath holding data from the Google Sheet.
- Parameters:
sheet_title (str) – Title of the Google Sheet
- Returns:
Breath holding data
- Return type:
pd.DataFrame
- src.utils.get_breath_holding.get_sheet_title(year: int, month: int) str[source]
Get the title of the Google Sheet.
- Parameters:
year (int) – Year
month (int) – Month
- Returns:
Title of the Google Sheet
- Return type:
str
src.utils.get_exercises module
Get all exercises available for a given musclegroup.
- src.utils.get_exercises.get_available_exercises(training_catalogue: str, split: str) list[str][source]
Fetch musclegroup-exercises catalogue.
- Parameters:
training_catalogue (str) – Exercises available for each musclegroup
split (str) – Name of musclegroup
- Returns:
A list of available exercises for a given split / musclegroup
- Return type:
list
src.utils.get_program module
Get the workout program based on the workout date.
src.utils.get_split module
Get the split of the workout.
src.utils.get_volume module
Get the total workout volume of each date in the table. In the case of multiple workouts on the same day, the volume is the sum of the volumes of the workouts.
- src.utils.get_volume.get_total_volume(table) list[tuple[str, int]][source]
Get the total volume of all workouts, summing volumes for the same date.
- Parameters:
table (tinydb.table.Table) – TinyDB table
- Returns:
List of tuples containing the date and total volume of each workout
- Return type:
list[tuple[str, int]]
- src.utils.get_volume.get_weight(s: dict, bodyweight: str, Sidea_9012_Olympic_Hex_Bar: str) int[source]
Get the weight of the exercise.
- Parameters:
s (dict) – Dictionary containing the exercise details
bodyweight (str) – Bodyweight of the person in kg
Sidea_9012_Olympic_Hex_Bar (str) – Weight of the barbell
- Returns:
Weight of the exercise
- Return type:
float
src.utils.get_workout_duration module
Get the workout duration on each date in a given year. In the case of multiple workouts on the same day, the duration is the sum of the durations of the workouts.
- src.utils.get_workout_duration.get_all_durations(year: str) dict[source]
Get the total duration of all workouts in a given year, summing durations for the same date.
- Parameters:
year (str) – Year to get the duration of each workout for.
- Returns:
Dictionary with the date as the key and the duration of the workout as the value.
- Return type:
dict
src.utils.google_sheet module
Google Sheets API.
src.utils.logger_config module
Logging configuration for the project.
src.utils.set_db_and_table module
Set db and table depending on datatype (real/simulated).
- class src.utils.set_db_and_table.TinyDBSingleton(db_path: str, storage=<class 'src.utils.custom_storage.YAMLStorage'>)[source]
Bases:
objectSingleton class for TinyDB.
- src.utils.set_db_and_table.set_db_and_table(datatype, athlete=None, year=None, env='prd')[source]
Set up database and table based on datatype (real/simulated).
- Parameters:
datatype (str) – Type of data to be used, either “real” or “simulated”
athlete (str, optional) – Athlete name, defaults to None
year (int, optional) – Year of the data, defaults to None
env (str, optional) – Environment, defaults to “prd”
- Returns:
Database, table and training catalogue
- Return type:
tuple
src.utils.validate module
Validates workout data from a JSON or YAML file.
- exception src.utils.validate.ExercisesFormatError(value: str, message: str)[source]
Bases:
ExceptionCustom error that is raised when Exercises doesn’t have the right format.
- class src.utils.validate.Workout(*, date: str, start_time: str, end_time: str, split: str, exercises: dict, warmup: str | None = None, cooldown: str | None = None, gym: str | None = None, notes: str | None = None)[source]
Bases:
BaseModelRepresents a Workout from a JSON or YAML file.
- cooldown: str | None
- date: str
- end_time: str
- exercises: dict
- gym: str | None
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- notes: str | None
- split: str
- start_time: str
- warmup: str | None
- class src.utils.validate.WorkoutFactory[source]
Bases:
objectFactory for creating Workout instances.