def METHOD_NAME(self, model_name: Optional[str] = None) -> Optional[int]:
    """Upsert a model given a model name, returns the model id."""
    # No model specified
    if model_name is None:
        return None
    with Session(self._engine) as session:
        model = session.exec(select(Model).where(Model.name == model_name)).first()
        if model is None:
            self._logger.info(f"could not find a model with name '{model_name}', creating new")
            model = Model(name=model_name)
            session.add(model)
            session.commit()
        return model.id