You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@zeppelin.apache.org by Jongyoul Lee <jo...@gmail.com> on 2023/08/19 08:14:06 UTC

Re: Passing a variable from an Angular paragraph to a Pyspark paragraph

Hello,

It's been a long time but do you still have the same issue? I'm not sure
about the feature but someone is using the similar features in my
understanding.

Do you have any update?

Regards,
Jongyoul

2023년 6월 16일 (금) 오전 12:36, alexander.2.kerr.bt.com via users <
users@zeppelin.apache.org>님이 작성:

> Hi,
>
>
>
> I’m trying to do a very simple thing – passing a variable (ideally an
> array, but string will do) from an Angular paragraph to a pyspark
> paragraph. Unfortunately I just get the result “None” when printing the
> value in pyspark.
>
>
>
> Setting the variable in my Angular paragraph (I’m using Javascript to do
> this for reasons related to the bigger project I’m working on and this
> works fine for passing to another %angular or %spark.spark paragraph):
>
>
>
> %angular
>
>
>
> <form id="main_form"></form>
>
> <script>
>
> $( document ).ready(function() {
>
>     angFormScope =
> angular.element(document.getElementById('main_form')).scope(); // Set
> Angular scope variable now document is fully loaded and ready
>
>     angFormScope.testvar = "hello"
>
> });
>
> </script>
>
>
>
> Trying to read the variable in my pyspark paragraph:
>
>
>
> %spark.pyspark
>
> testvar = z.get("testvar");
>
> print(testvar);
>
>
>
> Output: None
>
>
>
> However, getting the variable in another angular paragraph works fine.
>
>
>
> I also seem to have access to the Zeppelin context in %pyspark and %python
> paragraphs, e.g. these work:
>
>
>
> %spark.pyspark
>
> print(z.z);
>
> Output: org.apache.zeppelin.spark.SparkZeppelinContext@2cd4a775
>
>
>
> %python
>
> # Gets the user's ID from the system, and puts it in the user_ID bound
> variable
>
> z.z.angularBind("user_ID",
> z.getInterpreterContext().getAuthenticationInfo().getUser())
>
> Output: gives the user id correctly
>
>
>
> %spark.pyspark
>
> z.z.getInterpreterContext().getNoteId()
>
> Output: Gives the note ID correctly.
>
>
>
> I notice from the python Zeppelin context source that get() should be
> available but the function call should be “def get(self, key)” – am I
> supposed to specify self somehow?
> https://github.com/apache/zeppelin/blob/master/python/src/main/resources/python/zeppelin_context.py#L58
>
>
>
> Think I just need the right syntax here unless there’s a bug in Zeppelin
> blocking this from working (unfortunately it’s running in a corporate
> environment with Zeppelin 0.8.2).
>
>
>
> Thanks for any info.
>
>
>
> Alex Kerr
>
>
>


-- 
이종열, Jongyoul Lee, 李宗烈
http://madeng.net