Changes from review
This commit is contained in:
parent
5be8b0ecab
commit
cbfbd84fa9
7 changed files with 14 additions and 21 deletions
|
|
@ -323,14 +323,14 @@ class BaseCamera(OFMThing):
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
|
|
||||||
timestamp = time.strftime("%Y%m%d_%H%M%S")
|
timestamp = time.strftime("%Y%m%d_%H%M%S")
|
||||||
log_path = os.path.join(
|
datafile_path = os.path.join(
|
||||||
output_dir,
|
output_dir,
|
||||||
f"framerate_{timestamp}.json",
|
f"framerate_{timestamp}.json",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"Framerate monitor started -> %s",
|
"Framerate monitor started -> %s",
|
||||||
log_path,
|
datafile_path,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._framerate_monitor_running = True
|
self._framerate_monitor_running = True
|
||||||
|
|
@ -363,15 +363,15 @@ class BaseCamera(OFMThing):
|
||||||
avg_fps,
|
avg_fps,
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(log_path, "w") as f:
|
with open(datafile_path, "w") as f:
|
||||||
json.dump(data, f, indent=2)
|
json.dump(data, f, indent=2)
|
||||||
|
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"Framerate monitor complete -> %s",
|
"Framerate monitor complete -> %s",
|
||||||
log_path,
|
datafile_path,
|
||||||
)
|
)
|
||||||
|
|
||||||
return log_path
|
return datafile_path
|
||||||
|
|
||||||
@lt.property
|
@lt.property
|
||||||
def stream_active(self) -> bool:
|
def stream_active(self) -> bool:
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,6 @@ class StreamingPiCamera2(BaseCamera):
|
||||||
self._sensor_info = SUPPORTED_CAMS_SENSOR_INFO[camera_board]
|
self._sensor_info = SUPPORTED_CAMS_SENSOR_INFO[camera_board]
|
||||||
self._picamera_lock = RLock()
|
self._picamera_lock = RLock()
|
||||||
self._picamera = None
|
self._picamera = None
|
||||||
self._framerate_monitor_running = False
|
|
||||||
|
|
||||||
# Load the tuning file for the specified sensor mode.
|
# Load the tuning file for the specified sensor mode.
|
||||||
self.default_tuning = tf_utils.load_default_tuning(
|
self.default_tuning = tf_utils.load_default_tuning(
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,11 @@ class LabThingsTestEnv:
|
||||||
self._test_client: Optional[TestClient]
|
self._test_client: Optional[TestClient]
|
||||||
self._things_config = things
|
self._things_config = things
|
||||||
self._settings_folder = settings_folder
|
self._settings_folder = settings_folder
|
||||||
self._application_config = application_config
|
# Labthings requires an application config for the data_folder
|
||||||
|
if application_config:
|
||||||
|
self._application_config = application_config
|
||||||
|
else:
|
||||||
|
self._application_config = {"data_folder": tempfile.TemporaryDirectory()}
|
||||||
self._tmp_dir_obj: Optional[tempfile.TemporaryDirectory] = None
|
self._tmp_dir_obj: Optional[tempfile.TemporaryDirectory] = None
|
||||||
|
|
||||||
def __enter__(self) -> Self:
|
def __enter__(self) -> Self:
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ test_simulated_camera.py and for testing the consistency of camera APIs see
|
||||||
test_cameras.py.
|
test_cameras.py.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import tempfile
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pytest
|
import pytest
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
@ -21,8 +19,7 @@ from ..shared_utils.lt_test_utils import LabThingsTestEnv
|
||||||
def test_env() -> LabThingsTestEnv:
|
def test_env() -> LabThingsTestEnv:
|
||||||
"""Yield a test environment with the Simulated Camera and Dummy Stage."""
|
"""Yield a test environment with the Simulated Camera and Dummy Stage."""
|
||||||
thing_conf = {"camera": SimulatedCamera, "stage": DummyStage}
|
thing_conf = {"camera": SimulatedCamera, "stage": DummyStage}
|
||||||
app_config = {"data_folder": tempfile.gettempdir()}
|
with LabThingsTestEnv(things=thing_conf) as env:
|
||||||
with LabThingsTestEnv(things=thing_conf, application_config=app_config) as env:
|
|
||||||
yield env
|
yield env
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
"""Tests that captures have the expected metadata."""
|
"""Tests that captures have the expected metadata."""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import tempfile
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
@ -100,8 +99,7 @@ def test_env() -> LabThingsTestEnv:
|
||||||
"stage": DummyStage,
|
"stage": DummyStage,
|
||||||
"bg_channel_deviations_luv": ChannelDeviationLUV,
|
"bg_channel_deviations_luv": ChannelDeviationLUV,
|
||||||
}
|
}
|
||||||
app_config = {"data_folder": tempfile.gettempdir()}
|
with LabThingsTestEnv(things=thing_conf) as env:
|
||||||
with LabThingsTestEnv(things=thing_conf, application_config=app_config) as env:
|
|
||||||
yield env
|
yield env
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
"""Test the functionality specific to the simulated camera."""
|
"""Test the functionality specific to the simulated camera."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import tempfile
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
@ -29,9 +28,7 @@ def test_env() -> LabThingsTestEnv:
|
||||||
"bg_channel_deviations_luv": ChannelDeviationLUV,
|
"bg_channel_deviations_luv": ChannelDeviationLUV,
|
||||||
}
|
}
|
||||||
|
|
||||||
app_config = {"data_folder": tempfile.gettempdir()}
|
with LabThingsTestEnv(things=thing_conf) as env:
|
||||||
|
|
||||||
with LabThingsTestEnv(things=thing_conf, application_config=app_config) as env:
|
|
||||||
yield env
|
yield env
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
import tempfile
|
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
@ -177,8 +176,7 @@ def test_direction_inversion(dummy_stage):
|
||||||
def test_direction_errors_local_and_http():
|
def test_direction_errors_local_and_http():
|
||||||
"""Check for expected errors both locally and over http."""
|
"""Check for expected errors both locally and over http."""
|
||||||
thing_conf = {"camera": SimulatedCamera, "stage": DummyStage}
|
thing_conf = {"camera": SimulatedCamera, "stage": DummyStage}
|
||||||
app_config = {"data_folder": tempfile.gettempdir()}
|
with LabThingsTestEnv(things=thing_conf) as test_env:
|
||||||
with LabThingsTestEnv(things=thing_conf, application_config=app_config) as test_env:
|
|
||||||
dummy_stage = test_env.get_thing_by_type(DummyStage)
|
dummy_stage = test_env.get_thing_by_type(DummyStage)
|
||||||
stage_client = test_env.get_thing_client("stage")
|
stage_client = test_env.get_thing_client("stage")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue