Пример #1
0
def artifact_collection():
    blobs = Blobs({
        '1': InMemoryBlob(bytes(123)),
        '2': InMemoryBlob(bytes(321))
    })

    ac = blobs + _RelativePathWrapper(blobs, 'first') + _RelativePathWrapper(
        blobs, 'second')
    ac += _RelativePathWrapper(blobs, 'third')

    ret = ac + _RelativePathWrapper(ac, 'go')
    ret += _RelativePathWrapper(ac, 'be')
    return ret
Пример #2
0
 def get_artifacts(self) -> ArtifactCollection:
     """Returns binaries of models artifacts"""
     return CompositeArtifactCollection([
         _RelativePathWrapper(m.artifact_any,
                              os.path.join(MODEL_BIN_PATH, str(i)))
         for i, m in enumerate(self.models)
     ])
Пример #3
0
    def dump(self, model) -> ArtifactCollection:
        """
        Dumps model artifacts as :class:`~ebonite.core.objects.ArtifactCollection`

        :return: context manager with :class:`~ebonite.core.objects.ArtifactCollection`
        """
        model_blob, refs = self._serialize_model(model)
        blobs = {self.model_filename: InMemoryBlob(model_blob)}
        artifact_cms = []
        uuids = []

        for uuid, (io, obj) in refs.items():
            blobs[uuid + self.io_ext] = InMemoryBlob(self._serialize_io(io))
            artifact_cms.append(io.dump(obj))
            uuids.append(uuid)

        from ebonite.core.objects.artifacts import _enter_all_cm, _ExitAllCm, _RelativePathWrapper
        additional_artifacts = _enter_all_cm(artifact_cms)
        with _ExitAllCm(artifact_cms):
            additional_artifacts = [
                _RelativePathWrapper(art, uuid)
                for art, uuid in zip(additional_artifacts, uuids)
            ]
            yield CompositeArtifactCollection([Blobs(blobs)] +
                                              additional_artifacts)
Пример #4
0
    def get_artifacts(self) -> ArtifactCollection:
        """Return model binaries"""

        artifacts = CompositeArtifactCollection(
            [_RelativePathWrapper(m.artifact_any, os.path.join(MODEL_BIN_PATH, m.name)) for m in
             self.pipeline.models.values()])
        if len(self.server.additional_binaries) > 0:
            artifacts = CompositeArtifactCollection([
                artifacts,
                Blobs({os.path.basename(f): LocalFileBlob(f) for f in self.server.additional_binaries})
            ])
        return artifacts
Пример #5
0
 def get_artifacts(self) -> ArtifactCollection:
     """Return model binaries"""
     artifacts = _RelativePathWrapper(self.model.artifact_any,
                                      MODEL_BIN_PATH)
     if len(self.server.additional_binaries) > 0:
         artifacts = CompositeArtifactCollection([
             artifacts,
             Blobs({
                 os.path.basename(f): LocalFileBlob(f)
                 for f in self.server.additional_binaries
             })
         ])
     return artifacts
Пример #6
0
    def dump(self) -> ArtifactCollection:
        """
        Dumps model artifacts as :class:`~ebonite.core.objects.ArtifactCollection`

        :return: context manager with :class:`~ebonite.core.objects.ArtifactCollection`
        """
        model_blob, refs = self._serialize_model()
        blobs = {self.model_filename: InMemoryBlob(model_blob)}
        additional_artifacts = []

        for uuid, wrapper in refs.items():
            blobs[uuid + self.wrapper_ext] = InMemoryBlob(
                self._serialize_wrapper(wrapper))
            with wrapper.dump() as artifact:
                additional_artifacts.append(
                    _RelativePathWrapper(artifact, uuid))

        yield CompositeArtifactCollection([Blobs(blobs)] +
                                          additional_artifacts)
Пример #7
0
 def get_artifacts(self) -> ArtifactCollection:
     """Return model binaries"""
     return _RelativePathWrapper(self.model.artifact_any, MODEL_BIN_PATH)