Skip to content

Conversation

@jongyoul
Copy link
Member

@jongyoul jongyoul commented Jul 7, 2016

What is this PR for?

Supporting aliases for same interpreter group and enabling running two interpreters in same group.

What type of PR is it?

[Feature]

Todos

  • - Add InterpreterSettingRef
  • - Add aliases feature

What is the Jira issue?

How should this be tested?

  1. Create spark2 interpreter in a interpreter tab
  2. Add that interpreter in a notebook
  3. run %spark and %spark2

Screenshots (if appropriate)

Questions:

  • Does the licenses files need update? No
  • Is there breaking changes for older versions? No
  • Does this needs documentation? No

@Leemoonsoo
Copy link
Member

I have tested this branch and i've got some feedbacks

Interpreter-setting name and alias
I see interpreter-setting has alias field. And how about just use interpreter-setting name as an alias, for simplicity? instead of having both name and alias field.

Interpreter selection mechanism.
This PR changes current interpreter selection mechanism a lot.
For example, if i bind interpreter %md, %spark (spark, sql), %shell ... and try to use
%sql select * from table, then i get prefix not found.

I strongly recommend keep compatibility of previous interpreter selection mechanism, because it changes major user experience of Zeppelin.

My suggestion is,

  1. select interpreter in previous way first. i.e. matching [group].[name] with interpreter selection text.
  2. if there is no matching interpreter, start matching [alias].[name] with interpreter selection text.

while matching rule is

  1. if interpreter selection text specify full [group].[name] or [alias].[name], then simply find corresponding interpreter-setting and interpreter.
  2. if interpreter selection text specify just name, first assume [group] or [alias] is omitted.
  3. then assume [name] is omitted.

Import and change interpreter binding

It can be a future work, but i'd like to at least have an direction how we want to handle user experience change expected this PR brings.

Before

- While Zeppelin instance have the same set of interpreters, imported notebook may run without modification
- It was possible to quickly change interpreter binding without changing every paragraph. i.e. Bind 'spark-small-cluster' interpreter setting first and then bind 'spark-large-cluster' later without changing interpreter selection text of individual paragraphs

After

- If paragraph uses alias for interpreter selection, imported notebook will not able to run unless manually change interpreter selection text for the Zeppelin instance.
- Once user want to run the same notebook with different interpreter-setting, user need to change interpreter selection text of all paragraphs

@jongyoul
Copy link
Member Author

@Leemoonsoo Thanks for the review, and because this is the first working draft and I've changed a lot, some incompatibility and bug may exists. I'll fix them.

Concerning name and alias, that's also what i ask for. Keeping both of them would be redundant. And I'll check the selection mechanism. It may occurs because I've changed getInterpreter code for not using Interpreter.registeredInterpreters. I don't want to change the mechanism and should keep the current order as you mentioned. Finally, I agree to decide the direction to interpreter binding and import/export issue

@jongyoul
Copy link
Member Author

jongyoul commented Jul 10, 2016

@Leemoonsoo Merged name and aliases, and enabled working with 0.6.0's conf/interpreter.json. Concerning matching interpreters, I've test it with 0.6.0 binary. But there're something different from what you mentioned. If you choose %md as default and you run %sql select 1, it results in Prefix not found like what I've attached. In the code, %{name} will be adopted when default group has that name. Thus if you didn't set spark as default, you couldn't run %spark.sql only with %sql. Could you please check it again? and I've passed the CI!!
screen shot 2016-07-11 at 12 09 26 am

jongyoul added 2 commits July 11, 2016 00:12
Fixed the type of variables
Adjusted diamond operator
@jongyoul
Copy link
Member Author

Merging if there's no more discussion

private transient String path;

@Deprecated
private String group;
Copy link
Member

Choose a reason for hiding this comment

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

Is there any special reason deprecate group and create refName instead?
In my understanding, value in refName is always exactly the same to value held by group previously.

Copy link
Member Author

Choose a reason for hiding this comment

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

There're two reason. The most important point is mapping interpreterSettingRef and interpreterSetting. If we keep group as the name of interpreter, InterpreterSetting.group points InterpreterSetting.name. I think it makes more difficult to understand mapping. Currently, InterpreterSetting.refName points InterpreterSettingRef.name. I thought it would be better. Second, in more minor reason, This is a bit confusion from InterpreterGroup. InterpreterSetting.group is not related interpreterGroup but because those two terms includes group in their name, it looks related. It, however, is minor issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

And the reason why I deprecated instead of removing it is backward compatibility.

Copy link
Member

Choose a reason for hiding this comment

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

