From 9588c0bc36987088371bc64cd4f21fe78ef493b6 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Wed, 6 Dec 2023 15:34:27 -0700 Subject: [PATCH 1/5] debug --- scos_actions/actions/acquire_single_freq_fft.py | 1 + scos_actions/actions/acquire_single_freq_tdomain_iq.py | 1 + scos_actions/actions/interfaces/measurement_action.py | 2 ++ 3 files changed, 4 insertions(+) diff --git a/scos_actions/actions/acquire_single_freq_fft.py b/scos_actions/actions/acquire_single_freq_fft.py index a0cd7b6a..aaa37913 100644 --- a/scos_actions/actions/acquire_single_freq_fft.py +++ b/scos_actions/actions/acquire_single_freq_fft.py @@ -188,6 +188,7 @@ def execute(self, schedule_entry: dict, task_id: int) -> dict: # Build capture metadata sigan_settings = self.get_sigan_settings(measurement_result) + logger.debug(f"sigan settings:{sigan_settings}") measurement_result["capture_segment"] = self.create_capture_segment( sample_start=0, start_time=measurement_result["capture_time"], diff --git a/scos_actions/actions/acquire_single_freq_tdomain_iq.py b/scos_actions/actions/acquire_single_freq_tdomain_iq.py index 19aea960..7943dfb7 100644 --- a/scos_actions/actions/acquire_single_freq_tdomain_iq.py +++ b/scos_actions/actions/acquire_single_freq_tdomain_iq.py @@ -96,6 +96,7 @@ def execute(self, schedule_entry: dict, task_id: int) -> dict: ] measurement_result["classification"] = self.classification sigan_settings = self.get_sigan_settings(measurement_result) + logger.debug(f"sigan settings:{sigan_settings}") measurement_result["capture_segment"] = self.create_capture_segment( sample_start=0, start_time=measurement_result["capture_time"], diff --git a/scos_actions/actions/interfaces/measurement_action.py b/scos_actions/actions/interfaces/measurement_action.py index 0dd9587f..8acc224f 100644 --- a/scos_actions/actions/interfaces/measurement_action.py +++ b/scos_actions/actions/interfaces/measurement_action.py @@ -112,6 +112,8 @@ def create_metadata( except KeyError: logger.warning(warning_str.format("calibration_datetime")) try: + cap = measurement_result["capture_segment"] + logger.debug(f"Adding capture:{cap}") self.sigmf_builder.add_capture(measurement_result["capture_segment"]) except KeyError: logger.warning(warning_str.format("capture_segment")) From 245acb7828fdfef41e93a9e2d51eddb9f0bda4e7 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 7 Dec 2023 08:34:44 -0700 Subject: [PATCH 2/5] remove encoder. --- scos_actions/metadata/sigmf_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scos_actions/metadata/sigmf_builder.py b/scos_actions/metadata/sigmf_builder.py index 2a838d82..9ff1bb1e 100644 --- a/scos_actions/metadata/sigmf_builder.py +++ b/scos_actions/metadata/sigmf_builder.py @@ -417,7 +417,7 @@ def set_sensor(self, sensor: Sensor) -> None: self.sigmf_md.set_global_field("ntia-sensor:sensor", sensor) def add_capture(self, capture: CaptureSegment) -> None: - capture_dict = json.loads(msgspec_enc.encode(capture)) + capture_dict = json.loads(capture) sample_start = capture_dict.pop("core:sample_start") self.sigmf_md.add_capture(sample_start, metadata=capture_dict) From 245ddfb71323d95228fc3b459e4ebc4b3928e99a Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 7 Dec 2023 08:59:46 -0700 Subject: [PATCH 3/5] testing --- scos_actions/metadata/sigmf_builder.py | 2 +- scos_actions/metadata/utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scos_actions/metadata/sigmf_builder.py b/scos_actions/metadata/sigmf_builder.py index 9ff1bb1e..2a838d82 100644 --- a/scos_actions/metadata/sigmf_builder.py +++ b/scos_actions/metadata/sigmf_builder.py @@ -417,7 +417,7 @@ def set_sensor(self, sensor: Sensor) -> None: self.sigmf_md.set_global_field("ntia-sensor:sensor", sensor) def add_capture(self, capture: CaptureSegment) -> None: - capture_dict = json.loads(capture) + capture_dict = json.loads(msgspec_enc.encode(capture)) sample_start = capture_dict.pop("core:sample_start") self.sigmf_md.add_capture(sample_start, metadata=capture_dict) diff --git a/scos_actions/metadata/utils.py b/scos_actions/metadata/utils.py index 3a2ea965..ef4fd5e9 100644 --- a/scos_actions/metadata/utils.py +++ b/scos_actions/metadata/utils.py @@ -40,7 +40,7 @@ def _enc_hook(obj: Any) -> Any: # A reusable encoder with custom hook to ensure serialization -msgspec_enc = msgspec.json.Encoder(enc_hook=_enc_hook) +msgspec_enc = msgspec.json.Encoder() # A reusable decoder which outputs a Python dictionary msgspec_dec_dict = msgspec.json.Decoder(type=dict) From 3d0b9ca3e4c3225dd572f16ed1f3613b3bca1690 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 7 Dec 2023 09:53:24 -0700 Subject: [PATCH 4/5] Uset type in encoder and add check and conversion for np.bool_ --- scos_actions/metadata/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scos_actions/metadata/utils.py b/scos_actions/metadata/utils.py index ef4fd5e9..6253049a 100644 --- a/scos_actions/metadata/utils.py +++ b/scos_actions/metadata/utils.py @@ -33,14 +33,19 @@ def construct_geojson_point( def _enc_hook(obj: Any) -> Any: - if isinstance(obj, np.float64): + #While isinstance is recommended, it was causing a + #Recurrsion error and I don't think we have to worry + #about subytpes here. + if type(obj) == np.float64: return float(obj) + elif type(obj) == np.bool_: + return bool(obj) else: return obj # A reusable encoder with custom hook to ensure serialization -msgspec_enc = msgspec.json.Encoder() +msgspec_enc = msgspec.json.Encoder(enc_hook=_enc_hook) # A reusable decoder which outputs a Python dictionary msgspec_dec_dict = msgspec.json.Decoder(type=dict) From 32d0f9d6c01e0613bbcc151ea709fbaa31b96379 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 7 Dec 2023 11:15:11 -0700 Subject: [PATCH 5/5] increment version to 7.0.1 --- scos_actions/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scos_actions/__init__.py b/scos_actions/__init__.py index b378fc6c..fb16410a 100644 --- a/scos_actions/__init__.py +++ b/scos_actions/__init__.py @@ -1 +1 @@ -__version__ = "7.0.0" +__version__ = "7.0.1"