Compare commits

...

3 Commits

Author SHA1 Message Date
Eric W
42b44485ad
Merge 317d1acfe1 into a182385618 2026-04-29 15:34:51 +01:00
Nicolas Mowen
a182385618
Fix ROCm build (#23040)
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
2026-04-29 09:30:16 -05:00
Eric W
317d1acfe1 Fix motion activity endpoint returning invalid timestamps after pandas 3.0 upgrade
pandas 3.0 changed DatetimeIndex internal storage from datetime64[ns]
(nanoseconds) to datetime64[us] (microseconds). The motion activity
endpoint in review.py converted DatetimeIndex to epoch seconds using:

    df.index = df.index.astype(int) // (10**9)

This assumed nanosecond resolution, dividing by 10^9 to get seconds.
With microsecond resolution the division produces values ~1000x too
small (e.g. 1774785 instead of 1774785600), causing every entry to
have a start_time near zero. The frontend timeline could not match
these timestamps to the visible range, so motion indicator bars
disappeared entirely — despite the underlying recording data being
correct.

Replace the resolution-dependent integer division with pandas
Timedelta arithmetic:

    df.index = (df.index - _EPOCH) // _ONE_SECOND

This is resolution-independent (produces correct results on
datetime64[s], [ms], [us], and [ns]), ~148x faster than the
per-element .timestamp() alternative, produces native Python int
types that serialize cleanly to JSON, and is backwards-compatible
with older pandas versions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 09:38:56 -04:00
2 changed files with 12 additions and 4 deletions

View File

@ -32,11 +32,14 @@ RUN echo /opt/rocm/lib|tee /opt/rocm-dist/etc/ld.so.conf.d/rocm.conf
FROM deps AS deps-prelim
COPY docker/rocm/debian-backports.sources /etc/apt/sources.list.d/debian-backports.sources
RUN apt-get update && \
# install_deps.sh upgraded libstdc++6 from trixie for Battlemage; the matching
# -dev package must also come from trixie or apt refuses to satisfy it.
RUN echo "deb http://deb.debian.org/debian trixie main" > /etc/apt/sources.list.d/trixie.list && \
apt-get update && \
apt-get install -y libnuma1 && \
apt-get install -qq -y -t bookworm-backports mesa-va-drivers mesa-vulkan-drivers && \
# Install C++ standard library headers for HIPRTC kernel compilation fallback
apt-get install -qq -y libstdc++-12-dev && \
apt-get install -qq -y -t trixie libstdc++-14-dev && \
rm -f /etc/apt/sources.list.d/trixie.list && \
rm -rf /var/lib/apt/lists/*
WORKDIR /opt/frigate

View File

@ -40,6 +40,11 @@ from frigate.util.time import get_dst_transitions
logger = logging.getLogger(__name__)
# Pre-computed constants for resolution-independent datetime-to-epoch conversion
# (pandas 3.0+ stores datetime64 as microseconds, not nanoseconds)
_EPOCH = pd.Timestamp("1970-01-01")
_ONE_SECOND = pd.Timedelta("1s")
router = APIRouter(tags=[Tags.review])
@ -659,7 +664,7 @@ def motion_activity(
df.iloc[i : i + chunk, 0] = 0.0
# change types for output
df.index = df.index.astype(int) // (10**9)
df.index = (df.index - _EPOCH) // _ONE_SECOND
normalized = df.reset_index().to_dict("records")
return JSONResponse(content=normalized)