If field name is used internally only, refName might help understand relation between InterpreterSetting.name and InterpreterSettingRef.name.

However, field name in InterpreterSetting change format of conf/interpreter.json and interpreter setting creation REST api.

So i'm not sure it's good idea to change file format and REST api to improve readability of internal code. Users might already have some external tools and codes that interact with conf/interpreter.json and interpreter setting creation REST api.

I think we can just add comment in the source code to clarify how InterpreterSettingRef and InterpreterSetting is mapped, without field name change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I've got it. Actually variable names are not important and I agree that it's also good to keep that name. I'll revert those changes.

@Leemoonsoo
Copy link
Member

@jongyoul

Regarding Prefix Not found,

Thought it was coming from this PR but found that Prefix Not found message looks like coming after ca27bf5.
Previously, in the same situation, sql interpreter not found was printed.

The difference is, previously, ZeppelinServer (InterpreterFactory, NoteReplLoader) decide which interpreter to load and print sql interpreter not found. After ca27bf5, it starts jdbc interpreter and jdbc interpreter prints it.

@Leemoonsoo
Copy link
Member

Another behavior change i found from this PR is,

When no interpreter is binded to a notebook, (e.g. incase of conf/interpreter.json is removed)
When user open a notebook, Zeppelin automatically open interpreter binding menu and suggest default set of selections.

Previously, default set of selections were, a interpreter setting from each interpreter groups.
For example, if there are interpreter setting spark, spark2, md, sh, suggested selection will be spark, md, sh.

image

This PR suggest the first interpreter setting only. spark in the same situation.

image


intpSetting.setInterpreterGroupFactory(this);
interpreterSettings.put(intpSetting.id(), intpSetting);
saveToFile();
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason not saving it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've replace the function of add to add interpreterSettingRef and add new method called createNewSetting. Thus this method is called when InterpreterFactory.init() only and init method run saveToFile() at the end of method. Thus It would be redundant. But, I've missed saveToFile() at the end of createNewSetting. I'll add it into createNewSetting

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added saveToFile() at the end of createNewSetting, pushed it.

@jongyoul
Copy link
Member Author

@Leemoonsoo I've check the default binding issues and I will fix it.

Removed meaningless super constructor
@jongyoul
Copy link
Member Author

@Leemoonsoo Concerning sql interpreter not found, I'll fix that issue with another one. I'll remove jdbc magic after I adopt this feature.

@jongyoul
Copy link
Member Author

@Leemoonsoo I've reverted refName to group again. Review this PR finally.

@Leemoonsoo
Copy link
Member

@jongyoul Thanks! I have tested and reviewed the code. and looks good except one behavior.

Let's say there're two interpreter settings. spark1 and spark2 (and no interpreter setting name spark).

previously '%spark' select spark1 or spark2 whichever in front of binded interpreter list.
now, '%spark' is printing Prefix not found.

So after this PR, in this specific case, notebook will not be run before user change interpreter selection text in every paragraphs.

How do you think about supporting previous interpreter selection mechanism, too? Will there be any side effect to support previous interpreter selection mechanism? Or do you think it's better support new selection mechanism only?

@jongyoul
Copy link
Member Author

@Leemoonsoo I agree that this PR lower user experience in your case. It's better to support that feature for backward compatibility. BTW, I also think this makes users confused because user has no interpreter setting like spark but can run with %spark. I'll handle this issue with ZEPPELIN-1191 because it's out of scope of this issue. I merge it now and go for the next issue.

@jongyoul
Copy link
Member Author

@Leemoonsoo Thanks for detail review!!

@asfgit asfgit closed this in b11b6ec Jul 15, 2016
PhilippGrulich pushed a commit to SWC-SENSE/zeppelin that referenced this pull request Aug 8, 2016
### What is this PR for?
Supporting aliases for same interpreter group and enabling running two interpreters in same group.

### What type of PR is it?
[Feature]

### Todos
* [x] - Add InterpreterSettingRef
* [x] - Add aliases feature

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-1012

### How should this be tested?
1. Create spark2 interpreter in a interpreter tab
1. Add that interpreter in a notebook
1. run `%spark` and `%spark2`

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Jongyoul Lee <[email protected]>

Closes apache#1145 from jongyoul/ZEPPELIN-1012 and squashes the following commits:

