in deepracer_offroad_ws/webserver_pkg/webserver_pkg/models.py [0:0]
def get_file_and_folder_info(path):
"""Helper function to get the file and folder information for the model at the
model path sent as parameter.
Args:
path (str): Model directory path.
Returns:
dict: Dictonary with the relevant details about the model.
"""
training_algorithm_display_name = \
constants.TRAINING_ALGORITHM_NAME_MAPPING[constants.INVALID_ENUM_VALUE]
action_space_type_display_name = \
constants.ACTION_SPACE_TYPE_NAME_MAPPING[constants.INVALID_ENUM_VALUE]
model_metadata_sensors_display_names = \
[constants.SENSOR_INPUT_NAME_MAPPING[constants.INVALID_ENUM_VALUE]]
size = utility.execute(["du", "-sh", path])[1].split("\t")[0]
err_code, err_msg, model_metadata_content = \
read_model_metadata_file(os.path.join(path, "model_metadata.json"))
if err_code == 0:
err_code, err_msg, model_metadata_sensors = get_sensors(model_metadata_content)
if err_code == 0:
model_metadata_sensors_display_names = [constants.SENSOR_INPUT_NAME_MAPPING[
constants.SensorInputKeys(sensor)]
for sensor in model_metadata_sensors]
err_code, err_msg, training_algorithm = get_training_algorithm(model_metadata_content)
if err_code == 0:
training_algorithm_display_name = \
constants.TRAINING_ALGORITHM_NAME_MAPPING[
constants.TrainingAlgorithms(training_algorithm)]
err_code, err_msg, action_space_type = get_action_space_type(model_metadata_content)
if err_code == 0:
action_space_type_display_name = \
constants.ACTION_SPACE_TYPE_NAME_MAPPING[
constants.ActionSpaceTypes(action_space_type)]
data = {
"name": os.path.basename(path),
"size": size,
"creation_time": os.path.getmtime(path),
"status": "Ready",
"training_algorithm": training_algorithm_display_name,
"action_space_type": action_space_type_display_name,
"sensors": ", ".join(model_metadata_sensors_display_names)
}
return data