MCPcopy Create free account
hub / github.com/PriorLabs/tabpfn-client / TestServiceClientPredictionNormalization

Class TestServiceClientPredictionNormalization

tests/unit/test_client.py:567–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

565 "fitted_train_set_id": fitted_train_set_id,
566 "status": "failed",
567 "error": "boom",
568 },
569 )
570
571 ServiceClient.authorize("dummy_access_token")
572
573 with (
574 patch.object(ServiceClient, "_upload_to_gcs"),
575 patch.object(
576 ServiceClient,
577 "_resolve_async_settings",
578 return_value=_fast_poll_settings(),
579 ),
580 ):
581 with self.assertRaises(RuntimeError) as cm:
582 ServiceClient.fit(
583 self.X_train,
584 self.y_train,
585 tabpfn_systems=["preprocessing", "text"],
586 task_config=ClassifierFitTaskConfig(),
587 )
588
589 self.assertIn("boom", str(cm.exception))
590
591 @with_mock_server()
592 def test_predict_with_same_test_set_calls_prepare_and_predict_each_time(
593 self, mock_server
594 ):
595 prepare_route = mock_server.router.post("/tabpfn/prepare_test_set_upload")
596 prepare_route.respond(
597 200,
598 json=self._prepare_test_set_upload_response(
599 "00000000-0000-0000-0000-000000000003"
600 ),
601 )
602 predict_route = mock_server.router.post("/tabpfn/predict")
603 predict_route.respond(
604 200,
605 json=self._predict_response([1, 0, 1]),
606 )
607
608 fitted_train_set_id = UUID("00000000-0000-0000-0000-000000000002")
609
610 with patch.object(ServiceClient, "_upload_to_gcs"):
611 pred_1 = ServiceClient.predict(
612 fitted_train_set_id=fitted_train_set_id,
613 x_test=self.X_test,
614 task_config=ClassifierConfig(),
615 )
616 pred_2 = ServiceClient.predict(
617 fitted_train_set_id=fitted_train_set_id,
618 x_test=self.X_test,
619 task_config=ClassifierConfig(),
620 )
621
622 assert isinstance(pred_1.y_pred, np.ndarray)
623 assert isinstance(pred_2.y_pred, np.ndarray)
624 self.assertTrue(np.array_equal(pred_1.y_pred, pred_2.y_pred))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected