ebonite.core.objects.artifacts module

class ebonite.core.objects.artifacts.Blob[source]

Bases: ebonite.core.objects.artifacts.Blob, pyjackson.decorators.SubtypeRegisterMixin

This class is a base class for blobs. Blob is a binary payload, which can be accessed either through bytestream() context manager, which returns file-like object, or through materialize() method, which places a file in local fs

Must be pyjackson-able or marked Unserializable

type = 'pyjackson.decorators.Blob'
class ebonite.core.objects.artifacts.LocalFileBlob(path: str)[source]

Bases: ebonite.core.objects.artifacts.Blob

Blob implementation for local file

Parameters:path – path to local file
type = 'local_file'
materialize(path)[source]

Copies local file to another path

Parameters:path – target path
bytestream() → Iterable[BinaryIO][source]

Opens file for reading

Returns:file handler
class ebonite.core.objects.artifacts.MaterializeOnlyBlobMixin[source]

Bases: ebonite.core.objects.artifacts.Blob

Mixin for blobs which always have to be materialized first

bytestream() → Iterable[BinaryIO][source]

Materializes blob to temporary dir and returns it’s file handler

Returns:file handler
type = 'ebonite.core.objects.artifacts.MaterializeOnlyBlobMixin'
class ebonite.core.objects.artifacts.InMemoryBlob(payload: bytes)[source]

Bases: ebonite.core.objects.artifacts.Blob, pyjackson.core.Unserializable

Blob implementation for in-memory bytes

Parameters:payload – bytes
type = 'inmemory'
materialize(path)[source]

Writes payload to path

Parameters:path – target path
bytestream() → Iterable[BinaryIO][source]

Creates BytesIO object from bytes

Yields:file-like object
class ebonite.core.objects.artifacts.LazyBlob(source: Callable[[], Union[str, bytes, IO]], encoding: str = 'utf8')[source]

Bases: ebonite.core.objects.artifacts.Blob, pyjackson.core.Unserializable

Represents a lazy blob, which is computed only when needed

Parameters:
  • source – function with no arguments, that must return str, bytes or file-like object
  • encoding – encoding for payload if source returns str of io.StringIO
materialize(path)[source]

Writes payload to path

Parameters:path – target path
bytestream() → Iterable[BinaryIO][source]

Creates BytesIO object from bytes

Yields:file-like object
type = 'ebonite.core.objects.artifacts.LazyBlob'
class ebonite.core.objects.artifacts.ArtifactCollection[source]

Bases: ebonite.core.objects.artifacts.ArtifactCollection, pyjackson.decorators.SubtypeRegisterMixin

Base class for artifact collection. Artifact collection is a number of named artifacts, represented by Blob’s

Must be pyjackson-able

type = 'pyjackson.decorators.ArtifactCollection'
class ebonite.core.objects.artifacts.Blobs(blobs: Dict[str, ebonite.core.objects.artifacts.Blob])[source]

Bases: ebonite.core.objects.artifacts.ArtifactCollection

Artifact collection represented by a dictionary of blobs

Parameters:blobs – dict of name -> blob
type = 'blobs'
materialize(path)[source]

Materializes artifacts to path

Parameters:path – target dir
bytes_dict() → Dict[str, bytes][source]

Implementation must return a dict of artifact name -> artifact payload

Returns:dict of artifact names -> artifact payloads
blob_dict() → AbstractContextManager[Dict[str, ebonite.core.objects.artifacts.Blob]][source]
Yields:self.blobs
class ebonite.core.objects.artifacts.CompositeArtifactCollection(artifacts: List[ebonite.core.objects.artifacts.ArtifactCollection])[source]

Bases: ebonite.core.objects.artifacts.ArtifactCollection

Represents a merger of two or more ArtifactCollections

Parameters:artifacts – ArtifactCollections to merge
type = 'composite'
materialize(path)[source]

Materializes every ArtifactCollection to path

Parameters:path – target dir
bytes_dict() → Dict[str, bytes][source]

Implementation must return a dict of artifact name -> artifact payload

Returns:dict of artifact names -> artifact payloads
blob_dict() → AbstractContextManager[Dict[str, ebonite.core.objects.artifacts.Blob]][source]

Enters all ArtifactCollections blob_dict context managers and returns their union

Yields:name -> blob mapping