Grokbase Groups Pig user June 2012
FAQ
This has to be something obvious but I can’t seem to get python parameters once I add in a main(). Thanks.

~/pig-0.10/bin/pig pytest.py haha
...
2012-06-18 17:11:50,312 [main] INFO org.apache.pig.scripting.jython.JythonScriptEngine - created tmp python.cachedir=/tmp/pig_jytho
n_9083561197267275440
haha

~/pig-0.10/bin/pig pytest2.py haha
...
2012-06-18 17:13:25,609 [main] INFO org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting UDF: main
2012-06-18 17:13:25,635 [main] ERROR org.apache.pig.Main - ERROR 1121: Python Error. Traceback (most recent call last):
File "/home/wduckworth/pytest2.py", line 11, in <module>
print sys.argv[1]
IndexError: index out of range: 1

* * * pytest.py

#!/usr/bin/python

import sys
from org.apache.pig.scripting import Pig
print sys.argv[1]

* * * pytest2.py

#!/usr/bin/python

import sys
from org.apache.pig.scripting import Pig

def main():
print sys.argv[1]

if __name__ == '__main__':
main()




Will Duckworth Senior Vice President, Software Engineering | comScore, Inc. (NASDAQ:SCOR)

o +1 (703) 438-2108 | m +1 (301) 606-2977 | wduckworth@comscore.com

...........................................................................................................

Introducing Mobile Metrix 2.0 - The next generation of mobile behavioral measurement
www.comscore.com/MobileMetrix<http://www.comscore.com/Products_Services/Product_Index/Mobile_Metrix_2.0>

