Exemple #1
0
def test_installable_requirement__from_module():
    import pandas as pd
    assert InstallableRequirement.from_module(
        pd).to_str() == f'pandas=={pd.__version__}'

    import numpy as np
    assert InstallableRequirement.from_module(
        np).to_str() == f'numpy=={np.__version__}'

    import sklearn as sk
    assert InstallableRequirement.from_module(
        sk).to_str() == f'scikit-learn=={sk.__version__}'
    assert InstallableRequirement.from_module(
        sk, 'xyz').to_str() == f'xyz=={sk.__version__}'
Exemple #2
0
 def requirements(self) -> Requirements:
     return Requirements([InstallableRequirement.from_module(tf)
                          ]) + super().requirements.fget(self)
Exemple #3
0
 def _model_requirements(self) -> Requirements:
     if get_object_base_module(self.model) is sklearn:
         return Requirements([InstallableRequirement.from_module(sklearn)])
     # some sklearn compatible model (either from library or user code) - fallback
     return super()._model_requirements()
Exemple #4
0
 def requirements(self) -> Requirements:
     return Requirements([InstallableRequirement.from_module(lgb)
                          ]) + self.inner.requirements
Exemple #5
0
 def _model_requirements(self) -> Requirements:
     return Requirements([
         InstallableRequirement.from_module(lib) for lib in self.libraries
     ])