:return: tuple(command_success: bool, latest_version_value: str) """ pypi_package_info = requests.get(f"https://pypi.org/pypi/{package}/json") data = json.loads(pypi_package_info.text) versions = data["releases"].keys() return str(max(Version(v) for v in versions)) @pytest.mark.usefixtures("sagemaker") @pytest.mark.model("N/A") @pytest.mark.canary("Run safety tests regularly on production images") @pytest.mark.skipif( not is_dlc_cicd_context(), reason="Skipping test because it is not running in dlc cicd infra") @pytest.mark.skipif( not (is_mainline_context() or is_safety_test_context() or (is_canary_context() and is_time_for_canary_safety_scan())), reason= ("Skipping the test to decrease the number of calls to the Safety Check DB. " "Test will be executed in the 'mainline' pipeline and canaries pipeline." ), ) def test_safety(image): """ Runs safety check on a container with the capability to ignore safety issues that cannot be fixed, and only raise error if an issue is fixable. """ from dlc.safety_check import SafetyCheck safety_check = SafetyCheck()
:return: tuple(command_success: bool, latest_version_value: str) """ pypi_package_info = requests.get(f"https://pypi.org/pypi/{package}/json") data = json.loads(pypi_package_info.text) versions = data["releases"].keys() return str(max(Version(v) for v in versions)) @pytest.mark.usefixtures("sagemaker") @pytest.mark.model("N/A") @pytest.mark.canary("Run safety tests regularly on production images") @pytest.mark.skipif( not is_dlc_cicd_context(), reason="Skipping test because it is not running in dlc cicd infra") @pytest.mark.skipif( not (is_safety_test_context()), reason= ("Skipping the test to decrease the number of calls to the Safety Check DB. " "Test will be executed in the 'mainline' pipeline and canaries pipeline." ), ) def test_safety(image): """ Runs safety check on a container with the capability to ignore safety issues that cannot be fixed, and only raise error if an issue is fixable. """ from dlc.safety_check import SafetyCheck safety_check = SafetyCheck() repo_name, image_tag = image.split("/")[-1].split(":")
:param package: str Name of the package whose latest version must be retrieved :return: tuple(command_success: bool, latest_version_value: str) """ pypi_package_info = requests.get(f"https://pypi.org/pypi/{package}/json") data = json.loads(pypi_package_info.text) versions = data["releases"].keys() return str(max(Version(v) for v in versions)) @pytest.mark.usefixtures("sagemaker") @pytest.mark.model("N/A") @pytest.mark.canary("Run safety tests regularly on production images") @pytest.mark.skipif(not is_dlc_cicd_context(), reason="Skipping test because it is not running in dlc cicd infra") @pytest.mark.skipif( not ( is_safety_test_context() ), reason=( "Skipping the test to decrease the number of calls to the Safety Check DB. " "Test will be executed in the 'mainline' pipeline and canaries pipeline." ), ) def test_safety(image): """ Runs safety check on a container with the capability to ignore safety issues that cannot be fixed, and only raise error if an issue is fixable. """ from dlc.safety_check import SafetyCheck safety_check = SafetyCheck()