Compare commits
No commits in common. "ed95d13200190e4aa0e52530e477236febc3bead" and "0fdd07bec21f650bf043ad7bde887e455aea05a3" have entirely different histories.
ed95d13200
...
0fdd07bec2
5 changed files with 16 additions and 79 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
from clipwright.pipeline import llm_backend, profiles
|
from clipwright.pipeline import llm_backend, profiles
|
||||||
import re
|
import re
|
||||||
|
|
@ -1471,25 +1470,6 @@ async def lifespan(app: FastAPI):
|
||||||
yield
|
yield
|
||||||
# Cleanup (optional: cancel worker)
|
# Cleanup (optional: cancel worker)
|
||||||
|
|
||||||
# Health probes (Docker, every 5 s) and the dashboard's 2 s job-status poll would
|
|
||||||
# otherwise fill uvicorn's access log with thousands of identical lines and bury
|
|
||||||
# the real job output. Drop those from the access logger only: the requests are
|
|
||||||
# still served normally, just not echoed to the console.
|
|
||||||
_QUIET_ACCESS_PREFIXES = ("/health", "/api/status/")
|
|
||||||
|
|
||||||
|
|
||||||
class _QuietAccessPaths(logging.Filter):
|
|
||||||
"""Suppress access-log lines for health checks and job-status polling."""
|
|
||||||
|
|
||||||
def filter(self, record: logging.LogRecord) -> bool:
|
|
||||||
args = record.args
|
|
||||||
path = args[2] if isinstance(args, tuple) and len(args) >= 3 else ""
|
|
||||||
return not str(path).startswith(_QUIET_ACCESS_PREFIXES)
|
|
||||||
|
|
||||||
|
|
||||||
logging.getLogger("uvicorn.access").addFilter(_QuietAccessPaths())
|
|
||||||
|
|
||||||
|
|
||||||
app = FastAPI(lifespan=lifespan)
|
app = FastAPI(lifespan=lifespan)
|
||||||
|
|
||||||
# Free public tools behind the /tools SEO pages: YouTube transcript (existing
|
# Free public tools behind the /tools SEO pages: YouTube transcript (existing
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,7 @@ def _detect_transnetv2(video_path):
|
||||||
threshold = float(os.environ.get("TRANSNETV2_THRESHOLD", "0.5"))
|
threshold = float(os.environ.get("TRANSNETV2_THRESHOLD", "0.5"))
|
||||||
|
|
||||||
with _TN2_LOCK, torch.no_grad():
|
with _TN2_LOCK, torch.no_grad():
|
||||||
# frombuffer() yields a read-only array; copy so torch stops warning and
|
tensor = torch.from_numpy(np.ascontiguousarray(frames)).to(model.device)
|
||||||
# writing to the tensor is well-defined.
|
|
||||||
tensor = torch.from_numpy(np.array(frames, copy=True)).to(model.device)
|
|
||||||
single_frame_pred, _ = model.predict_frames(tensor, quiet=True)
|
single_frame_pred, _ = model.predict_frames(tensor, quiet=True)
|
||||||
single_frame_pred = single_frame_pred.cpu()
|
single_frame_pred = single_frame_pred.cpu()
|
||||||
del tensor
|
del tensor
|
||||||
|
|
|
||||||
33
dashboard/package-lock.json
generated
33
dashboard/package-lock.json
generated
|
|
@ -1469,16 +1469,12 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/baseline-browser-mapping": {
|
"node_modules/baseline-browser-mapping": {
|
||||||
"version": "2.11.27",
|
"version": "2.9.11",
|
||||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.27.tgz",
|
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.11.tgz",
|
||||||
"integrity": "sha512-ElY12DaROGuan+lMmZ8Cvo/ZUbXPe7Enc/9VU/b1T3Kp4dwytRcNdR8DoSJN5SNJT/CuvcCA0DHDVmMOCePdRQ==",
|
"integrity": "sha512-Sg0xJUNDU1sJNGdfGWhVHX0kkZ+HWcvmVymJbj6NSgZZmW/8S9Y2HQ5euytnIgakgxN6papOAWiwDo1ctFDcoQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"baseline-browser-mapping": "dist/cli.cjs"
|
"baseline-browser-mapping": "dist/cli.js"
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6.0.0"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/binary-extensions": {
|
"node_modules/binary-extensions": {
|
||||||
|
|
@ -1618,9 +1614,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/caniuse-lite": {
|
"node_modules/caniuse-lite": {
|
||||||
"version": "1.0.30001814",
|
"version": "1.0.30001761",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001814.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001761.tgz",
|
||||||
"integrity": "sha512-/Uaf1lAzr59XcMpW0o96WoEfr+VXK2OX4U9AgFoiSHsVJ4HppnIFUjtYzsyDH2+tgANaQb2/oxYGwCPapN1FpA==",
|
"integrity": "sha512-JF9ptu1vP2coz98+5051jZ4PwQgd2ni8A+gYSN7EA7dPKIMf0pDlSUxhdmVOaV3/fYK5uWBkgSXJaRLr4+3A6g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
|
@ -1635,8 +1631,7 @@
|
||||||
"type": "github",
|
"type": "github",
|
||||||
"url": "https://github.com/sponsors/ai"
|
"url": "https://github.com/sponsors/ai"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"license": "CC-BY-4.0"
|
|
||||||
},
|
},
|
||||||
"node_modules/chalk": {
|
"node_modules/chalk": {
|
||||||
"version": "4.1.2",
|
"version": "4.1.2",
|
||||||
|
|
@ -6179,9 +6174,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"baseline-browser-mapping": {
|
"baseline-browser-mapping": {
|
||||||
"version": "2.11.27",
|
"version": "2.9.11",
|
||||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.27.tgz",
|
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.11.tgz",
|
||||||
"integrity": "sha512-ElY12DaROGuan+lMmZ8Cvo/ZUbXPe7Enc/9VU/b1T3Kp4dwytRcNdR8DoSJN5SNJT/CuvcCA0DHDVmMOCePdRQ==",
|
"integrity": "sha512-Sg0xJUNDU1sJNGdfGWhVHX0kkZ+HWcvmVymJbj6NSgZZmW/8S9Y2HQ5euytnIgakgxN6papOAWiwDo1ctFDcoQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"binary-extensions": {
|
"binary-extensions": {
|
||||||
|
|
@ -6267,9 +6262,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"caniuse-lite": {
|
"caniuse-lite": {
|
||||||
"version": "1.0.30001814",
|
"version": "1.0.30001761",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001814.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001761.tgz",
|
||||||
"integrity": "sha512-/Uaf1lAzr59XcMpW0o96WoEfr+VXK2OX4U9AgFoiSHsVJ4HppnIFUjtYzsyDH2+tgANaQb2/oxYGwCPapN1FpA==",
|
"integrity": "sha512-JF9ptu1vP2coz98+5051jZ4PwQgd2ni8A+gYSN7EA7dPKIMf0pDlSUxhdmVOaV3/fYK5uWBkgSXJaRLr4+3A6g==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"chalk": {
|
"chalk": {
|
||||||
|
|
|
||||||
|
|
@ -474,11 +474,9 @@ function App() {
|
||||||
let interval;
|
let interval;
|
||||||
if ((status === 'processing' || status === 'completed') && jobId) {
|
if ((status === 'processing' || status === 'completed') && jobId) {
|
||||||
interval = setInterval(async () => {
|
interval = setInterval(async () => {
|
||||||
// Skip a backgrounded tab: with the dashboard open in several tabs the
|
|
||||||
// hidden ones kept polling /api/status and flooding the access log.
|
|
||||||
if (document.hidden) return;
|
|
||||||
try {
|
try {
|
||||||
const data = await pollJob(jobId);
|
const data = await pollJob(jobId);
|
||||||
|
console.log("Job status:", data);
|
||||||
|
|
||||||
// Update results if available (real-time)
|
// Update results if available (real-time)
|
||||||
if (data.result) {
|
if (data.result) {
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
"""The access-log filter that hides health checks and job-status polling."""
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from clipwright.api.app import _QuietAccessPaths
|
|
||||||
|
|
||||||
|
|
||||||
def _record(path):
|
|
||||||
return logging.LogRecord(
|
|
||||||
"uvicorn.access", logging.INFO, __file__, 1, "msg",
|
|
||||||
("1.2.3.4", "GET", path, "HTTP/1.1", 200), None,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_drops_health_and_status_lines():
|
|
||||||
f = _QuietAccessPaths()
|
|
||||||
assert f.filter(_record("/health")) is False
|
|
||||||
assert f.filter(_record("/health/ready")) is False
|
|
||||||
assert f.filter(_record("/api/status/4c533b81-ef05-4b51-80a3-137046577888")) is False
|
|
||||||
|
|
||||||
|
|
||||||
def test_keeps_real_requests():
|
|
||||||
f = _QuietAccessPaths()
|
|
||||||
assert f.filter(_record("/api/config")) is True
|
|
||||||
assert f.filter(_record("/api/uploads/abc")) is True
|
|
||||||
assert f.filter(_record("/videos/job/clip.mp4")) is True
|
|
||||||
|
|
||||||
|
|
||||||
def test_survives_unexpected_record_args():
|
|
||||||
# uvicorn access records always carry the args tuple, but a filter must never
|
|
||||||
# raise on a differently-shaped record.
|
|
||||||
f = _QuietAccessPaths()
|
|
||||||
rec = logging.LogRecord("uvicorn.access", logging.INFO, __file__, 1, "msg", None, None)
|
|
||||||
assert f.filter(rec) is True
|
|
||||||
Loading…
Reference in a new issue