Setting the correct Python data_path for vertex motion? I am currently using Blender 2.80, and am attempting to follow along with the tutorial at this link on animating mesh objects (https://medium.com/@behreajj/creative-coding-in-blender-a-primer-53e79ff71e)

Specifically, I am referring to the section where the author morphs the shape of Suzanne.

I am attempting to do the same for the grid object, and while the graph editor clearly shows the vertices are moving to where I want, the animation shows that the mesh does not change whatsoever. 

I am puzzled as to how the tutorial works for Suzanne, but this does not. I see that there is an alternate method using shape keys, but the code below should still work right?

import bpy
import numpy as np

pi = np.pi

#Clear out the objects on the screen
scene = bpy.context.scene
for obj in bpy.data.objects:
    bpy.data.objects.remove(obj, do_unlink=True)

#Make a grid object to animate
bpy.ops.mesh.primitive_grid_add(x_subdivisions=20, y_subdivisions=20,size=10)
obj = bpy.context.active_object
mesh = obj.data

frames = np.arange(0,250,20)
T =15*6
for fram_num in frames:
    scene.frame_set(fram_num)
    t = fram_num * 2*pi/T
    #Move all vertices and add keyframes to each one    
    for i,v in enumerate(mesh.vertices):
        x,y,_ = v.co
        z = np.sin(x+y-t)
        v.co = (x,y,z)
        v.keyframe_insert(data_path="co", index=-1)   


Edit: Curiously this code works in Blender 2.79, but not in 2.80! Is this a bug, or intended?
Handler workaround.

Personally would  lean towards using shape-keys for this. 

Not sure why the animated mesh doesn't update, hopefully someone will answer with a required setting, or it is an oversight in deps graph and may change up in future.

As a work-around, calling mesh.update() on a frame change via a handler gives the desired result

import bpy

def animate_meshes(scene):
    meshes = set(o.data for o in scene.objects if o.type == 'MESH')
    for m in meshes:
        m.update()

bpy.app.handlers.frame_change_post.append(animate_meshes)


clear all frame_change post handlers with

bpy.app.handlers.frame_change_post.clear()