Example #1
0
    def test_run_skip_package(self, context: Context, state: State,
                              tf_name: str, tf_version: str) -> None:
        """Test removing scipy from a TensorFlow stack."""
        scipy_package_version = PackageVersion(
            name="scipy",
            version="==1.2.2",
            develop=False,
            index=Source("https://pypi.org/simple"),
        )
        tf_package_version = PackageVersion(
            name=tf_name,
            version=f"=={tf_version}",
            develop=False,
            index=Source("https://pypi.org/simple"),
        )

        assert "tensorflow" not in state.resolved_dependencies
        state.resolved_dependencies[
            "tensorflow"] = tf_package_version.to_tuple()
        context.register_package_version(tf_package_version)
        context.dependents["scipy"] = {
            scipy_package_version.to_tuple():
            {(tf_package_version.to_tuple(), "rhel", "8", "3.6")}
        }

        with TensorFlowRemoveSciPyStep.assigned_context(context):
            unit = TensorFlowRemoveSciPyStep()
            with pytest.raises(SkipPackage):
                unit.run(state, scipy_package_version)
Example #2
0
    def test_run_deps(self, context: Context, state: State) -> None:
        """Test not removing scipy from a TensorFlow stack if introduced by another dependency."""
        scipy_package_version = PackageVersion(
            name="scipy",
            version="==1.2.2",
            develop=False,
            index=Source("https://pypi.org/simple"),
        )
        tf_package_version = PackageVersion(
            name="tensorflow",
            version="==2.2.0",
            develop=False,
            index=Source("https://pypi.org/simple"),
        )
        another_package_version = PackageVersion(
            name="some-package",
            version="==1.0.0",
            develop=False,
            index=Source("https://pypi.org/simple"),
        )

        assert "tensorflow" not in state.resolved_dependencies
        state.resolved_dependencies[
            "tensorflow"] = tf_package_version.to_tuple()
        state.resolved_dependencies[
            another_package_version.name] = another_package_version.to_tuple()
        context.register_package_version(tf_package_version)
        context.dependents["scipy"] = {
            scipy_package_version.to_tuple(): {
                (tf_package_version.to_tuple(), "rhel", "8", "3.6"),
                (another_package_version.to_tuple(), "rhel", "8", "3.6"),
            }
        }

        unit = TensorFlowRemoveSciPyStep()
        with TensorFlowRemoveSciPyStep.assigned_context(context):
            assert unit.run(state, scipy_package_version) is None