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

Handle cell ouput across languages. #13

Open
niconomaa opened this issue May 16, 2019 · 2 comments
Open

Handle cell ouput across languages. #13

niconomaa opened this issue May 16, 2019 · 2 comments
Assignees

Comments

@niconomaa
Copy link
Contributor

Errors are returned inconsistently depending on the language used in the kernel cell.
Consistent and useful error messages are desired.

@niconomaa niconomaa changed the title Error handling and stability. Handle cell ouput across languages. May 27, 2019
@jonashering
Copy link
Contributor

Initial idea was to call language specific String representation methods (such as obj.__repr__() for e.g. python) on foreign objects that ijavascript could not evaluate with default obj.inspect as implemented on feature branch #13. Will revert back to " " + obj as this seems to be cleaner approach.

@JakobEdding
Copy link
Member

JakobEdding commented Jun 24, 2019

In this comment, we try to consolidate observations of different behaviors of output / error handling across languages.

We also compare the output / error handling inside Jupyter Notebook to the behavior when using the Polyglot.eval interface inside a console node --polyglot --jvm session to potentially spot errors which are not caused by our implementation but instead by GraalVM.

Python - stdout - Jupyter Notebook ❌

Output of print() is not shown, NEL internal error because the execution of the last line doesn't yield anything which can be automatically converted and shown as cell output (yields null instead).

image

Python - stdout - Console ✅

Behaves as expected.

> result = Polyglot.eval('python', 'a = 0\nprint(a)\na += 1');
0
null

Python - stderr - Jupyter Notebook ✅

Behaves as expected.

image

Python - stderr - Console ✅

Behaves as expected.

> result = Polyglot.eval('python', '<----');
Error: SyntaxError: invalid syntax
    at Object.eval (native)

Ruby - stdout - Jupyter Notebook ❌

Output of puts is not shown

image

Ruby - stdout - Console ✅

Behaves as expected.

> result = Polyglot.eval('ruby', 'a = 0\nputs a\na += 1');
0
1

Ruby - stderr - Jupyter Notebook ❌

No error message in Notebook, NEL internal error on Node console, kernel is stuck in execution and is unresponsive.

image

Ruby - stderr - Console ❌

Unrelated JS error is shown.

> result = Polyglot.eval('ruby', '<----');
TypeError: Object prototype may only be an Object or null: DynamicObject@5d75f90e<Method>
    at Function.setPrototypeOf (native)
    at deprecate (internal/util.js:70:10)
    at formatValue (internal/util/inspect.js:481:21)
    at Object.inspect (internal/util/inspect.js:191:10)
    at Domain.debugDomainError (repl.js:439:34)
    at Domain.emit (events.js:189:13)
    at Domain.emit (domain.js:441:20)
    at REPLServer.defaultEval (repl.js:353:26)
    at bound (domain.js:395:14)
    at REPLServer.runBound (domain.js:408:12)

R - stdout - Jupyter Notebook ❌

Output of print() is not shown

image

R - stdout - Console ✅

Behaves as expected.

> result = Polyglot.eval('R', 'a = 0\nprint(a)\nb = "asdf"');
[1] 0
'asdf'

R - stderr - Jupyter Notebook ✅

Behaves as expected.

image

R - stderr - Console ✅

Behaves as expected.

> result = Polyglot.eval('R', '<----');
Error: parse exception
    at Object.eval (native)

JS - stdout - Jupyter Notebook ✅

Behaves as expected.

image

JS - stdout - Console ✅

Behaves as expected.

> result = Polyglot.eval('js', 'a = 0\nconsole.log(a)\na += 1');
0
1

JS - stderr - Jupyter Notebook ✅

Behaves as expected.

image

JS - stderr - Console ✅

Behaves as expected.

> result = Polyglot.eval('js', '<----');
Error: SyntaxError: <eval>:1:0 Expected an operand but found <
<----
^

    at Object.eval (native)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants