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

Line numbers in errors are not useful #9

Closed
chipkent opened this issue Jun 7, 2024 · 11 comments
Closed

Line numbers in errors are not useful #9

chipkent opened this issue Jun 7, 2024 · 11 comments
Assignees
Labels
bug Something isn't working question Further information is requested wontfix This will not be worked on
Milestone

Comments

@chipkent
Copy link
Member

chipkent commented Jun 7, 2024

UPDATE 08/12:
This PR may fix the root cause in jpy jpy-consortium/jpy/pull/158

UPDATE 07/16: I think #39 Expose python code errors as diagnostics should address the user experience challenge on this one. It won't help with the -1 line numbers which seems likely to be a Python runtime bug (see python/cpython#101400 for an example).

I run this code with a known error on line 11.

from deephaven import empty_table, time_table
from deephaven.plot import Figure

t1 = empty_table(10).update(["X = i", "Y = 10 * i"])
t2 = time_table("PT1s").update(["X = i%10", "Y = 10 * i"])

t3 = t1.natural_join(t2.last_by("X"), on="X", joins="YY=Y")

p1 = Figure().plot_xy("Plot 1", t1, x="X", y="Y").show()
p2 = Figure().plot_xy(t2, "X", "Y").show()

# p1 = Figure().plot_xy("Plot 1", t1, x="X", y="Y").show()
# p2 = Figure().plot_xy("Plot 2", t2, x="X", y="Y").show()


print("DH Rules")
print("DH Sucks")

Here is the error -- no mention of line 11 or even the file name:

14:16:33.055 ERROR r-Scheduler-Serial-1 | .c.ConsoleServiceGrpcImpl | Error running script: java.lang.RuntimeException: Error in Python interpreter:
Type: <class 'deephaven.dherror.DHError'>
Value: Improper input type: name=series_name type=<class 'deephaven.table.Table'> supported=['str'] : Improper input type: name=series_name type=<class 'deephaven.table.Table'> supported=['str']
NoneType: None

Line: 47
Namespace: _assert_type
File: /private/tmp/my-dh-venv/lib/python3.11/site-packages/deephaven/plot/figure.py
Traceback (most recent call last):
  File "<string>", line -1, in <module>
  File "/private/tmp/my-dh-venv/lib/python3.11/site-packages/deephaven/plot/figure.py", line -1, in plot_xy
  File "/private/tmp/my-dh-venv/lib/python3.11/site-packages/deephaven/plot/figure.py", line -1, in _convert_j
  File "/private/tmp/my-dh-venv/lib/python3.11/site-packages/deephaven/plot/figure.py", line -1, in _assert_type

	at org.jpy.PyLib.executeCode(Native Method)
	at org.jpy.PyObject.executeCode(PyObject.java:138)
	at io.deephaven.engine.util.PythonEvaluatorJpy.evalScript(PythonEvaluatorJpy.java:73)
	at io.deephaven.integrations.python.PythonDeephavenSession.lambda$evaluate$1(PythonDeephavenSession.java:205)
	at io.deephaven.util.locks.FunctionalLock.doLockedInterruptibly(FunctionalLock.java:51)
	at io.deephaven.integrations.python.PythonDeephavenSession.evaluate(PythonDeephavenSession.java:205)
	at io.deephaven.engine.util.AbstractScriptSession.lambda$evaluateScript$0(AbstractScriptSession.java:165)
	at io.deephaven.engine.context.ExecutionContext.lambda$apply$0(ExecutionContext.java:196)
	at io.deephaven.engine.context.ExecutionContext.apply(ExecutionContext.java:207)
	at io.deephaven.engine.context.ExecutionContext.apply(ExecutionContext.java:195)
	at io.deephaven.engine.util.AbstractScriptSession.evaluateScript(AbstractScriptSession.java:165)
	at io.deephaven.engine.util.DelegatingScriptSession.evaluateScript(DelegatingScriptSession.java:72)
	at io.deephaven.engine.util.ScriptSession.evaluateScript(ScriptSession.java:75)
	at io.deephaven.server.console.ConsoleServiceGrpcImpl.lambda$executeCommand$4(ConsoleServiceGrpcImpl.java:193)
	at io.deephaven.server.session.SessionState$ExportBuilder.lambda$submit$2(SessionState.java:1537)
	at io.deephaven.server.session.SessionState$ExportObject.doExport(SessionState.java:995)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at io.deephaven.server.runner.scheduler.SchedulerModule$ThreadFactory.lambda$newThread$0(SchedulerModule.java:100)
	at java.base/java.lang.Thread.run(Thread.java:829)
@chipkent chipkent added the bug Something isn't working label Jun 7, 2024
@mofojed mofojed added the triage label Jun 10, 2024
@vbabich vbabich removed the triage label Jun 18, 2024
@vbabich vbabich added this to the June 2024 milestone Jun 18, 2024
@bmingles
Copy link
Collaborator

bmingles commented Jun 25, 2024

Oddly when I run this script, I get the same error with different line numbers.

