Following on from my previous question which relates to a different problem, I thought I would frame in terms of this problem.
NOTE: I have tried all versions of subprocess.Popen()
, communicate()
, wait()
, such as:
vowpal = subprocess.Popen('../../vowpal.sh',shell=True, stdout=subprocess.PIPE)
vowpal.communicate()
print vowpal.returncode
I have a file structure like this:
├── src
│ ├── main
│ │ ├── costSensitiveClassifier.py
└── vowpal.sh
|
├── data
│ ├── output
│ │ ├── cost
| | |_______openCostClassifier.dat
| | |
And within costSensitiveClassifier.py
, I essentially am trying to run a script called vowpal.sh
that does some manipulations on openCostClassifer.dat
and outputs some files into the same folder as that file.
The code within costSensitiveClassifier.py is:
import subprocess
print "Starting cost sensitive predictions using batch script\n"
subprocess.call("../../vowpal.sh")
print "Ending predictions"
And the code within vowpal.sh is:
# !/bin/bash
vw --csoaa 24 data/output/cost/openCostClassifier.dat -f data/output/cost/csoaa.model
vw -t -i data/output/cost/csoaa.model data/output/cost/openCostClassifier.dat -p data/output/cost/csoaa.predict
The issue is always that the second line of the bash script needs there to be something called csoaa.model
to be output first (see line 1 of the bash script), and once finished, the second line should run which uses that file to output csoaa.predict
. However, this is not the case and I get when running the python file I get in my error code related to the bash script:
vw (./io_buf.h:123): can't open: data/output/cost/csoaa.modelerrno = No such file or directory
I found this link but not sure if it is what I need (should I adapt the sleep to be the expected time for the bash script to finish and create the files I need to work on?).