Skip to content

Commit 3faa738

Browse files
committed
feature: Add support for sysman python bindings
Related-To: NEO-NEO-17257 Signed-off-by: shubham kumar <shubham.kumar@intel.com>
1 parent 51bc498 commit 3faa738

3 files changed

Lines changed: 32 additions & 10 deletions

File tree

bindings/sysman/python/.flake8

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[flake8]
2+
max-line-length = 140
3+
extend-ignore =
4+
# F403: 'from module import *' used; unable to detect undefined names
5+
# F405: name may be undefined, or defined from star imports
6+
# Acceptable for ctypes bindings where wildcard imports are idiomatic
7+
F403,
8+
F405,
9+
# E266: too many leading '#' for block comment
10+
# Used for visual section separators
11+
E266
12+
per-file-ignores =
13+
# Allow module-level imports not at top of file in examples
14+
source/examples/pyzes_example.py:E402

bindings/sysman/python/source/examples/pyzes_black_box_test.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# Add the source directory to Python path so we can import pyzes
1919
script_dir = os.path.dirname(os.path.abspath(__file__))
20-
source_dir = os.path.join(script_dir, "..", "source")
20+
source_dir = os.path.join(script_dir, "..")
2121
source_dir = os.path.abspath(source_dir)
2222
if source_dir not in sys.path:
2323
sys.path.insert(0, source_dir)

bindings/sysman/python/source/examples/pyzes_example.py

100644100755
Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
# Add the source directory to Python path so we can import pyzes
2626
script_dir = os.path.dirname(os.path.abspath(__file__))
27-
source_dir = os.path.join(script_dir, "..", "source")
27+
source_dir = os.path.join(script_dir, "..")
2828
source_dir = os.path.abspath(source_dir)
2929
if source_dir not in sys.path:
3030
sys.path.insert(0, source_dir)
@@ -38,10 +38,11 @@
3838
os.environ["ZELLO_SYSMAN_USE_ZESINIT"] = "1"
3939

4040

41-
#####################################################################################################################################
41+
###############################################################################
4242
# Helper utilities ##
4343
def zes_driver_get_device_by_uuid(hDriver, uuid_bytes: bytes):
44-
"""Helper: given a 16-byte UUID (from core device properties), retrieve the corresponding Sysman device handle.
44+
"""Helper: given a 16-byte UUID (from core device properties), retrieve
45+
the corresponding Sysman device handle.
4546
Returns (result_code, device_handle, on_subdevice(bool), subdevice_id(int)).
4647
"""
4748
if len(uuid_bytes) != ZES_MAX_UUID_SIZE:
@@ -187,7 +188,9 @@ def enumerate_devices(hDriver, devices, dev_count):
187188
if rc2 == 0:
188189
same = handle_val(mapped_handle) == handle_val(devices[i])
189190
print(
190-
f" zesDriverGetDeviceByUuidExp: SUCCESS same_handle={same} on_subdevice={on_sub} subdevice_id={sub_id}"
191+
f" zesDriverGetDeviceByUuidExp: SUCCESS "
192+
f"same_handle={same} on_subdevice={on_sub} "
193+
f"subdevice_id={sub_id}"
191194
)
192195
else:
193196
print(f" zesDriverGetDeviceByUuidExp: rc={rc2}")
@@ -330,7 +333,9 @@ def demonstrate_memory_state(hDriver, devices, dev_count):
330333
continue
331334
print(f" Bandwidth: {mem_bandwidth}")
332335
print(
333-
f" Max Bandwidth: {mem_bandwidth.maxBandwidth:,} bytes/sec ({mem_bandwidth.maxBandwidth / (1024**3):.2f} GB/s)"
336+
f" Max Bandwidth: {mem_bandwidth.maxBandwidth:,} "
337+
f"bytes/sec "
338+
f"({mem_bandwidth.maxBandwidth / (1024**3):.2f} GB/s)"
334339
)
335340
print(f" Read Counter: {mem_bandwidth.readCounter:,} bytes")
336341
print(f" Write Counter: {mem_bandwidth.writeCounter:,} bytes")
@@ -440,17 +445,20 @@ def demonstrate_power_energy(hDriver, devices, dev_count):
440445
energy_counter2.timestamp - energy_counter.timestamp
441446
) / 1000000.0
442447

443-
print(f" Second reading:")
448+
print(" Second reading:")
444449
print(
445-
f" Energy: {energy_counter2.energy} microjoules ({energy_counter2.energy / 1000000.0:.6f} joules)"
450+
f" Energy: {energy_counter2.energy} microjoules "
451+
f"({energy_counter2.energy / 1000000.0:.6f} joules)"
446452
)
447453
print(
448-
f" Energy consumed: {energy_diff} microjoules ({energy_diff / 1000000.0:.6f} joules)"
454+
f" Energy consumed: {energy_diff} microjoules "
455+
f"({energy_diff / 1000000.0:.6f} joules)"
449456
)
450457
if time_diff > 0:
451458
avg_power = (energy_diff / 1000000.0) / time_diff # Watts
452459
print(
453-
f" Average power: {avg_power:.6f} watts over {time_diff:.6f} seconds"
460+
f" Average power: {avg_power:.6f} watts "
461+
f"over {time_diff:.6f} seconds"
454462
)
455463

456464
except Exception as e:

0 commit comments

Comments
 (0)