import tempfile
import tarfile


def create_model_archive(model_weights_file, model_class_file):
    """
    Creates a temporary archvie of the model using the weights and class
    definition.
    The created archive's location is returned.
    """
    _, tar_location = tempfile.mkstemp()
    with tarfile.open(tar_location, "w:gz") as tarout:
        tarout.add(model_weights_file, arcname="model.pt")
        tarout.add(model_class_file, arcname="model.py")
    return tar_location