+
+def obj_to_yaml(obj: object) -> str:
+ """
+ Converts object to yaml format
+ :return: yaml data
+ """
+ # dump to yaml
+ dump_text = yaml.dump(obj, default_flow_style=False, indent=2)
+ # split lines
+ lines = dump_text.splitlines()
+ # remove !!python/object tags
+ yaml_text = ""
+ for line in lines:
+ index = line.find("!!python/object")
+ if index >= 0:
+ line = line[:index]
+ yaml_text += line + "\n"
+ return yaml_text
+
+
+def obj_to_dict(obj: object) -> dict:
+ """
+ Converts object to dictionary format
+ :return: dict data
+ """
+ # convert obj to yaml
+ yaml_text = obj_to_yaml(obj)
+ # parse to dict
+ return yaml.load(yaml_text, Loader=yaml.Loader)
+
+
+def get_ee_id_components(ee_id: str) -> Tuple[str, str, str]:
+ """
+ Get model, application and machine components from an execution environment id
+ :param ee_id:
+ :return: model_name, application_name, machine_id
+ """
+ parts = ee_id.split(".")
+ if len(parts) != 3:
+ raise Exception("invalid ee id.")
+ model_name = parts[0]
+ application_name = parts[1]
+ machine_id = parts[2]
+ return model_name, application_name, machine_id
+
+
+def generate_random_alfanum_string(size: int) -> str:
+ """
+ Generate random alfa-numeric string with a size given by argument
+ :param size:
+ :return: random generated string
+ """
+
+ return "".join(
+ secrets.choice(string.ascii_letters + string.digits) for i in range(size)
+ )