Execution Order seems not to work. Any wait neccessary...?

thomas_wiedmannthomas_wiedmann Member Posts: 60 Guru
edited November 2018 in Help

Execution Order seems not to work after "Execute Program". "Execute Program" (PHP Script inside) do two things. I have added a "sleep(1)" at the end of the PHP Script (wait 1 second). But this has no effect.

 

<?php
// echo 'start php';

$aData = array();
$sData = null;

$sData = file_get_contents('M:/Scannen-AS/rapidminer-php-input.csv');
$aData = explode(PHP_EOL,$sData);

asort($aData);

$sData = implode(PHP_EOL,$aData);
// fwrite(STDOUT, $sData);

file_put_contents('M:/Scannen-AS/rapidminer-php-output.csv',$sData);

sleep(1);

?>

 

 

a) read a files and reorder it

b) write a new file with the ordered data

 

After this "Load File" give me an Error. But the missing file exist. If I run the process a second time (without delete the work files directory) the process seems to work.

 

RapidMiner.JPG

 

Pic. Working file directory

RapidMiner2.JPG

 

Any help?

 

Thanks!

Thomas

 

 

Tagged:

Best Answer

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,503 RM Data Scientist
    Solution Accepted

    Hi @thomas_wiedmann,

    as a side node. I can recommend the Delay and the Subprocess operators to enforce execution order.

     

    Best,

    Martin

    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany

Answers

  • Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn

    Ok, I think this is related to a path issue. 

     

    Windows has this type of directory structure M:\Path\to\file, whereas the error is saying it can't find M:/Path/to/file. Does the file reside on a windows machine but it's pathed differently?

  • thomas_wiedmannthomas_wiedmann Member Posts: 60 Guru

    @Thomas_Ott

     

    Okay, I will check this again, but like I wrote. If I run the process a second time "Open File" found the "old" file (rapidminer-php-output.csv) without any change of directory separator "\" or "/" . So I think, this is not the reason...

     

    Thanks!

    Thomas

  • thomas_wiedmannthomas_wiedmann Member Posts: 60 Guru

    Ok, I have chanced "\" to "/" inside the "Open File". But I get the same error

     

    RapidMiner3.JPG

     

    RapidMiner change "../.../.." to "..\...\.." inside the error message.

     

    Thanks!

    Thomas

     

  • Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn

    Hmm, that is interesting. So if you opened the saved file and try and run it, it crashes. The second time you run it, it works? If that's the case, it might be a bug of sorts. 

  • thomas_wiedmannthomas_wiedmann Member Posts: 60 Guru

    Hi @Thomas_Ott

     

    If I locked the "old" rapidminer-php-output.csv the PHP Script inside "Execute Programm" can't write.

     

    Thanks!

    Thomas

     

  • Edin_KlapicEdin_Klapic Moderator, Employee, RMResearcher, Member Posts: 299 RM Data Scientist

    Hi @thomas_wiedmann,

     

    Attached is a screenshot what @mschmitz was talking about.

    This way you can omit 'sleep' in your PHP script. The Delay value is in ms. And by moving Open File and Read CSV into a Subprocess you can easily enforce the execution order.

     

    Hope this helps,

    Edinimage.png

     

  • thomas_wiedmannthomas_wiedmann Member Posts: 60 Guru

    @Thomas_Ott

    @mschmitz

     

    Yes, this seems to work, I will check how long the shortes "Delay" is neccessary

     

    RapidMiner3.jpg

     

    Thanks!

    Thomas

  • Edin_KlapicEdin_Klapic Moderator, Employee, RMResearcher, Member Posts: 299 RM Data Scientist

    Hi @thomas_wiedmann,

     

    is there any reason why you have a subprocess *and* Open file & Read CSV?
    The proposed solution uses the Subprocess Operator only because it has an input port and therefore can be connected.

     

    Best,

    Edin

     

  • thomas_wiedmannthomas_wiedmann Member Posts: 60 Guru

    @Edin_Klapic

     

    Yes, I found no way get the piped data inside PHP like described here:

    https://community.rapidminer.com/t5/Getting-Started-Forum/Looking-for-a-sample-to-execute-PHP-using-Execute-Program/m-p/46575#M1850

     

    So I decide to use real files to pipe data thru "Execute Program" (PHP Script). PHP found no data on STDIN and waits forever.

    Maybe I make a mistake using PIPE, but I did'nt found it.

     

    rem --- rapidminer-start-php.bat ---
    d:
    cd d:\wiedmann\tools\php-5.6.13-Win32-VC11-x86
    php rapidminer.php
    exit
    <?php
    // echo 'start php';

    $aData = array();
    $sData = null;

    while($f = fgets(STDIN)){
    $aData = $f;
    }

    $sData = implode(PHP_EOL,$aData);
    file_put_contents('M:/Scannen-AS/rapidminer-php-log-input.csv',$sData);

    asort($aData);

    $sData = implode(PHP_EOL,$aData);
    file_put_contents('M:/Scannen-AS/rapidminer-php-log-output.csv',$sData);

    fwrite(STDOUT, $sData);

    // echo 'end php';

    ?>

    Regards,

    Thomas

Sign In or Register to comment.