Search Discussions

  • Duckworth, Will at Jun 18, 2012 at 9:52 pm
    I tried a couple other versions.

    This will work:

    #!/usr/bin/python

    import sys

    from org.apache.pig.scripting import Pig

    if __name__ == '__main__':
    print sys.argv[1]


    This will not:

    #!/usr/bin/python

    import sys

    from org.apache.pig.scripting import Pig

    @outputSchema("ip_address:long")
    def Ip2Num(ip):
    pass

    if __name__ == '__main__':
    print sys.argv[1]




    Will Duckworth Senior Vice President, Software Engineering | comScore, Inc.(NASDAQ:SCOR)
    o +1 (703) 438-2108 | m +1 (301) 606-2977 | mailto:wduckworth@comscore.com
    .....................................................................................................
    -----Original Message-----
    From: Duckworth, Will
    Sent: Monday, June 18, 2012 5:19 PM
    To: user@pig.apache.org
    Subject: Getting sys.argv using embedded jython

    This has to be something obvious but I can’t seem to get python parameters once I add in a main(). Thanks.

    ~/pig-0.10/bin/pig pytest.py haha
    ...
    2012-06-18 17:11:50,312 [main] INFO org.apache.pig.scripting.jython.JythonScriptEngine - created tmp python.cachedir=/tmp/pig_jytho
    n_9083561197267275440
    haha

    ~/pig-0.10/bin/pig pytest2.py haha
    ...
    2012-06-18 17:13:25,609 [main] INFO org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting UDF: main
    2012-06-18 17:13:25,635 [main] ERROR org.apache.pig.Main - ERROR 1121: Python Error. Traceback (most recent call last):
    File "/home/wduckworth/pytest2.py", line 11, in <module>
    print sys.argv[1]
    IndexError: index out of range: 1

    * * * pytest.py

    #!/usr/bin/python

    import sys
    from org.apache.pig.scripting import Pig
    print sys.argv[1]

    * * * pytest2.py

    #!/usr/bin/python

    import sys
    from org.apache.pig.scripting import Pig

    def main():
    print sys.argv[1]

    if __name__ == '__main__':
    main()




    Will Duckworth Senior Vice President, Software Engineering | comScore, Inc. (NASDAQ:SCOR)

    o +1 (703) 438-2108 | m +1 (301) 606-2977 | wduckworth@comscore.com

    ...........................................................................................................

    Introducing Mobile Metrix 2.0 - The next generation of mobile behavioral measurement
    www.comscore.com/MobileMetrix<http://www.comscore.com/Products_Services/Product_Index/Mobile_Metrix_2.0>
  • Daniel Dai at Jun 19, 2012 at 8:53 pm
    Yes, I can see this. However, trunk runs fine for me. I don't yet know why
    was that.

    Daniel
    On Mon, Jun 18, 2012 at 2:52 PM, Duckworth, Will wrote:

    I tried a couple other versions.

    This will work:

    #!/usr/bin/python

    import sys

    from org.apache.pig.scripting import Pig

    if __name__ == '__main__':
    print sys.argv[1]


    This will not:

    #!/usr/bin/python

    import sys

    from org.apache.pig.scripting import Pig

    @outputSchema("ip_address:long")
    def Ip2Num(ip):
    pass

    if __name__ == '__main__':
    print sys.argv[1]




    Will Duckworth Senior Vice President, Software Engineering | comScore,
    Inc.(NASDAQ:SCOR)
    o +1 (703) 438-2108 | m +1 (301) 606-2977 | mailto:wduckworth@comscore.com

    .....................................................................................................
    -----Original Message-----
    From: Duckworth, Will
    Sent: Monday, June 18, 2012 5:19 PM
    To: user@pig.apache.org
    Subject: Getting sys.argv using embedded jython

    This has to be something obvious but I can’t seem to get python parameters
    once I add in a main(). Thanks.

    ~/pig-0.10/bin/pig pytest.py haha
    ...
    2012-06-18 17:11:50,312 [main] INFO
    org.apache.pig.scripting.jython.JythonScriptEngine - created tmp
    python.cachedir=/tmp/pig_jytho
    n_9083561197267275440
    haha

    ~/pig-0.10/bin/pig pytest2.py haha
    ...
    2012-06-18 17:13:25,609 [main] INFO
    org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting
    UDF: main
    2012-06-18 17:13:25,635 [main] ERROR org.apache.pig.Main - ERROR 1121:
    Python Error. Traceback (most recent call last):
    File "/home/wduckworth/pytest2.py", line 11, in <module>
    print sys.argv[1]
    IndexError: index out of range: 1

    * * * pytest.py

    #!/usr/bin/python

    import sys
    from org.apache.pig.scripting import Pig
    print sys.argv[1]

    * * * pytest2.py

    #!/usr/bin/python

    import sys
    from org.apache.pig.scripting import Pig

    def main():
    print sys.argv[1]

    if __name__ == '__main__':
    main()




    Will Duckworth Senior Vice President, Software Engineering | comScore,
    Inc. (NASDAQ:SCOR)

    o +1 (703) 438-2108 | m +1 (301) 606-2977 | wduckworth@comscore.com


    ...........................................................................................................

    Introducing Mobile Metrix 2.0 - The next generation of mobile behavioral
    measurement
    www.comscore.com/MobileMetrix<
    http://www.comscore.com/Products_Services/Product_Index/Mobile_Metrix_2.0>

  • Duckworth, Will at Jun 19, 2012 at 9:08 pm
    Thanks Daniel. I will get a build of trunk and test as well.
    On Jun 19, 2012, at 4:53 PM, "Daniel Dai" wrote:

    Yes, I can see this. However, trunk runs fine for me. I don't yet know why
    was that.

    Daniel
    On Mon, Jun 18, 2012 at 2:52 PM, Duckworth, Will wrote:

    I tried a couple other versions.

    This will work:

    #!/usr/bin/python

    import sys

    from org.apache.pig.scripting import Pig

    if __name__ == '__main__':
    print sys.argv[1]


    This will not:

    #!/usr/bin/python

    import sys

    from org.apache.pig.scripting import Pig

    @outputSchema("ip_address:long")
    def Ip2Num(ip):
    pass

    if __name__ == '__main__':
    print sys.argv[1]




    Will Duckworth Senior Vice President, Software Engineering | comScore,
    Inc.(NASDAQ:SCOR)
    o +1 (703) 438-2108 | m +1 (301) 606-2977 | mailto:wduckworth@comscore.com

    .....................................................................................................
    -----Original Message-----
    From: Duckworth, Will
    Sent: Monday, June 18, 2012 5:19 PM
    To: user@pig.apache.org
    Subject: Getting sys.argv using embedded jython

    This has to be something obvious but I can’t seem to get python parameters
    once I add in a main(). Thanks.

    ~/pig-0.10/bin/pig pytest.py haha
    ...
    2012-06-18 17:11:50,312 [main] INFO
    org.apache.pig.scripting.jython.JythonScriptEngine - created tmp
    python.cachedir=/tmp/pig_jytho
    n_9083561197267275440
    haha

    ~/pig-0.10/bin/pig pytest2.py haha
    ...
    2012-06-18 17:13:25,609 [main] INFO
    org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting
    UDF: main
    2012-06-18 17:13:25,635 [main] ERROR org.apache.pig.Main - ERROR 1121:
    Python Error. Traceback (most recent call last):
    File "/home/wduckworth/pytest2.py", line 11, in <module>
    print sys.argv[1]
    IndexError: index out of range: 1

    * * * pytest.py

    #!/usr/bin/python

    import sys
    from org.apache.pig.scripting import Pig
    print sys.argv[1]

    * * * pytest2.py

    #!/usr/bin/python

    import sys
    from org.apache.pig.scripting import Pig

    def main():
    print sys.argv[1]

    if __name__ == '__main__':
    main()




    Will Duckworth Senior Vice President, Software Engineering | comScore,
    Inc. (NASDAQ:SCOR)

    o +1 (703) 438-2108 | m +1 (301) 606-2977 | wduckworth@comscore.com
    ...........................................................................................................

    Introducing Mobile Metrix 2.0 - The next generation of mobile behavioral
    measurement
    www.comscore.com/MobileMetrix<
    http://www.comscore.com/Products_Services/Product_Index/Mobile_Metrix_2.0>

  • Duckworth, Will at Jun 19, 2012 at 10:10 pm
    Confirmed that it works with trunk. Want me to log a ticket against 0.10?
    On Jun 19, 2012, at 5:09 PM, "Duckworth, Will" wrote:

    Thanks Daniel. I will get a build of trunk and test as well.
    On Jun 19, 2012, at 4:53 PM, "Daniel Dai" wrote:

    Yes, I can see this. However, trunk runs fine for me. I don't yet know why
    was that.

    Daniel
    On Mon, Jun 18, 2012 at 2:52 PM, Duckworth, Will wrote:

    I tried a couple other versions.

    This will work:

    #!/usr/bin/python

    import sys

    from org.apache.pig.scripting import Pig

    if __name__ == '__main__':
    print sys.argv[1]


    This will not:

    #!/usr/bin/python

    import sys

    from org.apache.pig.scripting import Pig

    @outputSchema("ip_address:long")
    def Ip2Num(ip):
    pass

    if __name__ == '__main__':
    print sys.argv[1]




    Will Duckworth Senior Vice President, Software Engineering | comScore,
    Inc.(NASDAQ:SCOR)
    o +1 (703) 438-2108 | m +1 (301) 606-2977 | mailto:wduckworth@comscore.com

    .....................................................................................................
    -----Original Message-----
    From: Duckworth, Will
    Sent: Monday, June 18, 2012 5:19 PM
    To: user@pig.apache.org
    Subject: Getting sys.argv using embedded jython

    This has to be something obvious but I can’t seem to get python parameters
    once I add in a main(). Thanks.

    ~/pig-0.10/bin/pig pytest.py haha
    ...
    2012-06-18 17:11:50,312 [main] INFO
    org.apache.pig.scripting.jython.JythonScriptEngine - created tmp
    python.cachedir=/tmp/pig_jytho
    n_9083561197267275440
    haha

    ~/pig-0.10/bin/pig pytest2.py haha
    ...
    2012-06-18 17:13:25,609 [main] INFO
    org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting
    UDF: main
    2012-06-18 17:13:25,635 [main] ERROR org.apache.pig.Main - ERROR 1121:
    Python Error. Traceback (most recent call last):
    File "/home/wduckworth/pytest2.py", line 11, in <module>
    print sys.argv[1]
    IndexError: index out of range: 1

    * * * pytest.py

    #!/usr/bin/python

    import sys
    from org.apache.pig.scripting import Pig
    print sys.argv[1]

    * * * pytest2.py

    #!/usr/bin/python

    import sys
    from org.apache.pig.scripting import Pig

    def main():
    print sys.argv[1]

    if __name__ == '__main__':
    main()




    Will Duckworth Senior Vice President, Software Engineering | comScore,
    Inc. (NASDAQ:SCOR)

    o +1 (703) 438-2108 | m +1 (301) 606-2977 | wduckworth@comscore.com
    ...........................................................................................................

    Introducing Mobile Metrix 2.0 - The next generation of mobile behavioral
    measurement
    www.comscore.com/MobileMetrix<
    http://www.comscore.com/Products_Services/Product_Index/Mobile_Metrix_2.0>

  • Daniel Dai at Jun 19, 2012 at 11:25 pm
    Go ahead
    On Tue, Jun 19, 2012 at 3:10 PM, Duckworth, Will wrote:

    Confirmed that it works with trunk. Want me to log a ticket against 0.10?
    On Jun 19, 2012, at 5:09 PM, "Duckworth, Will" wrote:

    Thanks Daniel. I will get a build of trunk and test as well.
    On Jun 19, 2012, at 4:53 PM, "Daniel Dai" wrote:

    Yes, I can see this. However, trunk runs fine for me. I don't yet know
    why
    was that.

    Daniel

    On Mon, Jun 18, 2012 at 2:52 PM, Duckworth, Will <
    wduckworth@comscore.com>wrote:
    I tried a couple other versions.

    This will work:

    #!/usr/bin/python

    import sys

    from org.apache.pig.scripting import Pig

    if __name__ == '__main__':
    print sys.argv[1]


    This will not:

    #!/usr/bin/python

    import sys

    from org.apache.pig.scripting import Pig

    @outputSchema("ip_address:long")
    def Ip2Num(ip):
    pass

    if __name__ == '__main__':
    print sys.argv[1]




    Will Duckworth Senior Vice President, Software Engineering |
    comScore,
    Inc.(NASDAQ:SCOR)
    o +1 (703) 438-2108 | m +1 (301) 606-2977 | mailto:
    wduckworth@comscore.com
    .....................................................................................................
    -----Original Message-----
    From: Duckworth, Will
    Sent: Monday, June 18, 2012 5:19 PM
    To: user@pig.apache.org
    Subject: Getting sys.argv using embedded jython

    This has to be something obvious but I can’t seem to get python
    parameters
    once I add in a main(). Thanks.

    ~/pig-0.10/bin/pig pytest.py haha
    ...
    2012-06-18 17:11:50,312 [main] INFO
    org.apache.pig.scripting.jython.JythonScriptEngine - created tmp
    python.cachedir=/tmp/pig_jytho
    n_9083561197267275440
    haha

    ~/pig-0.10/bin/pig pytest2.py haha
    ...
    2012-06-18 17:13:25,609 [main] INFO
    org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting
    UDF: main
    2012-06-18 17:13:25,635 [main] ERROR org.apache.pig.Main - ERROR 1121:
    Python Error. Traceback (most recent call last):
    File "/home/wduckworth/pytest2.py", line 11, in <module>
    print sys.argv[1]
    IndexError: index out of range: 1

    * * * pytest.py

    #!/usr/bin/python

    import sys
    from org.apache.pig.scripting import Pig
    print sys.argv[1]

    * * * pytest2.py

    #!/usr/bin/python

    import sys
    from org.apache.pig.scripting import Pig

    def main():
    print sys.argv[1]

    if __name__ == '__main__':
    main()




    Will Duckworth Senior Vice President, Software Engineering | comScore,
    Inc. (NASDAQ:SCOR)

    o +1 (703) 438-2108 | m +1 (301) 606-2977 | wduckworth@comscore.com
    ...........................................................................................................
    Introducing Mobile Metrix 2.0 - The next generation of mobile
    behavioral
    measurement
    www.comscore.com/MobileMetrix<
    http://www.comscore.com/Products_Services/Product_Index/Mobile_Metrix_2.0>

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriespig, hadoop
postedJun 18, '12 at 9:19p
activeJun 19, '12 at 11:25p
posts6
users2
websitepig.apache.org

2 users in discussion

Duckworth, Will: 4 posts Daniel Dai: 2 posts

People

Translate

site design / logo © 2022 Grokbase