devo_ml.modelmanager.profile
#
Profile helper functions.
- read_profile_from_file(profile, path=None)[source]#
Reads the profile located in a file.
A set of paths is built in order to search for a profile file:
path if provided.
current directory,
.
.user’s home directory,
/home/<user>/
.
The file to read the profile will be the file contained in path if there is a file name in path, otherwise modelmanager.ini.
A profile has this shape in a profile file:
[dev] url = https://dev_url token = 8a3vf98ai28sar1234lkj2l43td6f89a auth_type = standalone download_path = ~/models
and it is parsed to this python dict:
{ "url": "https://dev_url", "token": "8a3vf98ai28sar1234lkj2l43td6f89a", "auth_type": "standalone", "download_path": "~/models", }
- Parameters:
- Raises:
ProfileError – if no file found, or if profile not found in the file, or if values of the profile don’t pass the validation, or any syntax error in the file detected
- Return type:
- Returns:
The profile values found
- get_required_profile_value(section, key)[source]#
Gets the value of a key of a ConfigParser object section.
The key must exists in the section, and the value must not be empty, otherwise an exception will be raised.
- Parameters:
section (
SectionProxy
) – The config parser section to extract the valuekey (
str
) – The target key
- Raises:
ProfileValueRequired – If value found is empty or key doesn’t exist
- Return type:
- Returns:
The value found
- resolve_profile_file(paths, file_name=None)[source]#
Searches a profile file in a list of paths.
It searches for file_name if it is provided, modelmanager.ini otherwise.
- Parameters:
- Raises:
ProfileError – If no file found in paths set.
- Return type:
- Returns:
The file path of the profile file found