The upsert entity is built as a try/except right now. If the entity does not exist when calling the update, a second call is made to insert the entity. This should be able to be done in a single call and the generated code can then be used for batching.