|
22 | 22 | from ads.aqua.shaperecommend.llm_config import LLMConfig
|
23 | 23 | from ads.aqua.shaperecommend.recommend import (
|
24 | 24 | AquaShapeRecommend,
|
25 |
| - HuggingFaceModelFetcher, |
26 | 25 | )
|
27 | 26 | from ads.aqua.shaperecommend.shape_report import (
|
28 | 27 | DeploymentParams,
|
@@ -457,71 +456,3 @@ def test_shape_report_pareto_front(self):
|
457 | 456 | assert c and d in pf
|
458 | 457 | assert a and b not in pf
|
459 | 458 | assert len(pf) == 2
|
460 |
| - |
461 |
| - |
462 |
| -class TestHuggingFaceModelFetcher: |
463 |
| - @pytest.mark.parametrize( |
464 |
| - "model_id, expected", |
465 |
| - [ |
466 |
| - ("meta-llama/Llama-2-7b-hf", True), |
467 |
| - ("mistralai/Mistral-7B-v0.1", True), |
468 |
| - ("ocid1.datasciencemodel.oc1.iad.xxxxxxxx", False), |
469 |
| - ], |
470 |
| - ) |
471 |
| - def test_is_huggingface_model_id(self, model_id, expected): |
472 |
| - assert HuggingFaceModelFetcher.is_huggingface_model_id(model_id) == expected |
473 |
| - |
474 |
| - @patch("requests.get") |
475 |
| - def test_fetch_config_only_success(self, mock_get): |
476 |
| - mock_response = MagicMock() |
477 |
| - mock_response.status_code = 200 |
478 |
| - mock_response.json.return_value = {"model_type": "llama"} |
479 |
| - mock_get.return_value = mock_response |
480 |
| - |
481 |
| - config = HuggingFaceModelFetcher.fetch_config_only("some/model") |
482 |
| - assert config == {"model_type": "llama"} |
483 |
| - mock_get.assert_called_once() |
484 |
| - |
485 |
| - @patch("requests.get") |
486 |
| - def test_fetch_config_only_not_found(self, mock_get): |
487 |
| - mock_response = MagicMock() |
488 |
| - mock_response.status_code = 404 |
489 |
| - mock_get.return_value = mock_response |
490 |
| - |
491 |
| - with pytest.raises(AquaValueError, match="not found on HuggingFace"): |
492 |
| - HuggingFaceModelFetcher.fetch_config_only("non/existent") |
493 |
| - |
494 |
| - @patch.dict(os.environ, {"HF_TOKEN": "test_token_123"}, clear=True) |
495 |
| - def test_get_hf_token(self): |
496 |
| - assert HuggingFaceModelFetcher.get_hf_token() == "test_token_123" |
497 |
| - |
498 |
| - # @pytest.mark.network |
499 |
| - # def test_fetch_config_only_real_call_success(self): |
500 |
| - # """ |
501 |
| - # Tests a real network call to fetch a public model's configuration. |
502 |
| - # This test requires an internet connection. |
503 |
| - # """ |
504 |
| - # model_id = "distilbert-base-uncased" |
505 |
| - |
506 |
| - # try: |
507 |
| - # config = HuggingFaceModelFetcher.fetch_config_only(model_id) |
508 |
| - # assert isinstance(config, dict) |
509 |
| - # assert "model_type" in config |
510 |
| - # assert "dim" in config |
511 |
| - # except AquaValueError as e: |
512 |
| - # pytest.fail(f"Real network call to Hugging Face failed: {e}") |
513 |
| - |
514 |
| - @patch("ads.aqua.shaperecommend.recommend.OCIDataScienceModelDeployment.shapes") |
515 |
| - @patch.dict(os.environ, {}, clear=True) |
516 |
| - def test_valid_compute_shapes_raises_error_no_compartment(self, mock_oci_shapes): |
517 |
| - """ |
518 |
| - Tests that valid_compute_shapes raises a ValueError when no compartment ID is |
519 |
| - provided and none can be found in the environment. |
520 |
| - """ |
521 |
| - app = AquaShapeRecommend() |
522 |
| - |
523 |
| - with pytest.raises(AquaValueError, match="A compartment OCID is required"): |
524 |
| - app.valid_compute_shapes(compartment_id=None) |
525 |
| - |
526 |
| - # Verify that the OCI SDK was not called because the check failed early |
527 |
| - mock_oci_shapes.assert_not_called() |
0 commit comments