This package is deceptively simple, seeming to show that a single source file can contain the implementation to talk to Deephaven and the browser client, as long as the if DEV_MODE: block at the end contains your own source. However, if a user runs streamlit on this code with dev mode enabled, and tries to use streamlit's own re-run code, the __main__ import will run again to ingest changes, and any newly created objects will not be available to DH clients (including the browser).
Two simple proposed fixes:
remove the DEV_MODE block from __init__.py, and provide an alternative file to run tests from (perhaps one outside of the package)
migrate the bulk of __init__.py into another file that __init__.py can import from, and thus export only specific members to downstream consumers, as well as ensuring that the DEV_MODE block can change and the entire file can be re-evaluated without side unexpected side effects. Could also consider the use of __all__ to isolate which members are available for import.
This package is deceptively simple, seeming to show that a single source file can contain the implementation to talk to Deephaven and the browser client, as long as the
if DEV_MODE:
block at the end contains your own source. However, if a user runs streamlit on this code with dev mode enabled, and tries to use streamlit's own re-run code, the__main__
import will run again to ingest changes, and any newly created objects will not be available to DH clients (including the browser).Two simple proposed fixes:
__init__.py
, and provide an alternative file to run tests from (perhaps one outside of the package)__init__.py
into another file that__init__.py
can import from, and thus export only specific members to downstream consumers, as well as ensuring that the DEV_MODE block can change and the entire file can be re-evaluated without side unexpected side effects. Could also consider the use of__all__
to isolate which members are available for import.