Skip to content

Commit

Permalink
🐛 : debug 1
Browse files Browse the repository at this point in the history
  • Loading branch information
CBroz1 committed Nov 12, 2024
1 parent 942e279 commit bbe9130
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/spyglass/position/v1/dlc_utils_makevid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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."""

Expand Down
3 changes: 2 additions & 1 deletion src/spyglass/position/v1/position_trodes_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bbe9130

Please sign in to comment.