-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueuerun.m
129 lines (108 loc) · 2.77 KB
/
queuerun.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
% queuerun.m: wrapper for running a generic matlab program from
% the master queue
%
% basic flow:
% 1. figure out current queue id from enviroment (set by dbqueuemaster)
% 2. load up parameters from tQueue
% 3. execute parameters in tQueue(QUEUEID).parmsstring
%
% created SVD 6/7/03 -- ripped off of cellxcqueue
%
function queuerun(queueid)
[s,host]=unix('hostname');
if exist('narf_set_path','file'),
narf_set_path;
end
if exist('baphy_set_path','file'),
baphy_set_path;
else
addpath ~/code/baphy
baphy_set_path
end
dbopen;
global BATQUEUEID
if exist('queueid','var'),
BATQUEUEID=queueid;
else
BATQUEUEID=str2num(getenv('QUEUEID'));
end
QUEUEOUTPATH=getenv('QUEUEOUTPATH');
if isempty(QUEUEOUTPATH),
QUEUEOUTPATH='/tmp';
end
if isempty(BATQUEUEID),
disp('syntax error: cellxcmaster(queueid) parameter required');
disp(' or QUEUEID environment variable must be set');
return
end
% temporarily connect to NEMS db
r=dbGetConParms();
rtemp=r;
rtemp.DB_SERVER='hyrax.ohsu.edu:1234';
%dbSetConParms(rtemp);
queuedata=dbgetqueue(BATQUEUEID);
if isempty(queuedata)
fprintf('queue id=%d not found!\n',BATQUEUEID);
return
end
if ~isempty(findstr(lower(host),'seil.umd.edu')),
dbsetqueue(BATQUEUEID,1,-1);
end
% restore old db connection
dbSetConParms(r);
% for debugging
fprintf('QUEUEID=%d\n',BATQUEUEID);
fprintf('MYHOST=%s\n',getenv('MYHOST'));
eqi=strfind(queuedata.parmstring,'=');
opi=strfind(queuedata.parmstring,'(');
if isempty(eqi)
st=1;
else
st=eqi(1)+1;
end
if isempty(opi)
nd=length(queuedata.parmstring);
else
nd=opi-1;
end
try
fn_name = char(queuedata.parmstring(st:nd));
fn_loc=which(fn_name);
fn_loc_str=['from ',fn_loc,'\n'];
catch
fn_loc_str='';
end
% run the matlab commands specified in parmstring. presumably this
% takes care of all the output.
disp(['RUNNING: ' char(queuedata.parmstring)]);
fprintf(fn_loc_str)
eval(char(queuedata.parmstring));
% record that we're done with this queue entry
% (may've been cleared, so requery environment)
BATQUEUEID=str2num(getenv('QUEUEID'));
if isempty(findstr(lower(host),'seil.umd.edu')),
s=get(0,'Children');
s=s(s<=3);
figpath=sprintf('%s/%d',QUEUEOUTPATH,floor(BATQUEUEID/1000)*1000);
if ~exist(figpath,'dir'),
unix(['mkdir ',figpath]);
end
for ii=s(:)',
figure(ii);
fullpage portrait
print(['-f' num2str(ii)],'-djpeg','-r75',sprintf('%s/%d.%d.jpg',figpath,BATQUEUEID,ii));
end
end
global DB_SERVER BAPHY_LAB
if strcmpi(BAPHY_LAB,'lbhb'),
DB_SERVER='hyrax.ohsu.edu';
dbopen(1);
end
% temporarily connect to NEMS db
r=dbGetConParms();
rtemp=r;
rtemp.DB_SERVER='hyrax.ohsu.edu:1234';
%dbSetConParms(rtemp);
dbsetqueue(BATQUEUEID,1000,1);
% restore old db connection
dbSetConParms(r);