Data360 Analyze

 View Only
  • 1.  How to install python module MONTHDELTA

    Posted 01-25-2021 15:37

    Hi,

    In the transform node i need to modify a date with x number of months. The function datetime.timeadjust does not do the trick since you can only alter the date with a number of days, not taking into account the actual number of days in a specific month.

    In my search to find a suitable alternative i came across the module MONTHDELTA. Can anyone help me with how to install this module? I am aware that the D360 provides guidance on how to install "full python" modules. Trying this results in an error and gives the message "the system cannot find the requested file"

    Thank you in advance! 



  • 2.  RE: How to install python module MONTHDELTA

    Employee
    Posted 01-26-2021 03:07

    You can use the attached data flow to install the MonthDelta package into the /<site>/lib/jython2 directory. This location is on the system default search paths for Jython-based nodes (e.g. Transform, Generate Data). Note that only 'pure' python modules can be used with these nodes.

    After importing the prerequisite packages, the node constructs the path to the jython2 directory and uses this to define an argument for the pip install command. 

    A function is defined to perform the required package installation.This uses the subprocess function to execute the installation in a new system process. 

    Next, we specify the name of the package to be in installed (this is case sensitive). Note only 'pure' Python packages can be used with Jython-based nodes. Packages written in other languages (e.g. C++) cannot be used.

    The install() function is then invoked to perform the installation using pip. Note that internet access is required for pip to download the required package, and any prerequisite packages. The output metadata is then defined.

    The results of the install process are output by the ProcessRecords script. 

    Note that, in the case where the installation fails, only limited (or no) information may be output by the sub-process that attempted the installation. 

     

    Attached files

    Install_MonthDelta_Package_in_Default_Repo_Using_pip_in_Transform_Node - 26 Jan 2021.lna

     



  • 3.  RE: How to install python module MONTHDELTA

    Posted 01-26-2021 03:51

    Hi Adrian,

    Thank you very much for your quick response and solution. I works like a charm!

    This same flow can be used for importing other modules as well I understand?

    Mark



  • 4.  RE: How to install python module MONTHDELTA

    Employee
    Posted 01-26-2021 04:34

    The data flow can be used to import other packages. However, it may not work for all packages - for instance if the package defined by the 'package' variable in the script is pure python but it requires dependent packages which are written in C++ ; or if the package installs files to locations outside of the jython2 directory (e.g. the parent directory).



  • 5.  RE: How to install python module MONTHDELTA

    Posted 01-27-2021 03:36

    Can confirm we've been using a similar process successfully with boto3 for a while, thanks again Adrian for your help getting us that solution (https://support.infogix.com/hc/en-us/community/posts/360050775114).