Skip to content

modosaic.core.experiment_artifact

modosaic.core.experiment_artifact

ExperimentArtifact dataclass

ExperimentArtifact(relative_path, payload, kind)

Artifact payload plus the relative path where it should be saved.

Attributes:

Name Type Description
relative_path Path

Path below the experiment directory.

payload T

Artifact content.

kind ExperimentArtifactKind

Serialization strategy used by ExperimentService.

array classmethod

array(relative_path, payload)

Create a NumPy .npy array artifact.

Source code in modosaic/core/experiment_artifact.py
41
42
43
44
@classmethod
def array(cls, relative_path: str | Path, payload: np.ndarray) -> "ExperimentArtifact[np.ndarray]":
    """Create a NumPy `.npy` array artifact."""
    return cls(Path(relative_path), payload, ExperimentArtifactKind.ARRAY)

array_collection classmethod

array_collection(relative_path, payload)

Create a NumPy .npz array-collection artifact.

Source code in modosaic/core/experiment_artifact.py
46
47
48
49
50
51
52
53
@classmethod
def array_collection(
        cls,
        relative_path: str | Path,
        payload: Sequence[np.ndarray] | Mapping[str, np.ndarray],
) -> "ExperimentArtifact[Sequence[np.ndarray] | Mapping[str, np.ndarray]]":
    """Create a NumPy `.npz` array-collection artifact."""
    return cls(Path(relative_path), payload, ExperimentArtifactKind.ARRAY_COLLECTION)

bytes classmethod

bytes(relative_path, payload)

Create a raw bytes artifact.

Source code in modosaic/core/experiment_artifact.py
65
66
67
68
@classmethod
def bytes(cls, relative_path: str | Path, payload: bytes) -> "ExperimentArtifact[bytes]":
    """Create a raw bytes artifact."""
    return cls(Path(relative_path), payload, ExperimentArtifactKind.BYTES)

image classmethod

image(relative_path, payload)

Create a PIL image artifact.

Source code in modosaic/core/experiment_artifact.py
55
56
57
58
@classmethod
def image(cls, relative_path: str | Path, payload: Image) -> "ExperimentArtifact[Image]":
    """Create a PIL image artifact."""
    return cls(Path(relative_path), payload, ExperimentArtifactKind.IMAGE)

json classmethod

json(relative_path, payload)

Create a JSON artifact.

Source code in modosaic/core/experiment_artifact.py
60
61
62
63
@classmethod
def json(cls, relative_path: str | Path, payload: Any) -> "ExperimentArtifact[Any]":
    """Create a JSON artifact."""
    return cls(Path(relative_path), payload, ExperimentArtifactKind.JSON)

text classmethod

text(relative_path, payload)

Create a UTF-8 text artifact.

Source code in modosaic/core/experiment_artifact.py
36
37
38
39
@classmethod
def text(cls, relative_path: str | Path, payload: str) -> "ExperimentArtifact[str]":
    """Create a UTF-8 text artifact."""
    return cls(Path(relative_path), payload, ExperimentArtifactKind.TEXT)

ExperimentArtifactKind

Bases: StrEnum

Supported artifact payload types for experiment persistence.