Save during attach operation
Proposed solution:
def attach(self, attribute: str, artifact: bytes, uri: str, commit: bool = True, **kwargs):
"""Attach an artifact to an attribute field.
Args:
attribute: the attribute the artifact should be assigned to
artifact: the artifact to be stored
uri: the uri that determines where the artifact is to be stored.
**kwargs: additional metadata that should be recorded with the artifact
Returns:
the attached artifact
"""
artifact = Artifact.create(artifact=artifact, uri=uri, attached_to=self.id, **kwargs)
setattr(self, attribute, artifact)
self.save(commit=commit)
return artifact
Edited by Michael Loster