mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-11-16 21:37:13 +00:00
Adds surfsense_analyze_data: the model writes a pandas script, the Studio worker runs it on read-only copies of ticked spreadsheet and CSV sources, and the result carries what it printed, previews of the tables it saved and its charts inline. A chart's name can be placed in a rendered document like a source figure. The runner now shares its sandboxed process setup between document scripts and analyses, and the surfsense-data skill guides the script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
894 B
Python
25 lines
894 B
Python
"""The analysis job: the Studio worker runs the script, since the packaged worker is the binary that ships pandas (ADR 0039)."""
|
|
|
|
from pathlib import Path
|
|
|
|
from shared.queue import studio_queue
|
|
from worker.document_script.analysis_run import (
|
|
AnalysisInput,
|
|
AnalysisRun,
|
|
run_analysis_script,
|
|
)
|
|
|
|
# Ahead of Studio's own jobs: a turn is waiting on this one.
|
|
PRIORITY = 100
|
|
SCRIPT_SECONDS = 120
|
|
# Started later than this, it could not finish inside the tool call waiting for
|
|
# it, so it is dropped instead of run unseen.
|
|
START_WITHIN_SECONDS = 60
|
|
|
|
|
|
@studio_queue.task(priority=PRIORITY, expires=START_WITHIN_SECONDS)
|
|
def analyse_data(script: str, inputs: list[AnalysisInput], keep_in: str) -> AnalysisRun:
|
|
"""Run one analysis and keep its tables and charts in keep_in."""
|
|
return run_analysis_script(
|
|
script, inputs, Path(keep_in), timeout_seconds=SCRIPT_SECONDS
|
|
)
|