Difference between revisions of "Statistical Algorithms Importer: StatusUpdate"
From Gcube Wiki
(→Updating the status of a process) |
(→Python example) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 11: | Line 11: | ||
=== Python example === | === Python example === | ||
− | For example, the following Python script writes a local | + | For example, the following Python script writes a local status.txt file indicating its internal status. |
<source lang = "python"> | <source lang = "python"> | ||
.... | .... | ||
− | def updateStatus( | + | def updateStatus(perc): |
with open('status.txt','w') as st: | with open('status.txt','w') as st: | ||
st.write(perc) | st.write(perc) | ||
Line 22: | Line 22: | ||
.... | .... | ||
updateStatus('20') | updateStatus('20') | ||
− | + | doJob1() | |
+ | updateStatus('60') | ||
+ | doJob2() | ||
updateStatus('90') | updateStatus('90') | ||
Line 29: | Line 31: | ||
=== R example === | === R example === | ||
− | For example, the following R script writes a local | + | For example, the following R script writes a local status.txt file indicating its internal status. |
<source lang = "java"> | <source lang = "java"> |
Latest revision as of 14:20, 22 June 2021
- This page explains how to update the status of a process from a SAI-integrated algorithm.
Updating the status of a process
It is sufficient to write a file named "status.txt" locally to the process indicating a number from 20 to 90. The DataMiner will transform this information into a WPS status, also visible through the status bar of the DataMiner GUI. The algorithm's status is always forced to 100 by DataMiner at the end of the computation.
Python example
For example, the following Python script writes a local status.txt file indicating its internal status.
.... def updateStatus(perc): with open('status.txt','w') as st: st.write(perc) .... updateStatus('20') doJob1() updateStatus('60') doJob2() updateStatus('90')
R example
For example, the following R script writes a local status.txt file indicating its internal status.
nseconds <- 60 nsteps = nseconds/10 for (i in 1:nsteps){ status = i*100/nsteps cat("Status",status,"\n") write(status,file="status.txt") Sys.sleep(1) } output="test.txt" write(nseconds,file=output)