Hi,
I am trying to use a keras model in my package, and it works fine within rstudio.
However, when trying to call via the API, I get the following error
IOError: Unable to open file (unable to flock file, errno = 13, error message = 'Permission denied')
On checking the logs, I can see this is most likely linked with the AppArmor profile:
root@ip-20-80-40-101:~# sudo tail -f /var/log/kern.log | grep opencpu
gives:
Jan 27 23:54:20 ip-20-80-40-101 kernel: [2019126.246477] audit: type=1400 audit(1548613460.154:168): apparmor="DENIED" operation="unlink" profile="opencpu-exec" name="/usr/local/lib/R/site-library/reticulate/python/rpytools/__init__.pyc" pid=14756 comm="apache2" requested_mask="d" denied_mask="d" fsuid=33 ouid=0
Jan 27 23:54:20 ip-20-80-40-101 kernel: [2019126.246633] audit: type=1400 audit(1548613460.154:169): apparmor="DENIED" operation="unlink" profile="opencpu-exec" name="/usr/local/lib/R/site-library/reticulate/python/rpytools/call.pyc" pid=14756 comm="apache2" requested_mask="d" denied_mask="d" fsuid=33 ouid=0
Jan 27 23:54:20 ip-20-80-40-101 kernel: [2019126.248382] audit: type=1400 audit(1548613460.154:170): apparmor="DENIED" operation="unlink" profile="opencpu-exec" name="/usr/local/lib/R/site-library/reticulate/python/rpytools/output.pyc" pid=14756 comm="apache2" requested_mask="d" denied_mask="d" fsuid=33 ouid=0
Jan 27 23:54:20 ip-20-80-40-101 kernel: [2019126.992518] audit: type=1400 audit(1548613460.898:171): apparmor="DENIED" operation="file_lock" profile="opencpu-exec" name="/tmp/ocpu-temp/x01b782204d9bd7/keras_model39a43a999ab6.h5" pid=14756 comm="apache2" requested_mask="k" denied_mask="k" fsuid=33 ouid=33
In my package, I have the model stored in data/ folder, and I load it in the onLoad function
.onLoad <- function(lib, pkg) {
# something to run
utils::data(recipeObject, package = pkg, envir = parent.env(environment()))
utils::data(serializedModel, package = pkg, envir = parent.env(environment()))
}
I do not have any experience with AppArmor profiles, and would be great if someone could get me started.
How exactly should I go about this?
Thanks in advance,
/Debajyoti