Publishing 2019 R3 content
[platform/upstream/dldt.git] / inference-engine / ie_bridges / python / sample / hello_query_device / hello_query_device.py
1 import sys
2
3 from openvino.inference_engine import IECore
4
5
6 def param_to_string(metric):
7     if isinstance(metric, (list, tuple)):
8         return ", ".join([str(val) for val in metric])
9     elif isinstance(metric, dict):
10         str_param_repr = ""
11         for k, v in metric.items():
12             str_param_repr += "{}: {}\n".format(k, v)
13         return str_param_repr
14     else:
15         return str(metric)
16
17
18 def main():
19     ie = IECore()
20     print("Available devices:")
21     for device in ie.available_devices:
22         print("\tDevice: {}".format(device))
23         print("\tMetrics:")
24         for metric in ie.get_metric(device, "SUPPORTED_METRICS"):
25             try:
26               metric_val = ie.get_metric(device, metric)
27               print("\t\t{}: {}".format(metric, param_to_string(metric_val)))
28             except TypeError:
29               print("\t\t{}: UNSUPPORTED TYPE".format(metric))
30
31         print("\n\tDefault values for device configuration keys:")
32         for cfg in ie.get_metric(device, "SUPPORTED_CONFIG_KEYS"):
33             try:
34               cfg_val = ie.get_config(device, cfg)
35               print("\t\t{}: {}".format(cfg, param_to_string(cfg_val)))
36             except TypeError:
37               print("\t\t{}: UNSUPPORTED TYPE".format(cfg))
38
39 if __name__ == '__main__':
40     sys.exit(main() or 0)