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

Executing cell in specific language #598

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

lemeb
Copy link

@lemeb lemeb commented Dec 5, 2019

As mentioned in #509, #507, and #450, it is now possible in Livy to execute Spark code in Python, Scala, R for any Livy session. That would be great if you want to write polyglot notebooks and, as it turns out, it is quite a low-hanging fruit.

A few notes:

  • It uses an existing command line argument: %%spark run -l [language] for IPython kernels, or %%spark -l [language] for Sparkmagic kernels.
  • All unit tests pass. I did not write any additional tests, though.
  • I did not modify the documentation — or the example notebooks.

Here is a (slightly doctored for the sake of simplicity) working example. The json file is from here.

That was simple enough; now, for further, hard questions:

  • Can you get proper syntax highlighting for each cell?
  • How could we refactor the code such as you could have one Scala notebook and one Pyspark notebook working on the same session? (That is definitely doable.)

Anyway, thanks for all your hard work! Peace ✌️

@itamarst
Copy link
Contributor

This is pretty cool. Thank you! To get this merged, we'd probably need:

  1. Make sure there are some examples in the notebooks, just so people know it's a feature!
  2. Some unit tests.

Not really sure if it's possible to do syntax highlighting per cell...

@lemeb
Copy link
Author

lemeb commented Dec 21, 2019

thanks @itamarst! I'll try to have these two tasks done in the next few weeks when my thesis is done. :) (Right now, I'd had to boot sparkmagic out of my computers because it wasn't playing well with anaconda.)

Keep up the good work!

@snehab14
Copy link

Hi @lemeb, this is great!
Are you still working on getting this merged? This would definitely provide a lot of value.

Comment on lines +45 to +46
except BadUserConfigurationException as e:
codekind = session.kind

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to default this to the session kind? A statement without any kind attribute will use the session kind by default. Reference: https://livy.incubator.apache.org/docs/latest/rest-api.html#session-kind

@lemeb
Copy link
Author

lemeb commented Dec 19, 2023

hi @devstein ! Is there still a need for this PR? I could work on finishing it if you want.

Best :)

@devstein
Copy link
Collaborator

Hi @lemeb yes! This would a great addition. Let me know if I can help. Most of the merge conflicts are likely caused by enforcing black #605

@shay1bz shay1bz mentioned this pull request Mar 4, 2024
6 tasks
@shay1bz
Copy link

shay1bz commented Mar 4, 2024

This feature was implemented also in #892 (independently) on the latest master branch.

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

Successfully merging this pull request may close these issues.

5 participants