Exemple #1
0
    def test_from_env(self):
        reqs = Python.read_pip_environment(skip_options=True, )
        env = Python(requirements=reqs)
        assert env._msg.python.requirements
        assert not env._msg.python.raw_requirements

        reqs = _pip_requirements_utils.pin_verta_and_cloudpickle(reqs)
        assert_parsed_reqs_match(env.requirements, reqs)
    def test_log_environment(self, registered_model):
        model_version = registered_model.get_or_create_version(
            name="my version")

        reqs = Python.read_pip_environment()
        env = Python(requirements=reqs)
        model_version.log_environment(env)

        model_version = registered_model.get_version(id=model_version.id)
        assert str(env) == str(model_version.get_environment())
    def test_log_environment(self, registered_model):
        model_version = registered_model.get_or_create_version(
            name="my version")

        reqs = Python.read_pip_environment()
        env = Python(requirements=reqs)
        model_version.log_environment(env)

        model_version = registered_model.get_version(id=model_version.id)
        assert str(env) == str(model_version.get_environment())

        with pytest.raises(ValueError):
            model_version.log_environment(env)
        model_version.log_environment(env, overwrite=True)
        assert str(env) == str(model_version.get_environment())
    def test_del_environment(self, registered_model):
        model_version = registered_model.get_or_create_version(
            name="my version")

        reqs = Python.read_pip_environment()
        env = Python(requirements=reqs)
        model_version.log_environment(env)
        model_version.del_environment()

        model_version = registered_model.get_version(id=model_version.id)
        assert not model_version.has_environment

        with pytest.raises(RuntimeError) as excinfo:
            model_version.get_environment()

        assert "environment was not previously set" in str(excinfo.value)
Exemple #5
0
    def test_skip_spacy_models(self):
        pattern = SPACY_MODEL_PATTERN + "=="
        requirements = Python.read_pip_environment()

        assert not any(re.match(pattern, req) for req in requirements)
 def test_reqs_from_env(self):
     reqs = Python.read_pip_environment()
     env = Python(requirements=reqs)
     assert env._msg.python.requirements