Unable to access trained model from one python function into another and downloading the entire model

Sure. In that case, you can define model as a global variable.

Example: https://www.geeksforgeeks.org/global-keyword-in-python/

Something like this:

m = None

@anvil.server.callable
def work(path, file):
    global m  # in this function, m will refer to the above m
    if m is None:
        m = task2(path)
    # code that uses m...

This limits you to one user, and one model at a time. That model will be the one and only model in this code, at any one time. It will live while the notebook is running. As long as those limits work for you, this should be fine.

1 Like