Skip to content

Commit

Permalink
Add supress_dc_critical flag to supress dc task generation by hash. (#…
Browse files Browse the repository at this point in the history
…496)

Summary:
Pull Request resolved: #496

For devices which are known to disconnect frequently.  Adds flag to run_lab to specify a json file in the form {"hashes": ["hash_01", ..]} which will tell DeviceMonitor class to only log dc as an error in the lab, and supress task generation for the d/c.

Reviewed By: axitkhurana

Differential Revision: D36085728

fbshipit-source-id: 5ce82ddda4c07854affb03397b5a62851292297a
  • Loading branch information
Mark Anderson authored and facebook-github-bot committed May 3, 2022
1 parent 06a79db commit d216422
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 13 additions & 3 deletions benchmarking/platforms/device_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ def __init__(self, args: Dict, db: DBDriver):
self.usb_controller = USBController(self.args.usb_hub_device_mapping)
else:
self.usb_controller = None
# specify device hashes to suppress critical logging for when d/c occurs.
self.suppress_dc_critical_mapping = {}
if self.args.suppress_dc_critical_mapping:
try:
with open(self.args.suppress_dc_critical_mapping) as f:
self.suppress_dc_critical_mapping = set(json.load(f)["hashes"])
except Exception:
getLogger.exception("suppress_dc_critical_mapping was not loaded.")

def getLabDevices(self):
"""Return a reference to the lab's device meta data."""
Expand Down Expand Up @@ -186,9 +194,11 @@ def _handleDCDevices(self, online_hashes):
f"Device {dc_device} has shown as disconnected {dc_count} time(s) and was able to be reconnected."
)
else:
getLogger().critical(
f"Device {dc_device} has shown as disconnected {dc_count} time(s) ({dc_count * self.device_monitor_interval}s) and is offline.",
)
device_offline_message = f"Device {dc_device} has shown as disconnected {dc_count} time(s) ({dc_count * self.device_monitor_interval}s) and is offline."
if hash in self.suppress_dc_critical_mapping:
getLogger().error(device_offline_message)
else:
getLogger().critical(device_offline_message)
self.online_devices.remove(dc_device)
self.device_dc_count.pop(hash)

Expand Down
5 changes: 5 additions & 0 deletions benchmarking/run_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@
default=None,
help="Specify the usb hub hash, port mapping to devices",
)
parser.add_argument(
"--suppress_dc_critical_mapping",
default=None,
help="Suppress critical logs for device dc by hash.",
)
parser.add_argument(
"--file_storage", help="The storage engine for uploading and downloading files"
)
Expand Down

0 comments on commit d216422

Please sign in to comment.