Model not saving

Well something strange is definitely happening.

I would add a bunch more print statements to help you debug this. The only way that code path can be taken is if m is None. So when it gets called from the client it is None otherwise the else statements would never execute.

Are you checking the value of m by running that cell from jupyter or from the client code button click? If it’s the former then check the print statements when running the code from the anvil button click.

Is it possible you have multiple functions registered called download? Maybe you have multiple jupyter notebooks open. Or perhaps when you call that function from anvil you’ve reset the jupyter cells and m has changed.

When you have uplink server code running like this, it’s worth setting it up, then interacting with the server code from your app (exclusively) and check the logs in your jupyter notebook. Since that’s how your users will be working with the server code.

You might also add another server function for sanity, with an extra button in your app to call the function from client code.

### server
@anvil.server.callable
def check_m():
   print('checking m', m) # is m None?


### client code for another button 
def button_2_click(self, **event_args):
    anvil.server.call('check_m')

You may already be doing much of the above. But there is probably something that’s missing between our explanations and how you’re interacting with anvil and the jupyter notebook.


In summary - more print statements and try to exclusively interact with your notebook from the anvil app. (Write the server code, then run server calls from button clicks and check the jupyter notebook for the debug print statements)

Good luck!

You may also want to watch the jupyter notebook tutorial if you haven’t already.

2 Likes