Use Input Static node to pass python script to Python Interface Node

Comments

5 comments

  • Avatar
    Stony Smith

    Our software uses Python 2.7.3.   Python and the StaticData node aren't going to mesh well.

    But, depending upon what you are wishing to do, you can simply put your python script directly into the python node.

    Or, if the following conditions are met:

    1. your script does not need to interact with DV in any way (neither input nor ouput)
    2. for some reason you want it in a static data node
    3. or, if you need python 3

    Then you could put your script into the static data node, and use OutputRaw to save the data to a text file. Then use this code fragment in a python node (put it in the "initialize" subroutine)

    import os
    os.system("/path/to/python3 myscript.py")

    But, huge caveat... the StaticData node is going to be very problematic over commas and question marks.  StaticData is not going to play well with various delimiters.

    0
    Comment actions Permalink
  • Avatar
    Robert Eddy

    Thanks Stony.  Forgetting Python 3 for the time being-- is there another example available demonstrating the best way to use Python in a Dataverse job?  

    I'm trying to work with the "Example Python Node" job that's included in the install, but I'm not making any progress.

    If there is a different or better example, that's great, could you share?  

    If there is not, could you help me understand how I could view log messages?  Any basic change I make causes the job to fail.  I've tried adding a new line with a custom message, and have adjusted the LogLevel, but I get strange errors about indentation.     

    I read http://localhost:8080/docs/dist/help/Content/h-tech-guides/python-logging-errors.htm and have changed the Node LogLevel to 0.  

    But when I enter:

    self.logInfo("Testing, testing.")

    or

    self.logMedium("Testing, testing.")


    unindent does not match any outer indentation level (temp.L107ATM19M003.4544.129.1493665004886.64e180058116dc9e5c3911f38da0ad16.prop, line 17)

    Any help greatly appreciated.  Thanks, Rob

     

    0
    Comment actions Permalink
  • Avatar
    Stony Smith

    This is the one thing that I hate about python the most.  I love it for many many things, but this "feature" just kills me.

    In the Python2Implementation input field.. the spacing is done with TABS.
    However, you will find that your code, even though it is aligned properly, is filled with spaces instead of tabs.

    That's why the "indentation" is incorrect.

    0
    Comment actions Permalink
  • Avatar
    Robert Eddy

    Yep, that was it, thank you.  These info msgs will be a huge help in understanding what the Brain us up to.

     

    0
    Comment actions Permalink
  • Avatar
    Stony Smith

    <humor> THAT message is from python, so you'll have to report it to python.org </humor>

    0
    Comment actions Permalink

Please sign in to leave a comment.



Powered by Zendesk