Data360 Analyze

 View Only
  • 1.  Python script in workflow properties

    Posted 09-15-2022 03:34
    Hi,

    In graphs I have couple of data flow properties (type string and choice). These graph will be used on server version and will not have simple access to change properties (f.e. report period, report year) and I though about some automation of this process.

    I want to use simple Python code to receive current year which will be used as parameter in my graph. I used type of the property - Python.

    When I try to write some code in configuration tab and run graph nothing is processing, just all code is transfer to nodes as string. 
    Do I need some additional configuration? Is there any manual or example how to use Python type in data flow properties?


    ------------------------------
    Michal Czaplinski
    UPM-Kymmene Oyj
    Tampere
    ------------------------------


  • 2.  RE: Python script in workflow properties

    Employee
    Posted 09-15-2022 08:53
    Edited by Adrian Williams 09-15-2022 08:57
    While the UI does not prevent you from specifying a Data Flow property with a type of 'Python' I would consider this a niche use of Data Flow properties. Textual property substitution does, as the name implies, insert the literal contents of the property into the position where the property substitution is being performed. The property value is essentially treated as verbatim text in the node as if it had been entered directly there by the user. The textual substitution occurs before the node starts processing per se.
    The Python type is normally utilized on individual nodes or on a Composite where it would operate similar to the built-in node properties that need to be configured with some Python code.

    You could perhaps use a Python type Data Flow property to specify the code to be run in a specific node, For example, given the following (non-parameterized) Generate Data node:

    You could define Data Flow properties and configure them as follows:

    And then specify textual property substitutions in a Generate Data node that referenced those Data Flow properties:

    Note the lack of apostrophes or quote characters around the property references in the node.

    You could consider using this approach if you wanted to define the script once and use it in multiple nodes. However, this approach is not recommended as it reduces the transparency of the logic as you need to navigate to the Data Flow properties panel to view how the node is configured, and has limited scalability (in terms of the impact of creating multiple Python script Data Flow properties and then attempting to view the correct one in the Data Flow properties panel. The recommended approach would be to define a custom library node that would result in a reusable component, allowing the node's logic to be visible in the script properties on the node (and could be modified on an instance of the library node if required).

    If you just want to access the current year value in a script you may want to consider referencing the built-in 'RunDate' Run property and use python code to extract the slice of the string that represents the year element:


    ------------------------------
    Adrian Williams
    Precisely Software Inc.
    Naperville IL
    ------------------------------



  • 3.  RE: Python script in workflow properties

    Posted 09-30-2022 08:08
    Edited by Michal Czaplinski 09-30-2022 08:08
    Thanks for explanation.

    ------------------------------
    Michal Czaplinski
    UPM-Kymmene Oyj
    Tampere
    ------------------------------