Class object can't be unpickled

First I created class and pickle it in other python script.

class sample(object):
    def input(self):
        pass

s = sample()
pd.to_pickle(s, 'data/s.sav')

Then try to import it in bokeh server, I got error.

class sample(object):
    def input(self):
        pass

a = pd.read_pickle("data/hp.sav")

text = TextInput(title="title", value='test')

curdoc().add_root(text)
curdoc().title = "test"

AttributeError: Can’t get attribute ‘sample’ on <module ‘main’ from ‘C:\Users\Widnows\Anaconda3\Scripts\bokeh.exe\main.py’>

How should I load the pickled class object? I can read other format like dictionary.
Thanks

There is some additional useful information here:

https://www.stefaanlippens.net/python-pickling-and-dealing-with-attributeerror-module-object-has-no-attribute-thing.html

I think in the context of Bokeh you will have to define the pickle class in a separate module file that you import (for both save and load). This is an issue in general with pickle, but even more so in Bokeh app code. Every session that is opened on a Bokeh server runs the code in a completely new module that has a randomized name, that is guaranteed not to match whatever originally ran the save code.

Thanks for reply.

Second solution in your url works.

1.First create script to store class definition.

=> model/sample.py

2.modify __module__in saving.

from model import sample

s = sample()
sample.__module__ = "model.sample"
pd.to_pickle(s, "data/s.sav")

3.import as usual

from model import sample

a = pd.read_pickle("data/s.sav")