Running full script:
image

Running selected line 10 p2 = Figure().plot_xy(t2, "X", "Y").show()
image

I'm not sure how to get the -1 line number shown in the ticket description. @chipkent curious if I'm doing something wrong for the reproduction here?

That said, even if the line number is positive, there are 2 issues I see here:

  1. The line number seems to be relative to the number of selected lines as opposed to the file
  2. It just says <string> instead of providing a file name.

I do actually see this same behavior in code studio, so I think this is something that we should create a ticket for there and address there as well. The line number issue is likely something we can address only there and get it for free in the extension. The filename may be more nuanced since vscode file could be something outside of what code studio is aware of and would need special handling.

@bmingles
Copy link
Collaborator

@chipkent there's a possibility the -1 line numbers may be a Python bug fixed in 3.12.

@mofojed mofojed added the question Further information is requested label Jun 27, 2024
@bmingles
Copy link
Collaborator

bmingles commented Jul 2, 2024

I was able to reproduce the -1 line numbers in 3.11.0 per reproduction steps here: python/cpython#101400

@bmingles
Copy link
Collaborator

bmingles commented Jul 8, 2024

I talked to @mofojed about this one.

It seems the -1 line number is a Python bug that has been fixed in later versions. Upgrading to >= 3.12 should fix this.

We also discussed the lack of filename in the error message. This is due to the server being unaware of files at all since we are only passing the file content or selection. The output message File "<string>" is contextual to that content and represents the actual errors Python is processing. I am assuming once the -1 line numbers issue is removed from the equation, the lack of filename is less of an issue since the user should be aware of the file that was run that caused the error message. We are not planning to change anything here at this time.

@bmingles bmingles closed this as completed Jul 8, 2024
@bmingles bmingles added the wontfix This will not be worked on label Jul 16, 2024
@chipkent
Copy link
Member Author

chipkent commented Jul 16, 2024

I am on python 3.12.2 and am still getting -1 line numbers.

image

@chipkent chipkent reopened this Jul 16, 2024
@chipkent
Copy link
Member Author

Actually, looking at that, there is a Line: 20 in there that is correct. The line -1 is in the traceback. Maybe this is ok.

@chipkent
Copy link
Member Author

I'm reopening this. The problem is real.

import sys; print(sys.version)

from deephaven import empty_table, time_table
from deephaven.plot import Figure

t1 = empty_table(10).update(["X = i", "Y = 10 * i"])
t2 = time_table("PT1s").update(["X = i%10", "Y = 10 * i"])

t3 = t1.natural_join(t2.last_by("X"), on="X", joins="YY=Y")

p1 = Figure().plot_xy("Plot 1", t1, x="X", y="Y").show()
p2 = Figure().plot_xy(t2, "X", "Y").show()

# p1 = Figure().plot_xy("Plot 1", t1, x="X", y="Y").show()
# p2 = Figure().plot_xy("Plot 2", t2, x="X", y="Y").show()


print("DH Rules")
print("DH Sucks")

# import mymod
12:16:59.955 ERROR r-Scheduler-Serial-1 | .c.ConsoleServiceGrpcImpl | Error running script: java.lang.RuntimeException: Error in Python interpreter:
Type: <class 'deephaven.dherror.DHError'>
Value: Improper input type: name=series_name type=<class 'deephaven.table.Table'> supported=['str'] : Improper input type: name=series_name type=<class 'deephaven.table.Table'> supported=['str']
NoneType: None

Line: 47
Namespace: _assert_type
File: /private/tmp/my-dh-venv/lib/python3.12/site-packages/deephaven/plot/figure.py
Traceback (most recent call last):
  File "<string>", line -1, in <module>
  File "/private/tmp/my-dh-venv/lib/python3.12/site-packages/deephaven/plot/figure.py", line -1, in plot_xy
  File "/private/tmp/my-dh-venv/lib/python3.12/site-packages/deephaven/plot/figure.py", line -1, in _convert_j
  File "/private/tmp/my-dh-venv/lib/python3.12/site-packages/deephaven/plot/figure.py", line -1, in _assert_type

Note here that the problem is in the creation of p2. a value of the wrong type is passed into plot_xy. The stack trace here is totally unuseful because the original line is noted as File "<string>", line -1, in <module>. The -1 line number does not help the user resolve the location of the problem.

@chipkent
Copy link
Member Author

Note that the above has Line 47 as the problem when it is in fact line 13.

@chipkent chipkent reopened this Jul 16, 2024
@bmingles
Copy link
Collaborator

bmingles commented Jul 16, 2024

It looks like line 47 is referring to where the error gets raised inside of figure.py, so I think that line is as expected.
image

The -1 line numbers are still a bug for the File "<string>" aka. the string content of the script that is being passed to DH.

@chipkent
Copy link
Member Author

I have now done a pip installed DH on python 3.12, and I still see the -1 line numbers.

image

@jmao-denver
Copy link

Fixed by jpy-consortium/jpy#158

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

5 participants