Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce non-debug logging #95

Merged
merged 7 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
types: [file, python]
args: ["--profile", "black", "--filter-files", "--gitignore"]
- repo: https://github.com/psf/black
rev: 23.10.0
rev: 23.10.1
hooks:
- id: black
types: [file, python]
Expand Down
2 changes: 1 addition & 1 deletion scos_actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "6.4.1"
__version__ = "6.4.2"
2 changes: 1 addition & 1 deletion scos_actions/actions/calibrate_y_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __init__(self, parameters, sigan, gps=None):
try:
self.iir_apply = get_parameter(IIR_APPLY, parameters)
except ParameterException:
logger.info(
logger.debug(
"Config parameter 'iir_apply' not provided. "
+ "No IIR filtering will be used during calibration."
)
Expand Down
16 changes: 7 additions & 9 deletions scos_actions/calibration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ def get_sigan_calibration(sigan_cal_file: Path) -> Calibration:
"""
try:
sigan_cal = load_from_json(sigan_cal_file)
except Exception as err:
except Exception:
sigan_cal = None
logger.error("Unable to load sigan calibration data, reverting to none")
logger.exception(err)
logger.exception("Unable to load sigan calibration data, reverting to none")
return sigan_cal


Expand All @@ -34,16 +33,15 @@ def get_sensor_calibration(sensor_cal_file: Path) -> Calibration:
"""
try:
sensor_cal = load_from_json(sensor_cal_file)
except Exception as err:
except Exception:
sensor_cal = None
logger.error("Unable to load sensor calibration data, reverting to none")
logger.exception(err)
logger.exception("Unable to load sensor calibration data, reverting to none")
return sensor_cal


logger.info(f"Loading sensor cal file: {SENSOR_CALIBRATION_FILE}")
logger.debug(f"Loading sensor cal file: {SENSOR_CALIBRATION_FILE}")
sensor_calibration = get_sensor_calibration(SENSOR_CALIBRATION_FILE)
logger.info(f"Loading sigan cal file: {SIGAN_CALIBRATION_FILE}")
logger.debug(f"Loading sigan cal file: {SIGAN_CALIBRATION_FILE}")
sigan_calibration = get_sigan_calibration(SIGAN_CALIBRATION_FILE)
if sensor_calibration:
logger.info(f"Last sensor cal: {sensor_calibration.last_calibration_datetime}")
logger.debug(f"Last sensor cal: {sensor_calibration.last_calibration_datetime}")
7 changes: 3 additions & 4 deletions scos_actions/capabilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
SENSOR_DEFINITION_HASH = None
SENSOR_LOCATION = None

logger.info(f"Loading {SENSOR_DEFINITION_FILE}")
logger.debug(f"Loading {SENSOR_DEFINITION_FILE}")
try:
capabilities["sensor"] = utils.load_from_json(SENSOR_DEFINITION_FILE)
except Exception as e:
Expand All @@ -32,7 +32,7 @@
sensor_loc["z"] if "z" in sensor_loc else None,
)
except:
logger.warning("Failed to get sensor location from sensor definition.")
logger.exception("Failed to get sensor location from sensor definition.")