4d38462 [Jongyoul Lee] Reverted modifier of CronJob back to public
2fab2f2 [Jongyoul Lee] Reverted default constructor
7f9f72d [Jongyoul Lee] Fixed the style
4dd8f6e [Jongyoul Lee] Reverted style into original to avoid checkstyle
5eff48f [Jongyoul Lee] Reverted style into original to avoid checkstyle
5e50864 [Jongyoul Lee] Reverted refName to group
fac0b86 [Jongyoul Lee] Reformatted files related to this PR without test classes
5bb15a0 [Jongyoul Lee] Removed some console.log added for debugging
334634a [Jongyoul Lee] Fixed the description of parameter of add method
ca20889 [Jongyoul Lee] Changed setting.group to setting.name Removed meaningless super constructor
dde2232 [Jongyoul Lee] Added catching IOE from caller of createNewSetting
cb7dde5 [Jongyoul Lee] Fixed wrong test to save to file after Zeppelin calls createNewSetting
d59029b [Jongyoul Lee] Removed unused code Fixed the type of variables Adjusted diamond operator
9b05ca2 [Jongyoul Lee] Fixed some style
e585791 [Jongyoul Lee] Fixed some style
634cc21 [Jongyoul Lee] Fixed usage of getGroup
c100f76 [Jongyoul Lee] Removed deprecated method
240c8af [Jongyoul Lee] Removed debugging message
4ff493b [Jongyoul Lee] Fixed test case
d5a4c44 [Jongyoul Lee] Refactored InterpreterSetting Changed menu for creating new InterpreterSetting
16b56c3 [Jongyoul Lee] Fixed broken tests for InterpreterRestApiTest
fccdd9b [Jongyoul Lee] Fixed the style
5159a84 [Jongyoul Lee] Added feature for Interpreter aliases Extracted InterpreterInfo from InterpreterSetting
c4b016e [Jongyoul Lee] Refactored getInterpreter method not to use RegisteredInterpreter
minahlee added a commit to minahlee/zeppelin that referenced this pull request Sep 7, 2016
minahlee added a commit to minahlee/zeppelin that referenced this pull request Sep 7, 2016
minahlee added a commit to minahlee/zeppelin that referenced this pull request Sep 7, 2016
minahlee added a commit to minahlee/zeppelin that referenced this pull request Sep 7, 2016
minahlee added a commit to minahlee/zeppelin that referenced this pull request Sep 7, 2016
minahlee added a commit to minahlee/zeppelin that referenced this pull request Sep 7, 2016
minahlee added a commit to minahlee/zeppelin that referenced this pull request Sep 8, 2016
minahlee added a commit to minahlee/zeppelin that referenced this pull request Sep 8, 2016
minahlee added a commit to minahlee/zeppelin that referenced this pull request Sep 12, 2016
minahlee added a commit to minahlee/zeppelin that referenced this pull request Sep 21, 2016
minahlee added a commit to minahlee/zeppelin that referenced this pull request Sep 22, 2016
minahlee added a commit to minahlee/zeppelin that referenced this pull request Sep 22, 2016
asfgit pushed a commit that referenced this pull request Sep 23, 2016
### What is this PR for?
This is complete work of #1148. Comments and tasks on #1148 has been handled in this PR.
- Add syntax language information in `interpreter-setting.json`
- When user type `%replName` in paragraph, back-end check if the interpreter name with `replName` exists, and return language information to front-end if it does
- If user doesn't specify `%replName`, default interpreter's language will be used
- Using alias name for paragraph syntax highlight

### What type of PR is it?
[Bug Fix | Improvement]

