Skip to content

Commit 79d6f5f

Browse files
committed
fixed imports
1 parent d68e501 commit 79d6f5f

File tree

2 files changed

+3
-70
lines changed

2 files changed

+3
-70
lines changed

ads/aqua/shaperecommend/recommend.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313

1414
from pydantic import ValidationError
1515
from rich.table import Table
16-
from huggingface_hub import hf_hub_download, HfHubHTTPError
1716

17+
# In ads/aqua/shaperecommend/recommend.py
18+
from huggingface_hub import hf_hub_download
19+
from huggingface_hub.utils import HfHubHTTPError
1820
from ads.aqua.app import logger
1921
from ads.aqua.common.entities import ComputeShapeSummary
2022
from ads.aqua.common.errors import (

tests/unitary/with_extras/aqua/test_recommend.py

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from ads.aqua.shaperecommend.llm_config import LLMConfig
2323
from ads.aqua.shaperecommend.recommend import (
2424
AquaShapeRecommend,
25-
HuggingFaceModelFetcher,
2625
)
2726
from ads.aqua.shaperecommend.shape_report import (
2827
DeploymentParams,
@@ -457,71 +456,3 @@ def test_shape_report_pareto_front(self):
457456
assert c and d in pf
458457
assert a and b not in pf
459458
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

Comments
 (0)