Skip to content

trained_model_artifact

Trained model.

Classes:

Name Description
TrainedModelArtifact

Trained model class, representing a trained model artifact.

TrainedModelArtifact #

Trained model class, representing a trained model artifact.

This object is build after finishing a training process, and should never be built manually. It is not allowed to update an instance of it as it is also saved remotely. However, it is still safe to update its name and description

Parameters:

Name Type Description Default

id #

str
required

created_at #

str
required

created_by #

str
required

updated_at #

str
required

updated_by #

str
required

project_id #

str
required

hash_ #

str
required

private #

str
required

name #

str
required

description #

str
required

core_version #

str
required

project #

str
required

input_steps #

str
required

output_steps #

str
required

type_ #

str
required

checkpoints #

str
required

best_checkpoint #

str
required

Attributes:

Name Type Description
additional_properties str

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

Methods:

Name Description
__setattr__

Set attribute.

load_all

Load all explanations of the current project.

get_by_id

Get Explanation artifact by its ID.

get_by_name

Get Explanation artifact by its name.

delete

Delete the current object remotely.

__setattr__(attr: str, value: object) -> None #

Set attribute.

Source code in src/xpdeep/model/trained_model_artifact.py
@initialized_client_verification
@initialized_project_verification
def __setattr__(self, attr: str, value: object) -> None:
    """Set attribute."""
    if attr in {"name", "description"} and hasattr(self, attr):
        with ClientFactory.CURRENT.get()() as client:
            update_trained_model_artifact.sync(
                Project.CURRENT.get().model.id,
                self.id,
                client=client,
                body=TrainedModelArtifactUpdate(
                    type_="TRAINED_MODEL",
                    name=value if attr == "name" else None,  # type: ignore[arg-type]
                    description=value if attr == "description" else None,  # type: ignore[arg-type]
                ),
            )
    elif hasattr(self, attr) and attr != "additional_properties":
        message = f'Updating attribute "{attr}" is not allowed'
        raise AttributeError(message)

    object.__setattr__(self, attr, value)

load_all() -> list[TrainedModelArtifact] #

Load all explanations of the current project.

Source code in src/xpdeep/model/trained_model_artifact.py
@classmethod
@initialized_client_verification
@initialized_project_verification
def load_all(cls) -> list["TrainedModelArtifact"]:
    """Load all explanations of the current project."""
    return [cls.from_dict(select_one.to_dict()) for select_one in cls._load()]

get_by_id(trained_model_id: str) -> TrainedModelArtifact #

Get Explanation artifact by its ID.

Parameters:

Name Type Description Default
trained_model_id #
str

The ID of the explanation artifact to retrieve.

required
Source code in src/xpdeep/model/trained_model_artifact.py
@classmethod
@initialized_client_verification
@initialized_project_verification
def get_by_id(cls, trained_model_id: str) -> "TrainedModelArtifact":
    """Get Explanation artifact by its ID.

    Parameters
    ----------
    trained_model_id : str
        The ID of the explanation artifact to retrieve.
    """
    try:
        return cls.from_dict(next(iter(cls._load(trained_model_id=trained_model_id))).to_dict())
    except StopIteration as err:
        message = f"No Trained Model artifact found for the ID: {trained_model_id}"
        raise NotSavedError(message) from err

get_by_name(trained_model_id: str) -> TrainedModelArtifact #

Get Explanation artifact by its name.

Parameters:

Name Type Description Default
trained_model_id #
str

The name of the explanation artifact to retrieve.

required
Source code in src/xpdeep/model/trained_model_artifact.py
@classmethod
@initialized_client_verification
@initialized_project_verification
def get_by_name(cls, trained_model_id: str) -> "TrainedModelArtifact":
    """Get Explanation artifact by its name.

    Parameters
    ----------
    trained_model_id : str
        The name of the explanation artifact to retrieve.
    """
    try:
        return cls.from_dict(next(iter(cls._load(trained_model_name=trained_model_id))).to_dict())
    except StopIteration as err:
        message = f"No Trained Model artifact found for the name: {trained_model_id}"
        raise NotSavedError(message) from err

delete() -> None #

Delete the current object remotely.

Source code in src/xpdeep/model/trained_model_artifact.py
@initialized_client_verification
@initialized_project_verification
def delete(self) -> None:
    """Delete the current object remotely."""
    with ClientFactory.CURRENT.get()() as client:
        delete_one_trained_model_artifact.sync(
            Project.CURRENT.get().model.id,
            self.id,
            client=client,
        )