nolito.training module¶
- class nolito.training.Training(nolio_id=None, id_partner=None, name=None, date_start=None, date_end=None, hour_start=None, description=None, sport=None, sport_id=None, duration=None, distance=None, feeling=None, rpe=None, elevation_gain=None, elevation_loss=None, load_foster=None, load_coggan=None, is_competition=None, kilojoules=None, avg_watt=None, max_watt=None, athlete_id=None, structured_workout=None, planned=True)[source]¶
Bases:
objectA training payload for the Nolio API
Full reference: https://github.com/NolioApp/NolioAPI-Documentation/wiki/Training-Object
This is a Data Class <https://docs.python.org/3/library/dataclasses.html>_ so all parameters are also attributes.
- Parameters:
nolio_id (
int|None) – ID assigned by the nolio websiteid_partner (
int|None) – ID assigned by the local “partner” appname (
str|None) – Name of the trainingdate_start (
str|None) – Start date (YYYY-MM-DD)date_end (
str|None) – End date (YYYY-MM-DD)hour_start (
str|None) – Start timedescription (
str|None) – Training descriptionsport (
str|None) – Sport namesport_id (
int|None) – Nolio sport ID (https://github.com/NolioApp/NolioAPI-Documentation/wiki/Training-Object#sport-map)duration (
int|None) – Workout duration in mindistance (
int|float|None) – Workout distance in kmfeeling (
int|None) – Athlete feelingrpe (
int|None) – Athlete RPEelevation_gain (
int|None) – Elevation gainelevation_loss (
int|None) – Elevation lossload_foster (
float|None) – Foster loadload_coggan (
float|None) – Coggan loadis_competition (
bool|None) –Trueif the workout is a competitionkilojoules (
int|None) – Kilojoules spentavg_watt (
int|None) – Average power in wattsmax_watt (
int|None) – Max power in wattsathlete_id (
int|None) – Athlete ID (assigned by Nolio)structured_workout (
list|None) – Structured workout dictionaryplanned (
bool) – Whether this is a planned workout. Not sent to the Nolio API, for local use only.
- property completed: bool¶
Is the training a completed workout?
return: Returns the opposite of
Training.planned
- classmethod from_json(path)[source]¶
Load the training from a JSON file
- Parameters:
path (
Path|str) – Path to the JSON file- Raises:
TypeError – Raised if the JSON data is not a dictionary
- Return type:
Self- Returns:
The training object read from the file
- to_dict(keep_none=False)[source]¶
Convert the training object to a dictionary
This is useful to interact with the Nolio API or to save trainings to JSON files.
- Parameters:
keep_none (
bool) – Keep fields that have a none value ifTrue(defaults toFalse)- Return type:
dict[str,Any]- Returns:
The training dictionary
- to_edit_dict()[source]¶
Convert the training object to a dictioanry for
POSTrequestsOnly keys compatible with the API’s
POSTrequests are included, when they are not None.- Return type:
dict- Returns:
The
POSTready dictionary
- to_json(path)[source]¶
Save the training to a json file
Uses
Training.to_dict()- Parameters:
path (
Path|str) – Path to the JSON file
- class nolito.training.TrainingSet(trainings)[source]¶
Bases:
Sequence[Training]A set of
TrainingobjectsUseful to construct a training calendar or a training plan
- Parameters:
trainings (
list[dict[str,Any] |Training]) – List of training objects or dictionaries used as input Iftrainingscontains dictionaries, they are converted toTraininginstances- Variables:
trainings (
list[Training]) – List of training objects stored internally
- classmethod from_json(path)[source]¶
Create a training set from a JSON file
- Parameters:
path (
Path|str) – Path to the JSON file- Raises:
TypeError – Raised if the JSON is not a list of dictionaries
- Return type:
Self- Returns:
The newly create training set
- to_dicts()[source]¶
Convert the objects to a list of dictionaries
Converts the trainings with
Training.to_dict()- Return type:
list[dict[str,Any]]- Returns:
List of dictionaries with training info