webMethods

 View Only
Expand all | Collapse all

Deploying Python Script as a flow service in wM IS

  • 1.  Deploying Python Script as a flow service in wM IS

    Posted Mon July 31, 2023 06:17 AM

    Hi all

    We are developing an optimization script in Python while having some resources limitation, so we don’t have a resource to host this optimization service.

    Is there a way to host this python script as a flow service at the integration server?


    #webMethods
    #Integration-Server
    #Python


  • 2.  RE: Deploying Python Script as a flow service in wM IS

    Posted Mon July 31, 2023 06:36 AM

    You can’t run it inside java, but you could call it via a java service e.g.

    String run = "cmd /c python duplicatetestingoriginal.py" ;
    
    boolean isCreated = fwr.writeFile(BugFile, GD, 500, true, 5, "LET");
    
    if(isCreated){
    try{
    r = Runtime.getRuntime();
    p = r.exec(run);
    BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
    BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
    
    String line = "";
    while ((line = stdInput.readLine()) != null) {
    System.out.println(line);
    }
    while ((line = stdError.readLine()) != null) {
    errorW.write(line);
    }
    
    int exitVal = p.waitFor();
    arrayList = fwr.readResults();
    }catch(Exception e){
    
    }
    }
    else{
    // troubleshoot....
    
    }
    

    or you could try rewriting it into a java service e.g.


    #Python
    #webMethods
    #Integration-Server


  • 3.  RE: Deploying Python Script as a flow service in wM IS

    Posted Fri August 11, 2023 11:12 PM

    Out of curiocity - what usecase are you trying to solve?


    #webMethods
    #Python
    #Integration-Server


  • 4.  RE: Deploying Python Script as a flow service in wM IS

    Posted Tue September 05, 2023 05:22 AM

    We have a BPM implementation.

    In one of the processes we need to do some optimization logic, which we developed a python script to do and wanted to host this python script as a flow service.


    #Integration-Server
    #Python
    #webMethods


  • 5.  RE: Deploying Python Script as a flow service in wM IS

    Posted Tue September 05, 2023 08:45 AM

    A question.
    Would it make sense to create an API in Python that runs the script based on input and returns output? It would need to run as a separate process and then invoke the API over HTTP/S from IS/BPM.

    Compared to embeding it into the code you may find API approahc more elegent. Plus API code can be updated without having to change BPM.

    It may take you more effort upfront, but will keep solution flexible.


    #Python
    #webMethods
    #Integration-Server


  • 6.  RE: Deploying Python Script as a flow service in wM IS

    Posted Tue September 05, 2023 09:55 AM

    Exactly,

    This is what we are doing currently, but we were trying to host it within IS as we have some infrastructure resources limitations and didn’t prefer to run other applications on the same machine hosting the IS

    Best regards,
    Mohammed Alshehri


    #Integration-Server
    #webMethods
    #Python