Find entities that exist in a reference feature view but have NOT been labeled yet.
(request: ActiveLearningRequest)
| 426 | |
| 427 | @rest_app.post("/active-learning/candidates") |
| 428 | def active_learning_candidates(request: ActiveLearningRequest): |
| 429 | """Find entities that exist in a reference feature view but have NOT been labeled yet.""" |
| 430 | try: |
| 431 | fv_name = request.feature_view |
| 432 | fv: Any = None |
| 433 | try: |
| 434 | fv = store.registry.get_label_view(fv_name, store.project) |
| 435 | except Exception: |
| 436 | pass |
| 437 | |
| 438 | if fv is None: |
| 439 | return Response( |
| 440 | content=json.dumps({"detail": f"Label view '{fv_name}' not found"}), |
| 441 | status_code=status.HTTP_404_NOT_FOUND, |
| 442 | media_type="application/json", |
| 443 | ) |
| 444 | |
| 445 | ref_fv_name = request.reference_feature_view or ( |
| 446 | getattr(fv, "reference_feature_view", None) or "" |
| 447 | ) |
| 448 | |
| 449 | if not ref_fv_name: |
| 450 | return Response( |
| 451 | content=json.dumps( |
| 452 | { |
| 453 | "detail": "No reference feature view specified. " |
| 454 | "Provide a feature view containing all entities." |
| 455 | } |
| 456 | ), |
| 457 | status_code=status.HTTP_400_BAD_REQUEST, |
| 458 | media_type="application/json", |
| 459 | ) |
| 460 | |
| 461 | ref_fv: Any = None |
| 462 | try: |
| 463 | ref_fv = store.get_feature_view(ref_fv_name) |
| 464 | except Exception: |
| 465 | pass |
| 466 | |
| 467 | if ref_fv is None: |
| 468 | return Response( |
| 469 | content=json.dumps( |
| 470 | {"detail": f"Reference feature view '{ref_fv_name}' not found"} |
| 471 | ), |
| 472 | status_code=status.HTTP_404_NOT_FOUND, |
| 473 | media_type="application/json", |
| 474 | ) |
| 475 | |
| 476 | provider = store._get_provider() |
| 477 | |
| 478 | # Get all entities from reference feature view |
| 479 | ref_batch_source = getattr(ref_fv, "batch_source", None) |
| 480 | if ref_batch_source is None: |
| 481 | return Response( |
| 482 | content=json.dumps( |
| 483 | { |
| 484 | "detail": f"No batch source for reference view '{ref_fv_name}'" |
| 485 | } |
nothing calls this directly
no test coverage detected