@@ -18,7 +18,7 @@ class TestInstall:
1818 def setup_method (self ):
1919 self .manifest = Manifest .from_dict (
2020 {
21- "id" : "id" ,
21+ "id" : "guardrails/ id" ,
2222 "name" : "name" ,
2323 "author" : {
"name" :
"me" ,
"email" :
"[email protected] " },
2424 "maintainers" : [],
@@ -74,32 +74,30 @@ def test_install_local_models__false(self, mocker, use_remote_inferencing):
7474 )
7575
7676 install (
77- "hub://guardrails/test-validator " ,
77+ "hub://guardrails/id " ,
7878 install_local_models = False ,
7979 install_local_models_confirm = lambda : False ,
8080 )
8181
8282 log_calls = [
83- call (level = 5 , msg = "Installing hub://guardrails/test-validator ..." ),
83+ call (level = 5 , msg = "Installing hub://guardrails/id ..." ),
8484 call (
8585 level = 5 ,
8686 msg = "Skipping post install, models will not be downloaded for local "
8787 "inference." ,
8888 ),
8989 call (
9090 level = 5 ,
91- msg = "✅Successfully installed hub://guardrails/test-validator !\n \n Import validator:\n from guardrails.hub import TestValidator\n \n Get more info:\n https://hub.guardrailsai.com/validator/id\n " , # noqa
91+ msg = "✅Successfully installed hub://guardrails/id !\n \n Import validator:\n from guardrails.hub import TestValidator\n \n Get more info:\n https://hub.guardrailsai.com/validator/guardrails /id\n " , # noqa
9292 ), # noqa
9393 ]
9494 assert mock_logger_log .call_count == 3
9595 mock_logger_log .assert_has_calls (log_calls )
9696
97- get_manifest_and_site_packages_mock .assert_called_once_with (
98- "guardrails/test-validator"
99- )
97+ get_manifest_and_site_packages_mock .assert_called_once_with ("guardrails/id" )
10098
10199 mock_pip_install_hub_module .assert_called_once_with (
102- self .manifest , self . site_packages , quiet = ANY , upgrade = ANY , logger = ANY
100+ self .manifest . id , validator_version = None , quiet = ANY , upgrade = ANY , logger = ANY
103101 )
104102 mock_add_to_hub_init .assert_called_once_with (self .manifest , self .site_packages )
105103
@@ -117,6 +115,9 @@ def test_install_local_models__true(self, mocker, use_remote_inferencing):
117115
118116 mock_logger_log = mocker .patch ("guardrails.hub.install.cli_logger.log" )
119117
118+ pkg_resources = mocker .patch ("guardrails.hub.install.pkg_resources" )
119+ pkg_resources .get_distribution .return_value .version = "1.0.0"
120+
120121 get_manifest_and_site_packages_mock = mocker .patch (
121122 "guardrails.hub.validator_package_service.ValidatorPackageService.get_manifest_and_site_packages"
122123 )
@@ -136,31 +137,29 @@ def test_install_local_models__true(self, mocker, use_remote_inferencing):
136137 )
137138
138139 install (
139- "hub://guardrails/test-validator " ,
140+ "hub://guardrails/id " ,
140141 install_local_models = True ,
141142 install_local_models_confirm = lambda : True ,
142143 )
143144
144145 log_calls = [
145- call (level = 5 , msg = "Installing hub://guardrails/test-validator ..." ),
146+ call (level = 5 , msg = "Installing hub://guardrails/id ..." ),
146147 call (
147148 level = 5 ,
148149 msg = "Installing models locally!" ,
149150 ),
150151 call (
151152 level = 5 ,
152- msg = "✅Successfully installed hub://guardrails/test-validator !\n \n Import validator:\n from guardrails.hub import TestValidator\n \n Get more info:\n https://hub.guardrailsai.com/validator/id\n " , # noqa
153+ msg = "✅Successfully installed hub://guardrails/id !\n \n Import validator:\n from guardrails.hub import TestValidator\n \n Get more info:\n https://hub.guardrailsai.com/validator/guardrails /id\n " , # noqa
153154 ), # noqa
154155 ]
155156 assert mock_logger_log .call_count == 3
156157 mock_logger_log .assert_has_calls (log_calls )
157158
158- get_manifest_and_site_packages_mock .assert_called_once_with (
159- "guardrails/test-validator"
160- )
159+ get_manifest_and_site_packages_mock .assert_called_once_with ("guardrails/id" )
161160
162161 mock_pip_install_hub_module .assert_called_once_with (
163- self .manifest , self . site_packages , quiet = ANY , upgrade = ANY , logger = ANY
162+ self .manifest . id , validator_version = None , quiet = ANY , upgrade = ANY , logger = ANY
164163 )
165164 mock_add_to_hub_init .assert_called_once_with (self .manifest , self .site_packages )
166165
@@ -197,31 +196,29 @@ def test_install_local_models__none(self, mocker, use_remote_inferencing):
197196 )
198197
199198 install (
200- "hub://guardrails/test-validator " ,
199+ "hub://guardrails/id " ,
201200 install_local_models = None ,
202201 install_local_models_confirm = lambda : True ,
203202 )
204203
205204 log_calls = [
206- call (level = 5 , msg = "Installing hub://guardrails/test-validator ..." ),
205+ call (level = 5 , msg = "Installing hub://guardrails/id ..." ),
207206 call (
208207 level = 5 ,
209208 msg = "Installing models locally!" ,
210209 ),
211210 call (
212211 level = 5 ,
213- msg = "✅Successfully installed hub://guardrails/test-validator !\n \n Import validator:\n from guardrails.hub import TestValidator\n \n Get more info:\n https://hub.guardrailsai.com/validator/id\n " , # noqa
212+ msg = "✅Successfully installed hub://guardrails/id !\n \n Import validator:\n from guardrails.hub import TestValidator\n \n Get more info:\n https://hub.guardrailsai.com/validator/guardrails /id\n " , # noqa
214213 ), # noqa
215214 ]
216215 assert mock_logger_log .call_count == 3
217216 mock_logger_log .assert_has_calls (log_calls )
218217
219- get_manifest_and_site_packages_mock .assert_called_once_with (
220- "guardrails/test-validator"
221- )
218+ get_manifest_and_site_packages_mock .assert_called_once_with ("guardrails/id" )
222219
223220 mock_pip_install_hub_module .assert_called_once_with (
224- self .manifest , self . site_packages , quiet = ANY , upgrade = ANY , logger = ANY
221+ self .manifest . id , validator_version = None , quiet = ANY , upgrade = ANY , logger = ANY
225222 )
226223 mock_add_to_hub_init .assert_called_once_with (self .manifest , self .site_packages )
227224
@@ -258,12 +255,12 @@ def test_happy_path(self, mocker, use_remote_inferencing):
258255 )
259256
260257 install (
261- "hub://guardrails/test-validator " ,
258+ "hub://guardrails/id " ,
262259 install_local_models_confirm = lambda : True ,
263260 )
264261
265262 log_calls = [
266- call (level = 5 , msg = "Installing hub://guardrails/test-validator ..." ),
263+ call (level = 5 , msg = "Installing hub://guardrails/id ..." ),
267264 call (
268265 level = 5 ,
269266 msg = "Installing models locally!" , # noqa
@@ -273,12 +270,10 @@ def test_happy_path(self, mocker, use_remote_inferencing):
273270 assert mock_logger_log .call_count == 3
274271 mock_logger_log .assert_has_calls (log_calls )
275272
276- get_manifest_and_site_packages_mock .assert_called_once_with (
277- "guardrails/test-validator"
278- )
273+ get_manifest_and_site_packages_mock .assert_called_once_with ("guardrails/id" )
279274
280275 mock_pip_install_hub_module .assert_called_once_with (
281- self .manifest , self . site_packages , quiet = ANY , upgrade = ANY , logger = ANY
276+ self .manifest . id , validator_version = None , quiet = ANY , upgrade = ANY , logger = ANY
282277 )
283278 mock_add_to_hub_init .assert_called_once_with (self .manifest , self .site_packages )
284279
@@ -408,7 +403,7 @@ def test_use_remote_endpoint(self, mocker, use_remote_inferencing: bool):
408403
409404 manifest = Manifest .from_dict (
410405 {
411- "id" : "id " ,
406+ "id" : "guardrails/test-validator " ,
412407 "name" : "name" ,
413408 "author" : {
"name" :
"me" ,
"email" :
"[email protected] " },
414409 "maintainers" : [],
0 commit comments