Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to assert that deephaven_server.Server is started before importing deephaven #2853

Closed
chipkent opened this issue Sep 14, 2022 · 2 comments · Fixed by #2872
Closed

Need to assert that deephaven_server.Server is started before importing deephaven #2853

chipkent opened this issue Sep 14, 2022 · 2 comments · Fixed by #2872
Assignees
Labels
bug Something isn't working python triage
Milestone

Comments

@chipkent
Copy link
Member

When using Deephaven as a Python library, the deephaven module can only be safely imported after the deephaven_server.Server has been started. A check needs to be added to deephaven/__init__.py to ensure the server has been started.

The bug was introduced in v0.16. In versions before v0.16, the server needed to be created (to create the JVM), but the server did not need to be started. Changes related to Python variable scoping in the query language introduced the new requirement that the server be started.

@chipkent chipkent added bug Something isn't working triage python labels Sep 14, 2022
@chipkent chipkent added this to the Sept 2022 milestone Sep 14, 2022
@devinrsmith
Copy link
Member

Here is the new error:

>>> import deephaven_server
>>> server = deephaven_server.Server()
# Starting io.deephaven.python.server.EmbeddedServer
# Bootstrapping from resource '/bootstrap.properties'
# io.deephaven.internal.log.LoggerFactoryServiceLoaderImpl: searching for 'io.deephaven.internal.log.LoggerFactory'...
# io.deephaven.internal.log.LoggerFactoryServiceLoaderImpl: found 'io.deephaven.internal.log.LoggerFactorySlf4j'
>>> import deephaven
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/devin/.venvs/deephaven-server-0-16-1/lib64/python3.10/site-packages/deephaven/__init__.py", line 19, in <module>
    from .table import SortDirection, AsOfMatchRule
  File "/home/devin/.venvs/deephaven-server-0-16-1/lib64/python3.10/site-packages/deephaven/table.py", line 54, in <module>
    _j_script_session = jpy.cast(_JExecutionContext.getContext().getQueryScope(), _JUnsynchronizedScriptSessionQueryScope).scriptSession()
AttributeError: 'NoneType' object has no attribute 'scriptSession'
>>> server.start()
Server started on port 10000
>>> import deephaven
>>> 

@devinrsmith
Copy link
Member

I think ultimately, this is due to the introduction of java execution at python module initialization time, something we haven't done before (up until now, we have mainly just used jpy.get_type, or accessing constant values). I've got a fix I'll get up for review soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants