Ejemplo n.º 1
0
def test_repository_tags():
    tags = repository_tags_at_dockerhub('python')
    assert f'{get_python_version()}-slim' in tags
    assert get_python_version() in tags

    tags = repository_tags_at_dockerhub('minio/minio')
    assert 'latest' in tags
Ejemplo n.º 2
0
 def __init__(self,
              base_image=None,
              python_version=None,
              templates_dir=None,
              run_cmd='sh run.sh'):
     self.python_version = python_version or get_python_version()
     self.base_image = base_image or f'python:{self.python_version}-slim'
     self.templates_dir = templates_dir or os.path.join(
         os.getcwd(), 'docker_templates')
     self.run_cmd = run_cmd
Ejemplo n.º 3
0
 def load(self):
     """
     Load model artifacts into wrapper
     """
     if get_python_version() != self.params.get(self.PYTHON_VERSION):
         warnings.warn(
             f'Loading model from different python version {self.params.get(self.PYTHON_VERSION)}'
         )
     with tempfile.TemporaryDirectory(prefix='ebonite_run_') as tmpdir:
         self.artifact.materialize(tmpdir)
         self.wrapper.load(tmpdir)
Ejemplo n.º 4
0
    def create(cls,
               model_object,
               input_data,
               model_name: str = None,
               params: Dict[str, Any] = None,
               description: str = None,
               additional_artifacts: ArtifactCollection = None,
               additional_requirements: AnyRequirements = None,
               custom_wrapper: ModelWrapper = None,
               custom_artifact: ArtifactCollection = None,
               custom_requirements: AnyRequirements = None) -> 'Model':
        """
        Creates Model instance from arbitrary model objects and sample of input data

        :param model_object: The model object to analyze.
        :param input_data: Input data sample to determine structure of inputs and outputs for given model object.
        :param model_name: The model name.
        :param params: dict with arbitrary parameters. Must be json-serializable
        :param description: text description of this model
        :param additional_artifacts: Additional artifact.
        :param additional_requirements: Additional requirements.
        :param custom_wrapper: Custom model wrapper.
        :param custom_artifact: Custom artifact collection to replace all other.
        :param custom_requirements: Custom requirements to replace all other.
        :returns: :py:class:`Model`
        """
        wrapper: ModelWrapper = custom_wrapper or ModelAnalyzer.analyze(
            model_object, input_data=input_data)
        name = model_name or _generate_model_name(wrapper)

        artifact = custom_artifact or WrapperArtifactCollection(wrapper)
        if additional_artifacts is not None:
            artifact += additional_artifacts

        if custom_requirements is not None:
            requirements = resolve_requirements(custom_requirements)
        else:
            requirements = wrapper.requirements

        if additional_requirements is not None:
            requirements += additional_requirements

        requirements = RequirementAnalyzer.analyze(requirements)
        params = params or {}
        params[cls.PYTHON_VERSION] = params.get(cls.PYTHON_VERSION,
                                                get_python_version())
        model = Model(name, wrapper, None, requirements, params, description)
        model._unpersisted_artifacts = artifact
        return model
Ejemplo n.º 5
0
 def get_python_version(self):
     """Returns current python version"""
     return get_python_version()
Ejemplo n.º 6
0
 def python_version(self):
     return self._python_version or get_python_version()