### What is the Jira issue?
[ZEPPELIN-1026](https://issues.apache.org/jira/browse/ZEPPELIN-1026)

### How should this be tested?
1. Create new note and make markdown interpreter to be default.
2. See if markdown syntax is applied.

### Screenshots (if appropriate)
#### Case 1. When the default interpreter set to python interpreter.
**Before**
Has `scala` as syntax highlight language when %python is not set.
<img width="665" alt="screen shot 2016-07-07 at 10 46 20 pm" src="https://cloud.githubusercontent.com/assets/8503346/16655312/af67a302-4494-11e6-949e-793ad0515d7a.png">

**After**
Has `python` as syntax highlight language even when %python is not set.
<img width="666" alt="screen shot 2016-07-07 at 10 44 39 pm" src="https://cloud.githubusercontent.com/assets/8503346/16655248/769d8ba4-4494-11e6-9b3c-dc5e026e9c53.png">

#### Case 2. When use alias name as repl name.
**Before**
<img width="742" alt="screen shot 2016-09-08 at 4 22 39 pm" src="https://cloud.githubusercontent.com/assets/8503346/18353471/620c5ede-75e2-11e6-9d01-0726bc900dc0.png">

**After**
<img width="741" alt="screen shot 2016-09-08 at 4 34 57 pm" src="https://cloud.githubusercontent.com/assets/8503346/18353487/6cdaa406-75e2-11e6-831a-08e0fa3a85d8.png">

### Further possible improvements
There are still several cases that Zeppelin doesn't handle syntax highlight well. These can be handled with another jira ticket/PR.
1. When default bound interpreter changes, syntax highlight is not changed accordingly
2. When copy/paste code, syntax highlight won't be applied properly since Zeppelin only checks changes when cursor is in first line.

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? yes(for creating new interpreter)

Author: Mina Lee <[email protected]>

Closes #1415 from minahlee/ZEPPELIN-1026 and squashes the following commits:

c66fb0e [Mina Lee] Move getEditorSetting to InterpreterFactory class
2d56222 [Mina Lee] Add description about default syntax highlight in doc
08ccad9 [Mina Lee] Fix test
0874522 [Mina Lee] Change condition for triggering 'getAndSetEditorSetting' to reduce front-end <-> back-end communication
9e4f2e9 [Mina Lee] Change the way to read interpreter language from interpreter-setting.json after #1145
75543b3 [Mina Lee] Add test
565d9d0 [Mina Lee] [DOC] Setting syntax highlight when writing new interpreter
20132ca [Mina Lee] Get paragraph editor mode from backend
52f4207 [Mina Lee] Align comments for readability
26cbbb8 [Mina Lee] Add editor field
pedrozatta pushed a commit to pedrozatta/zeppelin that referenced this pull request Oct 27, 2016
### What is this PR for?
This is complete work of apache#1148. Comments and tasks on apache#1148 has been handled in this PR.
- Add syntax language information in `interpreter-setting.json`
- When user type `%replName` in paragraph, back-end check if the interpreter name with `replName` exists, and return language information to front-end if it does
- If user doesn't specify `%replName`, default interpreter's language will be used
- Using alias name for paragraph syntax highlight

### What type of PR is it?
[Bug Fix | Improvement]

### What is the Jira issue?
[ZEPPELIN-1026](https://issues.apache.org/jira/browse/ZEPPELIN-1026)

### How should this be tested?
1. Create new note and make markdown interpreter to be default.
2. See if markdown syntax is applied.

### Screenshots (if appropriate)
#### Case 1. When the default interpreter set to python interpreter.
**Before**
Has `scala` as syntax highlight language when %python is not set.
<img width="665" alt="screen shot 2016-07-07 at 10 46 20 pm" src="https://cloud.githubusercontent.com/assets/8503346/16655312/af67a302-4494-11e6-949e-793ad0515d7a.png">

**After**
Has `python` as syntax highlight language even when %python is not set.
<img width="666" alt="screen shot 2016-07-07 at 10 44 39 pm" src="https://cloud.githubusercontent.com/assets/8503346/16655248/769d8ba4-4494-11e6-9b3c-dc5e026e9c53.png">

#### Case 2. When use alias name as repl name.
**Before**
<img width="742" alt="screen shot 2016-09-08 at 4 22 39 pm" src="https://cloud.githubusercontent.com/assets/8503346/18353471/620c5ede-75e2-11e6-9d01-0726bc900dc0.png">

**After**
<img width="741" alt="screen shot 2016-09-08 at 4 34 57 pm" src="https://cloud.githubusercontent.com/assets/8503346/18353487/6cdaa406-75e2-11e6-831a-08e0fa3a85d8.png">

### Further possible improvements
There are still several cases that Zeppelin doesn't handle syntax highlight well. These can be handled with another jira ticket/PR.
1. When default bound interpreter changes, syntax highlight is not changed accordingly
2. When copy/paste code, syntax highlight won't be applied properly since Zeppelin only checks changes when cursor is in first line.

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? yes(for creating new interpreter)

Author: Mina Lee <[email protected]>

Closes apache#1415 from minahlee/ZEPPELIN-1026 and squashes the following commits:

c66fb0e [Mina Lee] Move getEditorSetting to InterpreterFactory class
2d56222 [Mina Lee] Add description about default syntax highlight in doc
08ccad9 [Mina Lee] Fix test
0874522 [Mina Lee] Change condition for triggering 'getAndSetEditorSetting' to reduce front-end <-> back-end communication
9e4f2e9 [Mina Lee] Change the way to read interpreter language from interpreter-setting.json after apache#1145
75543b3 [Mina Lee] Add test
565d9d0 [Mina Lee] [DOC] Setting syntax highlight when writing new interpreter
20132ca [Mina Lee] Get paragraph editor mode from backend
52f4207 [Mina Lee] Align comments for readability
26cbbb8 [Mina Lee] Add editor field
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

Successfully merging this pull request may close these issues.

2 participants