Consider removing absolute paths from `model.sh`
As part of testing exported models, I realized that model.sh files generated during export contain several absolute paths to the export directory. Ideally from my perspective, .sh files should avoid including absolute paths, e.g. so the entire export directory can be arbitrarily relocated (less any external path dependencies in the model).
A simplified export script might be something like the following, where the working directory would be controlled by the user / client code:
#!/bin/bash
./model.bin >> out 2>> err
if [ $? -eq 0 ]; then
echo success > finished
else
echo failure > finished
fi
The original motivation for the absolute paths was to make it easier to launch a detached process from Java. I'll check if there is a good way to do this without relying on the shell script to change directories.
Turns out that for remote jobs, it gets more complicated to handle paths when they're relative. Since this is not a high-priority issue, I am closing this as "won't fix".
Thank you for taking a look! I agree this isn't a priority since the solution is complicated.
While looking at this issue, a thought came to me on how to deal with the remote path issue. I'm reopening this, just to keep it on the TODO list.
The main issue with relative remote paths is how to transmit them through SSH. The current procedure is to convert them to absolute paths, then quote if needed. The part about converting to absolute path could be removed, as there isn't really a good way to do this. The current method is just a hack that is rarely actually used, and doesn't really work when it is used. Instead, paths will be transmitted exactly as is.
The remaining issue is that a relative path to an executable will generally fail. It is usually an immediate reference to an executable in the current working directory (CWD), but "." isn't necessarily in the search path. Rather than requiring the user to configure this, we should prepend a dot to the path. However, we shouldn't do that with every single relative path. The trick here is to extend Host.quote() to take a flag indicating whether to treat the path as an executable.