From bbe9130aaf8aa0a98ade010b6c9d13b99d926c59 Mon Sep 17 00:00:00 2001 From: CBroz1 Date: Tue, 12 Nov 2024 09:05:42 -0600 Subject: [PATCH] =?UTF-8?q?=20=F0=9F=90=9B=20:=20debug=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/spyglass/position/v1/dlc_utils_makevid.py | 14 +++++++++----- .../position/v1/position_trodes_position.py | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/spyglass/position/v1/dlc_utils_makevid.py b/src/spyglass/position/v1/dlc_utils_makevid.py index 2763a7898..836b4366f 100644 --- a/src/spyglass/position/v1/dlc_utils_makevid.py +++ b/src/spyglass/position/v1/dlc_utils_makevid.py @@ -5,7 +5,6 @@ import subprocess from concurrent.futures import ProcessPoolExecutor, TimeoutError, as_completed from pathlib import Path -from typing import Tuple import matplotlib import matplotlib.pyplot as plt @@ -118,6 +117,9 @@ def __init__( _ = self._set_frame_info() _ = self._set_plot_bases() + if test_mode: # CICD fails with ambiguous pool error + self._debug_one_frame() + logger.info( f"Making video: {self.output_video_filename} " + f"in batches of {self.batch_size}" @@ -190,10 +192,6 @@ def _set_frame_info(self): self.pad_len = len(str(self.n_frames)) - def _set_input_stats(self, video_filename=None) -> Tuple[int, int]: - """Get the width and height of the video.""" - logger.debug("Getting video stats with ffprobe") - def _set_plot_bases(self): """Create the figure and axes for the video.""" logger.debug("Setting plot bases") @@ -384,6 +382,12 @@ def _generate_single_frame(self, frame_ind): return frame_ind + def _debug_one_frame(self): + """Debug a single frame.""" + frame_ind = 10 + self.ffmepg_extract(frame_ind, frame_ind + 1) + self._generate_single_frame(frame_ind) + def process_frames(self): """Process video frames in batches and generate matplotlib frames.""" diff --git a/src/spyglass/position/v1/position_trodes_position.py b/src/spyglass/position/v1/position_trodes_position.py index 031c0e6bb..30ed80809 100644 --- a/src/spyglass/position/v1/position_trodes_position.py +++ b/src/spyglass/position/v1/position_trodes_position.py @@ -344,9 +344,10 @@ def make(self, key): adj_df = _fix_col_names(raw_df) # adjust 'xloc1' to 'xloc' limit = params.get("limit", None) - if limit or test_mode: + if limit: params["debug"] = True output_video_filename = Path(".") / f"TEST_VID_{limit}.mp4" + if limit or test_mode: # pytest video data has mismatched shapes in some cases min_len = limit or min(len(adj_df), len(pos_df), len(video_time)) adj_df = adj_df.head(min_len)