Skip to content

Commit a544ec8

Browse files
committed
Fix S3 storage path reading in jobs router
1 parent 02b290f commit a544ec8

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

stringsight/routers/jobs.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from stringsight.routers.auth import get_current_user_optional
1111
from stringsight.schemas import ExtractJobStartRequest, PipelineJobRequest, ClusterJobRequest
1212
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
1314

1415
router = APIRouter(prefix="/api/v1/jobs", tags=["jobs"])
1516

@@ -146,20 +147,18 @@ def get_job_results(
146147

147148
if not job.result_path:
148149
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+
155158
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+
163162
return {
164163
"properties": properties,
165164
"result_path": job.result_path,

0 commit comments

Comments
 (0)