|
10 | 10 | from stringsight.routers.auth import get_current_user_optional |
11 | 11 | from stringsight.schemas import ExtractJobStartRequest, PipelineJobRequest, ClusterJobRequest |
12 | 12 | from stringsight.workers.tasks import run_extract_job, run_pipeline_job, run_cluster_job, _run_cluster_job_async |
| 13 | +from stringsight.storage.adapter import get_storage_adapter |
13 | 14 |
|
14 | 15 | router = APIRouter(prefix="/api/v1/jobs", tags=["jobs"]) |
15 | 16 |
|
@@ -146,20 +147,18 @@ def get_job_results( |
146 | 147 |
|
147 | 148 | if not job.result_path: |
148 | 149 | raise HTTPException(status_code=404, detail="No results available for this job") |
149 | | - |
150 | | - # Read the results from the file |
151 | | - result_file = Path(job.result_path) / "validated_properties.jsonl" |
152 | | - if not result_file.exists(): |
153 | | - raise HTTPException(status_code=404, detail=f"Results file not found: {result_file}") |
154 | | - |
| 150 | + |
| 151 | + # Read the results from storage (works with both filesystem and S3) |
| 152 | + storage = get_storage_adapter() |
| 153 | + result_file_path = f"{job.result_path}/validated_properties.jsonl" |
| 154 | + |
| 155 | + if not storage.exists(result_file_path): |
| 156 | + raise HTTPException(status_code=404, detail=f"Results file not found: {result_file_path}") |
| 157 | + |
155 | 158 | try: |
156 | | - # Read JSONL file |
157 | | - properties = [] |
158 | | - with open(result_file, 'r') as f: |
159 | | - for line in f: |
160 | | - if line.strip(): |
161 | | - properties.append(json.loads(line)) |
162 | | - |
| 159 | + # Read JSONL file using storage adapter |
| 160 | + properties = storage.read_jsonl(result_file_path) |
| 161 | + |
163 | 162 | return { |
164 | 163 | "properties": properties, |
165 | 164 | "result_path": job.result_path, |
|
0 commit comments