# Generate sensor definition file hash (SHA 512)
try:
Expand All @@ -41,7 +41,6 @@
SENSOR_DEFINITION_HASH = hashlib.sha512(sensor_def.encode("UTF-8")).hexdigest()
capabilities["sensor"]["sensor_sha512"] = SENSOR_DEFINITION_HASH
except:
logger.error(f"Unable to generate sensor definition hash")
capabilities["sensor"]["sensor_sha512"] = "ERROR GENERATING HASH"
# SENSOR_DEFINITION_HASH is None, do not raise Exception
logger.debug(e)
logger.exception(f"Unable to generate sensor definition hash")
10 changes: 4 additions & 6 deletions scos_actions/discover/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,20 @@ def load_from_yaml(action_classes, sigan, gps, yaml_dir: Path = ACTION_DEFINITIO
definition = yaml.load(yaml_file)
for class_name, parameters in definition.items():
try:
logger.debug("Attempting to configure: " + class_name)
logger.debug(f"Attempting to configure: {class_name}")
action = action_classes[class_name](
parameters=parameters, sigan=sigan, gps=gps
)
parsed_actions[action.name] = action
except KeyError as exc:
err = "Nonexistent action class name {!r} referenced in {!r}"
logger.error(err.format(class_name, yaml_file.name))
logger.exception(exc)
logger.exception(err.format(class_name, yaml_file.name))
raise exc
except TypeError as exc:
err = "Invalid parameter list {!r} referenced in {!r}"
logger.error(err.format(parameters, yaml_file.name))
logger.exception(exc)
logger.exception(err.format(parameters, yaml_file.name))
raise exc
except Exception as exc:
logger.error("Unable to load yaml:", exc, class_name, parameters)
logger.exception("Unable to load yaml:", class_name, parameters)
raise exc
return parsed_actions
14 changes: 7 additions & 7 deletions scos_actions/hardware/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def load_switches(switch_dir: Path) -> dict:
if switch_dir is not None and switch_dir.is_dir():
for f in switch_dir.iterdir():
file_path = f.resolve()
logger.info(f"loading switch config {file_path}")
logger.debug(f"loading switch config {file_path}")
conf = utils.load_from_json(file_path)
try:
switch = ControlByWebWebRelay(conf)
logger.info(f"Adding {switch.id}")
logger.debug(f"Adding {switch.id}")

switch_dict[switch.id] = switch
logger.info(f"Registering switch status for {switch.name}")
logger.debug(f"Registering switch status for {switch.name}")
register_component_with_status.send(__name__, component=switch)
except ConfigurationException:
logger.error(f"Unable to configure switch defined in: {file_path}")
Expand All @@ -49,7 +49,7 @@ def load_preselector_from_file(preselector_config_file: Path):
preselector_config, PRESELECTOR_MODULE, PRESELECTOR_CLASS
)
except ConfigurationException:
logger.error(
logger.exception(
f"Unable to create preselector defined in: {preselector_config_file}"
)
return None
Expand All @@ -61,15 +61,15 @@ def load_preselector(preselector_config, module, preselector_class_name):
preselector_constructor = getattr(preselector_module, preselector_class_name)
ps = preselector_constructor(capabilities["sensor"], preselector_config)
if ps and ps.name:
logger.info(f"Registering {ps.name} as status provider")
logger.debug(f"Registering {ps.name} as status provider")
register_component_with_status.send(__name__, component=ps)
else:
ps = None
return ps


register_component_with_status.connect(status_registration_handler)
logger.info("Connected status registration handler")
logger.debug("Connected status registration handler")
preselector = load_preselector_from_file(PRESELECTOR_CONFIG_FILE)
switches = load_switches(SWITCH_CONFIGS_DIR)
logger.info(f"Loaded {(len(switches))} switches.")
logger.debug(f"Loaded {(len(switches))} switches.")
2 changes: 1 addition & 1 deletion scos_actions/hardware/mocks/mock_sigan.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def acquire_time_domain_samples(
data_len = len(data)
if not len(data) == num_samples:
if retries > 0:
msg = "USRP error: requested {} samples, but got {}."
msg = "Signal analyzer error: requested {} samples, but got {}."
logger.warning(msg.format(num_samples + num_samples_skip, data_len))
logger.warning(f"Retrying {retries} more times.")
retries = retries - 1
Expand Down
8 changes: 4 additions & 4 deletions scos_actions/hardware/sigan_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,17 @@ def power_cycle_and_connect(self, sleep_time: float = 2.0) -> None:
try:
power_cycle_sigan()
except HardwareConfigurationException as hce:
logger.warn(f"Unable to power cycle sigan: {hce}")
logger.warning(f"Unable to power cycle sigan: {hce}")
return
try:
# Wait for power cycle to complete
logger.debug(f"Waiting {sleep_time} seconds before reconnecting...")
time.sleep(sleep_time)
logger.info("Power cycled signal analyzer. Reconnecting...")
self.connect()
except Exception as e:
logger.error(
f"Unable to reconnect to signal analyzer after power cycling: {e}"
except Exception:
logger.exception(
"Unable to reconnect to signal analyzer after power cycling"
)
return

Expand Down
5 changes: 3 additions & 2 deletions scos_actions/metadata/structs/ntia_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,11 @@ class Computer(msgspec.Struct, **SIGMF_OBJECT_KWARGS):
class ScosPlugin(msgspec.Struct, **SIGMF_OBJECT_KWARGS):
"""
Interface for generating `ntia-diagnostics` `ScosPlugin` objects.
:param name: The Python package name as it is imported, e.g., `"scos_tekrsa"`

:param name: The Python package name as it is imported, e.g., `"scos_tekrsa"`
:param version: Version of the SCOS plugin.
"""

name: Optional[str] = None
version: Optional[str] = None

Expand Down
2 changes: 1 addition & 1 deletion scos_actions/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
logger = logging.getLogger(__name__)
env = Env()

logger.info("Initializing scos-actions settings")
logger.debug("Initializing scos-actions settings")
CONFIG_DIR = Path(__file__).parent.resolve() / "configs"
ACTION_DEFINITIONS_DIR = CONFIG_DIR / "actions"

Expand Down
2 changes: 1 addition & 1 deletion scos_actions/status/status_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class StatusMonitor:
def __init__(self):
logger.info("Initializing StatusMonitor")
logger.debug("Initializing StatusMonitor")
self.status_components = []

def add_component(self, component):
Expand Down
2 changes: 1 addition & 1 deletion scos_actions/status/status_registration_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def status_registration_handler(sender, **kwargs):
try:
logger.info(f"Registering {sender} as status provider")
logger.debug(f"Registering {sender} as status provider")
status_registrar.add_component(kwargs["component"])
except:
logger.exception("Error registering status component")