anakin87 / who-killed-laura-palmer

Simple Question Answering system, based on data crawled from Twin Peaks Wiki. It is built using 🔍 Haystack, an awesome open-source framework for building search systems that work intelligently over large document collections.
Apache License 2.0
11 stars 0 forks source link

Errors on Python 3.9 #1

Open yoeldk opened 1 year ago

yoeldk commented 1 year ago

Hello,

I followed your installation instructions using Python 3.9.6 but unfortunately I keep getting errors after running the Streamlit app.

Should I use a different Python version?

anakin87 commented 1 year ago

Hello @yoeldk!

What types of error? Can you share the stacktrace?

yoeldk commented 1 year ago

Thanks for your reply. Please see attached. It's very long, not sure I captured it all but I think the log output repeats itself continuously.

On Thu, Nov 10, 2022 at 11:34 AM Stefano Fiorucci @.***> wrote:

Hello @yoeldk https://github.com/yoeldk!

What types of error? Can you share the stacktrace?

— Reply to this email directly, view it on GitHub https://github.com/anakin87/who-killed-laura-palmer/issues/1#issuecomment-1310008807, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7NSOZ25FOCYK6C7MC6TGDWHS6RDANCNFSM6AAAAAAR4K66S4 . You are receiving this because you were mentioned.Message ID: @.***>


If you don't know where the object of type `builtins.function` is coming
from, try looking at the hash chain below for an object that you do recognize,
then pass that to `hash_funcs` instead:

Object of type builtins.function: <function start_haystack at 0x00000230CD078E50>


