Open CalebCourier opened 1 week ago
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
Expected behavior Validator should be uninstalled successfully without an error. If certain file paths don't exist then just skip over them.
Library version: Version (e.g. 0.1.5)
Additional context
guardrails hub uninstall hub://brainlogic/high_quality_translation
Uninstalling hub://brainlogic/high_quality_translation...
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.venv/lib/python3.12/site-packages │ │ /guardrails/cli/hub/uninstall.py:107 in uninstall │ │ │ │ 104 │ │ │ 105 │ # Cleanup │ │ 106 │ with console.status("Cleaning up", spinner="bouncingBar"): │ │ ❱ 107 │ │ remove_from_hub_inits(module_manifest, site_packages) │ │ 108 │ │ │ 109 │ console.print("✅ Successfully uninstalled!") # type: ignore │ │ 110 │ logger.log(level=LEVELS.get("SPAM"), msg="✅ Successfully uninstalled!") # type: ig │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ module_manifest = ModuleManifest( │ │ │ │ │ id='brainlogic/high_quality_translation', │ │ │ │ │ name='High Quality Translation', │ │ │ │ │ author=Contributor( │ │ │ │ │ │ name='BrainLogic AI', │ │ │ │ │ │ email='nicolas@brainlogic.ai' │ │ │ │ │ ), │ │ │ │ │ maintainers=[ │ │ │ │ │ │ Contributor(name='Nicolás Loeff', email='nicolas@brainlogic.ai') │ │ │ │ │ ], │ │ │ │ │ repository=Repository( │ │ │ │ │ │ │ │ │ │ url='https://github.com/BrainLogicHub/high_quality_translation_validator.… │ │ │ │ │ │ branch=None │ │ │ │ │ ), │ │ │ │ │ namespace='brainlogic', │ │ │ │ │ package_name='high_quality_translation', │ │ │ │ │ module_name='validator', │ │ │ │ │ exports=['HighQualityTranslation'], │ │ │ │ │ tags=ModuleTags( │ │ │ │ │ │ content_type=['string'], │ │ │ │ │ │ validation_category=[], │ │ │ │ │ │ process_requirements=[] │ │ │ │ │ ), │ │ │ │ │ requires_auth=False, │ │ │ │ │ post_install='post-install.py', │ │ │ │ │ index='./init.py', │ │ │ │ │ required_model_auth=[] │ │ │ │ ) │ │ │ │ module_name = 'brainlogic/high_quality_translation' │ │ │ │ package_uri = 'hub://brainlogic/high_quality_translation' │ │ │ │ site_packages = '/Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.venv/lib/… │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.venv/lib/python3.12/site-packages │ │ /guardrails/cli/hub/uninstall.py:52 in remove_from_hub_inits │ │ │ │ 49 │ namespace_init_location = os.path.join( │ │ 50 │ │ site_packages, "guardrails", "hub", namespace, "init.py" │ │ 51 │ ) │ │ ❱ 52 │ lines = remove_line(namespace_init_location, import_line) │ │ 53 │ │ │ 54 │ # remove namespace pkg if namespace init.py is empty │ │ 55 │ if (len(lines) == 0) and (namespace != "hub"): │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ exports = ['HighQualityTranslation'] │ │ │ │ hub_init_location = '/Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.v… │ │ │ │ import_line = 'from guardrails.hub.brainlogic.high_quality_translation.validator │ │ │ │ import HighQua'+15 │ │ │ │ manifest = ModuleManifest( │ │ │ │ │ id='brainlogic/high_quality_translation', │ │ │ │ │ name='High Quality Translation', │ │ │ │ │ author=Contributor( │ │ │ │ │ │ name='BrainLogic AI', │ │ │ │ │ │ email='nicolas@brainlogic.ai' │ │ │ │ │ ), │ │ │ │ │ maintainers=[ │ │ │ │ │ │ Contributor( │ │ │ │ │ │ │ name='Nicolás Loeff', │ │ │ │ │ │ │ email='nicolas@brainlogic.ai' │ │ │ │ │ │ ) │ │ │ │ │ ], │ │ │ │ │ repository=Repository( │ │ │ │ │ │ │ │ │ │ url='https://github.com/BrainLogicHub/high_quality_translation_va… │ │ │ │ │ │ branch=None │ │ │ │ │ ), │ │ │ │ │ namespace='brainlogic', │ │ │ │ │ package_name='high_quality_translation', │ │ │ │ │ module_name='validator', │ │ │ │ │ exports=['HighQualityTranslation'], │ │ │ │ │ tags=ModuleTags( │ │ │ │ │ │ content_type=['string'], │ │ │ │ │ │ validation_category=[], │ │ │ │ │ │ process_requirements=[] │ │ │ │ │ ), │ │ │ │ │ requires_auth=False, │ │ │ │ │ post_install='post-install.py', │ │ │ │ │ index='./init.py', │ │ │ │ │ required_model_auth=[] │ │ │ │ ) │ │ │ │ module_name = 'validator' │ │ │ │ namespace = 'brainlogic' │ │ │ │ namespace_init_location = '/Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.v… │ │ │ │ org_package = ['brainlogic', 'high_quality_translation'] │ │ │ │ relative_path = 'brainlogic.high_quality_translation.validator' │ │ │ │ site_packages = '/Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.v… │ │ │ │ sorted_exports = ['HighQualityTranslation'] │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.venv/lib/python3.12/site-packages │ │ /guardrails/cli/hub/uninstall.py:24 in remove_line │ │ │ │ 21 │ │ 22 │ │ 23 def remove_line(file_path: str, line_content: str): │ │ ❱ 24 │ with open(file_path, "r+") as file: │ │ 25 │ │ lines = file.readlines() │ │ 26 │ │ file.seek(0) │ │ 27 │ │ lines = [line for line in lines if line.strip() != line_content.strip()] │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ file_path = '/Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.venv/lib/pyt… │ │ │ │ line_content = 'from guardrails.hub.brainlogic.high_quality_translation.validator import │ │ │ │ HighQua'+15 │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ FileNotFoundError: [Errno 2] No such file or directory: '/Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.venv/lib/python3.12/site-packages/gua rdrails/hub/brainlogic/init.py'
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
Expected behavior Validator should be uninstalled successfully without an error. If certain file paths don't exist then just skip over them.
Library version: Version (e.g. 0.1.5)
Additional context
Uninstalling hub://brainlogic/high_quality_translation...
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.venv/lib/python3.12/site-packages │ │ /guardrails/cli/hub/uninstall.py:107 in uninstall │ │ │ │ 104 │ │ │ 105 │ # Cleanup │ │ 106 │ with console.status("Cleaning up", spinner="bouncingBar"): │ │ ❱ 107 │ │ remove_from_hub_inits(module_manifest, site_packages) │ │ 108 │ │ │ 109 │ console.print("✅ Successfully uninstalled!") # type: ignore │ │ 110 │ logger.log(level=LEVELS.get("SPAM"), msg="✅ Successfully uninstalled!") # type: ig │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ module_manifest = ModuleManifest( │ │ │ │ │ id='brainlogic/high_quality_translation', │ │ │ │ │ name='High Quality Translation', │ │ │ │ │ author=Contributor( │ │ │ │ │ │ name='BrainLogic AI', │ │ │ │ │ │ email='nicolas@brainlogic.ai' │ │ │ │ │ ), │ │ │ │ │ maintainers=[ │ │ │ │ │ │ Contributor(name='Nicolás Loeff', email='nicolas@brainlogic.ai') │ │ │ │ │ ], │ │ │ │ │ repository=Repository( │ │ │ │ │ │ │ │ │ │ url='https://github.com/BrainLogicHub/high_quality_translation_validator.… │ │ │ │ │ │ branch=None │ │ │ │ │ ), │ │ │ │ │ namespace='brainlogic', │ │ │ │ │ package_name='high_quality_translation', │ │ │ │ │ module_name='validator', │ │ │ │ │ exports=['HighQualityTranslation'], │ │ │ │ │ tags=ModuleTags( │ │ │ │ │ │ content_type=['string'], │ │ │ │ │ │ validation_category=[], │ │ │ │ │ │ process_requirements=[] │ │ │ │ │ ), │ │ │ │ │ requires_auth=False, │ │ │ │ │ post_install='post-install.py', │ │ │ │ │ index='./init.py', │ │ │ │ │ required_model_auth=[] │ │ │ │ ) │ │ │ │ module_name = 'brainlogic/high_quality_translation' │ │ │ │ package_uri = 'hub://brainlogic/high_quality_translation' │ │ │ │ site_packages = '/Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.venv/lib/… │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.venv/lib/python3.12/site-packages │ │ /guardrails/cli/hub/uninstall.py:52 in remove_from_hub_inits │ │ │ │ 49 │ namespace_init_location = os.path.join( │ │ 50 │ │ site_packages, "guardrails", "hub", namespace, "init.py" │ │ 51 │ ) │ │ ❱ 52 │ lines = remove_line(namespace_init_location, import_line) │ │ 53 │ │ │ 54 │ # remove namespace pkg if namespace init.py is empty │ │ 55 │ if (len(lines) == 0) and (namespace != "hub"): │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ exports = ['HighQualityTranslation'] │ │ │ │ hub_init_location = '/Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.v… │ │ │ │ import_line = 'from guardrails.hub.brainlogic.high_quality_translation.validator │ │ │ │ import HighQua'+15 │ │ │ │ manifest = ModuleManifest( │ │ │ │ │ id='brainlogic/high_quality_translation', │ │ │ │ │ name='High Quality Translation', │ │ │ │ │ author=Contributor( │ │ │ │ │ │ name='BrainLogic AI', │ │ │ │ │ │ email='nicolas@brainlogic.ai' │ │ │ │ │ ), │ │ │ │ │ maintainers=[ │ │ │ │ │ │ Contributor( │ │ │ │ │ │ │ name='Nicolás Loeff', │ │ │ │ │ │ │ email='nicolas@brainlogic.ai' │ │ │ │ │ │ ) │ │ │ │ │ ], │ │ │ │ │ repository=Repository( │ │ │ │ │ │ │ │ │ │ url='https://github.com/BrainLogicHub/high_quality_translation_va… │ │ │ │ │ │ branch=None │ │ │ │ │ ), │ │ │ │ │ namespace='brainlogic', │ │ │ │ │ package_name='high_quality_translation', │ │ │ │ │ module_name='validator', │ │ │ │ │ exports=['HighQualityTranslation'], │ │ │ │ │ tags=ModuleTags( │ │ │ │ │ │ content_type=['string'], │ │ │ │ │ │ validation_category=[], │ │ │ │ │ │ process_requirements=[] │ │ │ │ │ ), │ │ │ │ │ requires_auth=False, │ │ │ │ │ post_install='post-install.py', │ │ │ │ │ index='./init.py', │ │ │ │ │ required_model_auth=[] │ │ │ │ ) │ │ │ │ module_name = 'validator' │ │ │ │ namespace = 'brainlogic' │ │ │ │ namespace_init_location = '/Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.v… │ │ │ │ org_package = ['brainlogic', 'high_quality_translation'] │ │ │ │ relative_path = 'brainlogic.high_quality_translation.validator' │ │ │ │ site_packages = '/Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.v… │ │ │ │ sorted_exports = ['HighQualityTranslation'] │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.venv/lib/python3.12/site-packages │ │ /guardrails/cli/hub/uninstall.py:24 in remove_line │ │ │ │ 21 │ │ 22 │ │ 23 def remove_line(file_path: str, line_content: str): │ │ ❱ 24 │ with open(file_path, "r+") as file: │ │ 25 │ │ lines = file.readlines() │ │ 26 │ │ file.seek(0) │ │ 27 │ │ lines = [line for line in lines if line.strip() != line_content.strip()] │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ file_path = '/Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.venv/lib/pyt… │ │ │ │ line_content = 'from guardrails.hub.brainlogic.high_quality_translation.validator import │ │ │ │ HighQua'+15 │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ FileNotFoundError: [Errno 2] No such file or directory: '/Users/calebcourier/Projects/gr-mono/guardrails/docs/examples/.venv/lib/python3.12/site-packages/gua rdrails/hub/brainlogic/init.py'