Please see the `hash_funcs` [documentation]
(https://docs.streamlit.io/library/advanced-features/caching#the-hash_funcs-parameter)
for more details.

Traceback (most recent call last):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
AttributeError: module '__main__' has no attribute '__file__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
2022-11-10 14:34:23.839
  Warning: to view a Streamlit app on a browser, use Streamlit in a file and
  run it with the following command:

    streamlit run [FILE_NAME] [ARGUMENTS]
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\app.py", line 12, in <module>
    from app_utils.backend_utils import load_questions, query
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\.\app_utils\backend_utils.py", line 37, in <module>
    pipe = start_haystack()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 623, in wrapped_func
    return get_or_create_cached_value()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 548, in get_or_create_cached_value
    cache_key = _hash_func(non_optional_func, hash_funcs)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 674, in _hash_func
    update_hash(
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 109, in update_hash
    ch.update(hasher, val, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 386, in update
    b = self.to_bytes(obj, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 375, in to_bytes
    raise InternalHashError(e, obj)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
streamlit.runtime.legacy_caching.hashing.InternalHashError: module '__main__' has no attribute '__file__'

While caching the body of `start_haystack()`, Streamlit encountered an
object of type `builtins.function`, which it does not know how to hash.

**In this specific case, it's very likely you found a Streamlit bug so please
[file a bug report here.]
(https://github.com/streamlit/streamlit/issues/new/choose)**

In the meantime, you can try bypassing this error by registering a custom
hash function via the `hash_funcs` keyword in @st.cache(). For example:

@st.cache(hash_funcs={builtins.function: my_hash_func}) def my_func(...): ...


If you don't know where the object of type `builtins.function` is coming
from, try looking at the hash chain below for an object that you do recognize,
then pass that to `hash_funcs` instead:

Object of type builtins.function: <function start_haystack at 0x0000026CEBCF8E50>


Please see the `hash_funcs` [documentation]
(https://docs.streamlit.io/library/advanced-features/caching#the-hash_funcs-parameter)
for more details.

2022-11-10 14:34:24.189
  Warning: to view a Streamlit app on a browser, use Streamlit in a file and
  run it with the following command:

    streamlit run [FILE_NAME] [ARGUMENTS]
Traceback (most recent call last):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
AttributeError: module '__main__' has no attribute '__file__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 268, in run_path
Traceback (most recent call last):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    return _run_module_code(code, init_globals, run_name,
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 97, in _run_module_code
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
AttributeError: module '__main__' has no attribute '__file__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 125, in _main
Traceback (most recent call last):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    prepare(preparation_data)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    if self._file_should_be_hashed(code.co_filename):
    main_content = runpy.run_path(main_path,
    _run_code(code, mod_globals, init_globals,
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 268, in run_path
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    filepath, self._get_main_script_directory()
    return _run_module_code(code, init_globals, run_name,
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 97, in _run_module_code
    exec(code, run_globals)
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\app.py", line 12, in <module>
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
    _run_code(code, mod_globals, init_globals,
AttributeError: module '__main__' has no attribute '__file__'
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code

During handling of the above exception, another exception occurred:

    from app_utils.backend_utils import load_questions, query
    exec(code, run_globals)
Traceback (most recent call last):
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\.\app_utils\backend_utils.py", line 37, in <module>
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\app.py", line 12, in <module>
  File "<string>", line 1, in <module>
    pipe = start_haystack()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 623, in wrapped_func
    from app_utils.backend_utils import load_questions, query
    return get_or_create_cached_value()
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\.\app_utils\backend_utils.py", line 37, in <module>
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 548, in get_or_create_cached_value
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
    pipe = start_haystack()
    cache_key = _hash_func(non_optional_func, hash_funcs)
    exitcode = _main(fd, parent_sentinel)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 623, in wrapped_func
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 674, in _hash_func
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 125, in _main
    update_hash(
    return get_or_create_cached_value()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 109, in update_hash
    prepare(preparation_data)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 548, in get_or_create_cached_value
    ch.update(hasher, val, context)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 386, in update
    cache_key = _hash_func(non_optional_func, hash_funcs)
    _fixup_main_from_path(data['init_main_from_path'])
    b = self.to_bytes(obj, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 674, in _hash_func
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 375, in to_bytes
    main_content = runpy.run_path(main_path,
    update_hash(
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 268, in run_path
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 109, in update_hash
    raise InternalHashError(e, obj)
    ch.update(hasher, val, context)
    return _run_module_code(code, init_globals, run_name,
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 386, in update
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    b = self.to_bytes(obj, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 375, in to_bytes
    exec(code, run_globals)
    if self._file_should_be_hashed(code.co_filename):
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\app.py", line 12, in <module>
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    raise InternalHashError(e, obj)
    from app_utils.backend_utils import load_questions, query
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\.\app_utils\backend_utils.py", line 37, in <module>
    filepath, self._get_main_script_directory()
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
    pipe = start_haystack()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 623, in wrapped_func
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
    if self._file_should_be_hashed(code.co_filename):
streamlit.runtime.legacy_caching.hashing.InternalHashError: module '__main__' has no attribute '__file__'

While caching the body of `start_haystack()`, Streamlit encountered an
object of type `builtins.function`, which it does not know how to hash.

**In this specific case, it's very likely you found a Streamlit bug so please
[file a bug report here.]
(https://github.com/streamlit/streamlit/issues/new/choose)**

In the meantime, you can try bypassing this error by registering a custom
hash function via the `hash_funcs` keyword in @st.cache(). For example:

@st.cache(hash_funcs={builtins.function: my_hash_func}) def my_func(...): ...


If you don't know where the object of type `builtins.function` is coming
from, try looking at the hash chain below for an object that you do recognize,
then pass that to `hash_funcs` instead:

Object of type builtins.function: <function start_haystack at 0x00000202CEF18E50>


Please see the `hash_funcs` [documentation]
(https://docs.streamlit.io/library/advanced-features/caching#the-hash_funcs-parameter)
for more details.
              File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed

    return get_or_create_cached_value()
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 548, in get_or_create_cached_value
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    cache_key = _hash_func(non_optional_func, hash_funcs)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 674, in _hash_func
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
    update_hash(
streamlit.runtime.legacy_caching.hashing.InternalHashError: module '__main__' has no attribute '__file__'

While caching the body of `start_haystack()`, Streamlit encountered an
object of type `builtins.function`, which it does not know how to hash.

**In this specific case, it's very likely you found a Streamlit bug so please
[file a bug report here.]
(https://github.com/streamlit/streamlit/issues/new/choose)**

In the meantime, you can try bypassing this error by registering a custom
hash function via the `hash_funcs` keyword in @st.cache(). For example:

@st.cache(hash_funcs={builtins.function: my_hash_func}) def my_func(...): ...


If you don't know where the object of type `builtins.function` is coming
from, try looking at the hash chain below for an object that you do recognize,
then pass that to `hash_funcs` instead:

Object of type builtins.function: <function start_haystack at 0x000002B9EE668E50>


Please see the `hash_funcs` [documentation]
(https://docs.streamlit.io/library/advanced-features/caching#the-hash_funcs-parameter)
for more details.
              File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 109, in update_hash

    ch.update(hasher, val, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 386, in update
    b = self.to_bytes(obj, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 375, in to_bytes
    raise InternalHashError(e, obj)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
streamlit.runtime.legacy_caching.hashing.InternalHashError: module '__main__' has no attribute '__file__'

While caching the body of `start_haystack()`, Streamlit encountered an
object of type `builtins.function`, which it does not know how to hash.

**In this specific case, it's very likely you found a Streamlit bug so please
[file a bug report here.]
(https://github.com/streamlit/streamlit/issues/new/choose)**

In the meantime, you can try bypassing this error by registering a custom
hash function via the `hash_funcs` keyword in @st.cache(). For example:

@st.cache(hash_funcs={builtins.function: my_hash_func}) def my_func(...): ...


If you don't know where the object of type `builtins.function` is coming
from, try looking at the hash chain below for an object that you do recognize,
then pass that to `hash_funcs` instead:

Object of type builtins.function: <function start_haystack at 0x0000021442138E50>


Please see the `hash_funcs` [documentation]
(https://docs.streamlit.io/library/advanced-features/caching#the-hash_funcs-parameter)
for more details.

2022-11-10 14:34:27.050
  Warning: to view a Streamlit app on a browser, use Streamlit in a file and
  run it with the following command:

    streamlit run [FILE_NAME] [ARGUMENTS]
Traceback (most recent call last):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
AttributeError: module '__main__' has no attribute '__file__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\app.py", line 12, in <module>
    from app_utils.backend_utils import load_questions, query
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\.\app_utils\backend_utils.py", line 37, in <module>
    pipe = start_haystack()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 623, in wrapped_func
    return get_or_create_cached_value()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 548, in get_or_create_cached_value
    cache_key = _hash_func(non_optional_func, hash_funcs)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 674, in _hash_func
    update_hash(
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 109, in update_hash
    ch.update(hasher, val, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 386, in update
    b = self.to_bytes(obj, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 375, in to_bytes
    raise InternalHashError(e, obj)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
streamlit.runtime.legacy_caching.hashing.InternalHashError: module '__main__' has no attribute '__file__'

While caching the body of `start_haystack()`, Streamlit encountered an
object of type `builtins.function`, which it does not know how to hash.

**In this specific case, it's very likely you found a Streamlit bug so please
[file a bug report here.]
(https://github.com/streamlit/streamlit/issues/new/choose)**

In the meantime, you can try bypassing this error by registering a custom
hash function via the `hash_funcs` keyword in @st.cache(). For example:

@st.cache(hash_funcs={builtins.function: my_hash_func}) def my_func(...): ...


If you don't know where the object of type `builtins.function` is coming
from, try looking at the hash chain below for an object that you do recognize,
then pass that to `hash_funcs` instead:

Object of type builtins.function: <function start_haystack at 0x000002C87D558E50>


Please see the `hash_funcs` [documentation]
(https://docs.streamlit.io/library/advanced-features/caching#the-hash_funcs-parameter)
for more details.

2022-11-10 14:34:49.150 INFO    haystack.document_stores.base: Numba not found, replacing njit() with no-op implementation. Enable it with 'pip install numba'.
2022-11-10 14:34:49.818 INFO    haystack.document_stores.base: Numba not found, replacing njit() with no-op implementation. Enable it with 'pip install numba'.
2022-11-10 14:34:49.885 INFO    haystack.document_stores.base: Numba not found, replacing njit() with no-op implementation. Enable it with 'pip install numba'.
2022-11-10 14:34:49.960 INFO    haystack.document_stores.base: Numba not found, replacing njit() with no-op implementation. Enable it with 'pip install numba'.
2022-11-10 14:34:50.373 INFO    faiss.loader: Loading faiss with AVX2 support.
2022-11-10 14:34:50.412 INFO    faiss.loader: Could not load library with AVX2 support due to:
ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'")
2022-11-10 14:34:50.423 INFO    faiss.loader: Loading faiss.
2022-11-10 14:34:50.507 INFO    faiss.loader: Successfully loaded faiss.
2022-11-10 14:34:50.920 INFO    haystack.document_stores.base: Numba not found, replacing njit() with no-op implementation. Enable it with 'pip install numba'.
2022-11-10 14:34:51.053 INFO    faiss.loader: Loading faiss with AVX2 support.
2022-11-10 14:34:51.064 INFO    faiss.loader: Could not load library with AVX2 support due to:
ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'")
2022-11-10 14:34:51.081 INFO    faiss.loader: Loading faiss.
2022-11-10 14:34:51.151 INFO    faiss.loader: Successfully loaded faiss.
2022-11-10 14:34:51.227 INFO    faiss.loader: Loading faiss with AVX2 support.
2022-11-10 14:34:51.231 INFO    faiss.loader: Could not load library with AVX2 support due to:
ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'")
2022-11-10 14:34:51.235 INFO    faiss.loader: Loading faiss.
2022-11-10 14:34:51.275 INFO    faiss.loader: Loading faiss with AVX2 support.
2022-11-10 14:34:51.288 INFO    faiss.loader: Could not load library with AVX2 support due to:
ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'")
2022-11-10 14:34:51.290 INFO    faiss.loader: Loading faiss.
2022-11-10 14:34:51.304 INFO    faiss.loader: Successfully loaded faiss.
2022-11-10 14:34:51.360 INFO    faiss.loader: Successfully loaded faiss.
2022-11-10 14:34:52.411 INFO    faiss.loader: Loading faiss with AVX2 support.
2022-11-10 14:34:52.416 INFO    faiss.loader: Could not load library with AVX2 support due to:
ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'")
2022-11-10 14:34:52.420 INFO    faiss.loader: Loading faiss.
2022-11-10 14:34:52.530 INFO    faiss.loader: Successfully loaded faiss.
2022-11-10 14:34:54.465 INFO    haystack.modeling.model.optimization: apex not found, won't use it. See https://nvidia.github.io/apex/
2022-11-10 14:34:54.930 ERROR   root: Failed to import 'magic' (from 'python-magic' and 'python-magic-bin' on Windows). FileTypeClassifier will not perform mimetype detection on extensionless files. Please make sure the necessary OS libraries are installed if you need this functionality.
2022-11-10 14:34:55.273 INFO    haystack.modeling.model.optimization: apex not found, won't use it. See https://nvidia.github.io/apex/
2022-11-10 14:34:55.408 INFO    haystack.modeling.model.optimization: apex not found, won't use it. See https://nvidia.github.io/apex/
2022-11-10 14:34:55.435 INFO    haystack.document_stores.base: Numba not found, replacing njit() with no-op implementation. Enable it with 'pip install numba'.
2022-11-10 14:34:55.780 ERROR   root: Failed to import 'magic' (from 'python-magic' and 'python-magic-bin' on Windows). FileTypeClassifier will not perform mimetype detection on extensionless files. Please make sure the necessary OS libraries are installed if you need this functionality.
2022-11-10 14:34:55.897 ERROR   root: Failed to import 'magic' (from 'python-magic' and 'python-magic-bin' on Windows). FileTypeClassifier will not perform mimetype detection on extensionless files. Please make sure the necessary OS libraries are installed if you need this functionality.
2022-11-10 14:34:56.340 INFO    haystack.modeling.model.optimization: apex not found, won't use it. See https://nvidia.github.io/apex/
2022-11-10 14:34:56.857 INFO    haystack.modeling.model.optimization: apex not found, won't use it. See https://nvidia.github.io/apex/
2022-11-10 14:34:57.049 INFO    faiss.loader: Loading faiss with AVX2 support.
2022-11-10 14:34:57.052 INFO    faiss.loader: Could not load library with AVX2 support due to:
ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'")
2022-11-10 14:34:57.057 INFO    faiss.loader: Loading faiss.
2022-11-10 14:34:57.151 INFO    faiss.loader: Successfully loaded faiss.
2022-11-10 14:34:57.161 ERROR   root: Failed to import 'magic' (from 'python-magic' and 'python-magic-bin' on Windows). FileTypeClassifier will not perform mimetype detection on extensionless files. Please make sure the necessary OS libraries are installed if you need this functionality.
2022-11-10 14:34:57.343 ERROR   root: Failed to import 'magic' (from 'python-magic' and 'python-magic-bin' on Windows). FileTypeClassifier will not perform mimetype detection on extensionless files. Please make sure the necessary OS libraries are installed if you need this functionality.
2022-11-10 14:34:58.569 INFO    haystack.document_stores.base: Numba not found, replacing njit() with no-op implementation. Enable it with 'pip install numba'.
2022-11-10 14:34:59.774 INFO    faiss.loader: Loading faiss with AVX2 support.
2022-11-10 14:34:59.777 INFO    faiss.loader: Could not load library with AVX2 support due to:
ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'")
2022-11-10 14:34:59.778 INFO    faiss.loader: Loading faiss.
2022-11-10 14:34:59.888 INFO    faiss.loader: Successfully loaded faiss.
2022-11-10 14:35:00.685 INFO    haystack.modeling.model.optimization: apex not found, won't use it. See https://nvidia.github.io/apex/
2022-11-10 14:35:01.097 ERROR   root: Failed to import 'magic' (from 'python-magic' and 'python-magic-bin' on Windows). FileTypeClassifier will not perform mimetype detection on extensionless files. Please make sure the necessary OS libraries are installed if you need this functionality.
2022-11-10 14:35:03.136 INFO    haystack.modeling.model.optimization: apex not found, won't use it. See https://nvidia.github.io/apex/
2022-11-10 14:35:03.552 ERROR   root: Failed to import 'magic' (from 'python-magic' and 'python-magic-bin' on Windows). FileTypeClassifier will not perform mimetype detection on extensionless files. Please make sure the necessary OS libraries are installed if you need this functionality.
2022-11-10 14:35:03.602
  Warning: to view a Streamlit app on a browser, use Streamlit in a file and
  run it with the following command:

    streamlit run [FILE_NAME] [ARGUMENTS]
2022-11-10 14:35:04.967
  Warning: to view a Streamlit app on a browser, use Streamlit in a file and
  run it with the following command:

    streamlit run [FILE_NAME] [ARGUMENTS]
Traceback (most recent call last):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
2022-11-10 14:35:05.046
  Warning: to view a Streamlit app on a browser, use Streamlit in a file and
  run it with the following command:

    streamlit run [FILE_NAME] [ARGUMENTS]
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
AttributeError: module '__main__' has no attribute '__file__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\app.py", line 12, in <module>
    from app_utils.backend_utils import load_questions, query
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\.\app_utils\backend_utils.py", line 37, in <module>
    pipe = start_haystack()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 623, in wrapped_func
    return get_or_create_cached_value()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 548, in get_or_create_cached_value
    cache_key = _hash_func(non_optional_func, hash_funcs)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 674, in _hash_func
    update_hash(
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 109, in update_hash
    ch.update(hasher, val, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 386, in update
    b = self.to_bytes(obj, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 375, in to_bytes
    raise InternalHashError(e, obj)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
streamlit.runtime.legacy_caching.hashing.InternalHashError: module '__main__' has no attribute '__file__'

While caching the body of `start_haystack()`, Streamlit encountered an
object of type `builtins.function`, which it does not know how to hash.

**In this specific case, it's very likely you found a Streamlit bug so please
[file a bug report here.]
(https://github.com/streamlit/streamlit/issues/new/choose)**

In the meantime, you can try bypassing this error by registering a custom
hash function via the `hash_funcs` keyword in @st.cache(). For example:

@st.cache(hash_funcs={builtins.function: my_hash_func}) def my_func(...): ...


If you don't know where the object of type `builtins.function` is coming
from, try looking at the hash chain below for an object that you do recognize,
then pass that to `hash_funcs` instead:

Object of type builtins.function: <function start_haystack at 0x000001EEC8405E50>


Please see the `hash_funcs` [documentation]
(https://docs.streamlit.io/library/advanced-features/caching#the-hash_funcs-parameter)
for more details.

Traceback (most recent call last):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
AttributeError: module '__main__' has no attribute '__file__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
Traceback (most recent call last):
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    exec(code, run_globals)
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\app.py", line 12, in <module>
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    from app_utils.backend_utils import load_questions, query
    if self._file_should_be_hashed(code.co_filename):
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\.\app_utils\backend_utils.py", line 37, in <module>
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    pipe = start_haystack()
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 623, in wrapped_func
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    return get_or_create_cached_value()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 548, in get_or_create_cached_value
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
AttributeError: module '__main__' has no attribute '__file__'
    cache_key = _hash_func(non_optional_func, hash_funcs)

During handling of the above exception, another exception occurred:

  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 674, in _hash_func
Traceback (most recent call last):
    update_hash(
  File "<string>", line 1, in <module>
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 109, in update_hash
    ch.update(hasher, val, context)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 386, in update
    exitcode = _main(fd, parent_sentinel)
    b = self.to_bytes(obj, context)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 125, in _main
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 375, in to_bytes
    prepare(preparation_data)
    raise InternalHashError(e, obj)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    _fixup_main_from_path(data['init_main_from_path'])
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    main_content = runpy.run_path(main_path,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 268, in run_path
    if self._file_should_be_hashed(code.co_filename):
    return _run_module_code(code, init_globals, run_name,
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 97, in _run_module_code
    filepath, self._get_main_script_directory()
    _run_code(code, mod_globals, init_globals,
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
streamlit.runtime.legacy_caching.hashing.InternalHashError: module '__main__' has no attribute '__file__'

While caching the body of `start_haystack()`, Streamlit encountered an
object of type `builtins.function`, which it does not know how to hash.

**In this specific case, it's very likely you found a Streamlit bug so please
[file a bug report here.]
(https://github.com/streamlit/streamlit/issues/new/choose)**

In the meantime, you can try bypassing this error by registering a custom
hash function via the `hash_funcs` keyword in @st.cache(). For example:

@st.cache(hash_funcs={builtins.function: my_hash_func}) def my_func(...): ...


If you don't know where the object of type `builtins.function` is coming
from, try looking at the hash chain below for an object that you do recognize,
then pass that to `hash_funcs` instead:

Object of type builtins.function: <function start_haystack at 0x0000028E7B6B5E50>


Please see the `hash_funcs` [documentation]
(https://docs.streamlit.io/library/advanced-features/caching#the-hash_funcs-parameter)
for more details.
                exec(code, run_globals)

  File "C:\GitHub\Streamlit\who-killed-laura-palmer\app.py", line 12, in <module>
    from app_utils.backend_utils import load_questions, query
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\.\app_utils\backend_utils.py", line 37, in <module>
    pipe = start_haystack()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 623, in wrapped_func
    return get_or_create_cached_value()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 548, in get_or_create_cached_value
    cache_key = _hash_func(non_optional_func, hash_funcs)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 674, in _hash_func
    update_hash(
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 109, in update_hash
    ch.update(hasher, val, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 386, in update
    b = self.to_bytes(obj, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 375, in to_bytes
    raise InternalHashError(e, obj)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
2022-11-10 14:35:05.655
  Warning: to view a Streamlit app on a browser, use Streamlit in a file and
  run it with the following command:

    streamlit run [FILE_NAME] [ARGUMENTS]
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
streamlit.runtime.legacy_caching.hashing.InternalHashError: module '__main__' has no attribute '__file__'

While caching the body of `start_haystack()`, Streamlit encountered an
object of type `builtins.function`, which it does not know how to hash.

**In this specific case, it's very likely you found a Streamlit bug so please
[file a bug report here.]
(https://github.com/streamlit/streamlit/issues/new/choose)**

In the meantime, you can try bypassing this error by registering a custom
hash function via the `hash_funcs` keyword in @st.cache(). For example:

@st.cache(hash_funcs={builtins.function: my_hash_func}) def my_func(...): ...


If you don't know where the object of type `builtins.function` is coming
from, try looking at the hash chain below for an object that you do recognize,
then pass that to `hash_funcs` instead:

Object of type builtins.function: <function start_haystack at 0x0000012DFD465E50>


Please see the `hash_funcs` [documentation]
(https://docs.streamlit.io/library/advanced-features/caching#the-hash_funcs-parameter)
for more details.

2022-11-10 14:35:06.143
  Warning: to view a Streamlit app on a browser, use Streamlit in a file and
  run it with the following command:

    streamlit run [FILE_NAME] [ARGUMENTS]
Traceback (most recent call last):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
AttributeError: module '__main__' has no attribute '__file__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\app.py", line 12, in <module>
    from app_utils.backend_utils import load_questions, query
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\.\app_utils\backend_utils.py", line 37, in <module>
    pipe = start_haystack()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 623, in wrapped_func
    return get_or_create_cached_value()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 548, in get_or_create_cached_value
    cache_key = _hash_func(non_optional_func, hash_funcs)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 674, in _hash_func
    update_hash(
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 109, in update_hash
    ch.update(hasher, val, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 386, in update
    b = self.to_bytes(obj, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 375, in to_bytes
    raise InternalHashError(e, obj)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
streamlit.runtime.legacy_caching.hashing.InternalHashError: module '__main__' has no attribute '__file__'

While caching the body of `start_haystack()`, Streamlit encountered an
object of type `builtins.function`, which it does not know how to hash.

**In this specific case, it's very likely you found a Streamlit bug so please
[file a bug report here.]
(https://github.com/streamlit/streamlit/issues/new/choose)**

In the meantime, you can try bypassing this error by registering a custom
hash function via the `hash_funcs` keyword in @st.cache(). For example:

@st.cache(hash_funcs={builtins.function: my_hash_func}) def my_func(...): ...


If you don't know where the object of type `builtins.function` is coming
from, try looking at the hash chain below for an object that you do recognize,
then pass that to `hash_funcs` instead:

Object of type builtins.function: <function start_haystack at 0x0000022B01155E50>


Please see the `hash_funcs` [documentation]
(https://docs.streamlit.io/library/advanced-features/caching#the-hash_funcs-parameter)
for more details.

Traceback (most recent call last):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
AttributeError: module '__main__' has no attribute '__file__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Users\ykrupnik\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\app.py", line 12, in <module>
    from app_utils.backend_utils import load_questions, query
  File "C:\GitHub\Streamlit\who-killed-laura-palmer\.\app_utils\backend_utils.py", line 37, in <module>
    pipe = start_haystack()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 623, in wrapped_func
    return get_or_create_cached_value()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 548, in get_or_create_cached_value
    cache_key = _hash_func(non_optional_func, hash_funcs)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\caching.py", line 674, in _hash_func
    update_hash(
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 109, in update_hash
    ch.update(hasher, val, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 386, in update
    b = self.to_bytes(obj, context)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 375, in to_bytes
    raise InternalHashError(e, obj)
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_script_directory()
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 715, in _get_main_script_directory
    abs_main_path = pathlib.Path(__main__.__file__).resolve()
streamlit.runtime.legacy_caching.hashing.InternalHashError: module '__main__' has no attribute '__file__'

While caching the body of `start_haystack()`, Streamlit encountered an
object of type `builtins.function`, which it does not know how to hash.

**In this specific case, it's very likely you found a Streamlit bug so please
[file a bug report here.]
(https://github.com/streamlit/streamlit/issues/new/choose)**

In the meantime, you can try bypassing this error by registering a custom
hash function via the `hash_funcs` keyword in @st.cache(). For example:

@st.cache(hash_funcs={builtins.function: my_hash_func}) def my_func(...): ...


If you don't know where the object of type `builtins.function` is coming
from, try looking at the hash chain below for an object that you do recognize,
then pass that to `hash_funcs` instead:

Object of type builtins.function: <function start_haystack at 0x000001D97BD85E50>



Please see the `hash_funcs` [documentation]
(https://docs.streamlit.io/library/advanced-features/caching#the-hash_funcs-parameter)
for more details.

2022-11-10 14:35:09.083
  Warning: to view a Streamlit app on a browser, use Streamlit in a file and
  run it with the following command:

    streamlit run [FILE_NAME] [ARGUMENTS]
Traceback (most recent call last):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 361, in to_bytes
    b = b"%s:%s" % (tname, self._to_bytes(obj, context))
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 627, in _to_bytes
    if self._file_should_be_hashed(code.co_filename):
  File "c:\github\streamlit\who-killed-laura-palmer\env\lib\site-packages\streamlit\runtime\legacy_caching\hashing.py", line 403, in _file_should_be_hashed
    filepath, self._get_main_s
anakin87 commented 1 year ago

Can be related to using Windows as operating system. I only tested the webapp using Linux. When I have some time, I'll try to reproduce this issue.

yoeldk commented 1 year ago

That would be great, thanks a lot!

On Thu, Nov 10, 2022 at 2:48 PM Stefano Fiorucci @.***> wrote:

Can be related to using Windows as operating system. I only tested the webapp using Linux. When I have some time, I'll try to reproduce this issue.

— Reply to this email directly, view it on GitHub https://github.com/anakin87/who-killed-laura-palmer/issues/1#issuecomment-1310231360, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7NSO6MIFOFGKX5LQ5NIS3WHTVKRANCNFSM6AAAAAAR4K66S4 . You are receiving this because you were mentioned.Message ID: @.***>

anakin87 commented 1 year ago

I can confirm this bug in Windows.

For the moment, you can try to comment these lines: https://github.com/anakin87/who-killed-laura-palmer/blob/87009f74f22895e84e65b27c0fb1b42b631a60f5/app_utils/backend_utils.py#L12-L13

They are necessary for caching the pipeline, but you can safely skip this part.

yoeldk commented 1 year ago

Thanks Stefano :)

On Thu, Nov 10, 2022 at 4:42 PM Stefano Fiorucci @.***> wrote:

I can confirm this bug in Windows.

For the moment, you can try to comment these lines:

https://github.com/anakin87/who-killed-laura-palmer/blob/87009f74f22895e84e65b27c0fb1b42b631a60f5/app_utils/backend_utils.py#L12-L13

They are necessary for caching the pipeline, but you can safely skip this part.

— Reply to this email directly, view it on GitHub https://github.com/anakin87/who-killed-laura-palmer/issues/1#issuecomment-1310394993, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7NSOYJTSRHRIR7UFFS7P3WHUCT3ANCNFSM6AAAAAAR4K66S4 . You are receiving this because you were mentioned.Message ID: @.***>

yoeldk commented 1 year ago

Hi Stefano,

I actually started the installation from scratch and it worked without commenting out lines (had to install a newer version of torch though). What would you say be the easiest way to re-use your code but with different text source? (Assuming I have downloaded texts from another source that I want to ask questions on).

Thanks, Yoel

On Sun, Nov 13, 2022 at 2:30 PM Yoel K @.***> wrote:

Thanks Stefano :)

On Thu, Nov 10, 2022 at 4:42 PM Stefano Fiorucci @.***> wrote:

I can confirm this bug in Windows.

For the moment, you can try to comment these lines:

https://github.com/anakin87/who-killed-laura-palmer/blob/87009f74f22895e84e65b27c0fb1b42b631a60f5/app_utils/backend_utils.py#L12-L13

They are necessary for caching the pipeline, but you can safely skip this part.

— Reply to this email directly, view it on GitHub https://github.com/anakin87/who-killed-laura-palmer/issues/1#issuecomment-1310394993, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7NSOYJTSRHRIR7UFFS7P3WHUCT3ANCNFSM6AAAAAAR4K66S4 . You are receiving this because you were mentioned.Message ID: @.***>

anakin87 commented 1 year ago

This project is only meant to showcase some Haystack features applied to a nice new domain.

  1. In any case, I think you can try to run/adapt this notebook to your data: https://github.com/anakin87/who-killed-laura-palmer/blob/main/notebooks/indexing_and_pipeline_creation.ipynb

  2. The output of the notebook is a FAISS index that you can put in the directory data/index in place of the existing one (based on my data).