Skip to content

Commit 525a203

Browse files
author
Jon Walker
authored
Merge pull request #18 from jameskochubasas/master
CAS python score code generation
2 parents 003d375 + 2a6ad7b commit 525a203

File tree

3 files changed

+21
-32
lines changed

3 files changed

+21
-32
lines changed

src/sasctl/tasks.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ def register_model(model, name, project, repository=None, input=None,
159159
files.append({'name': 'dmcas_espscorecode.sas',
160160
'file': mas_module.score_code(dest='ESP'),
161161
'role': 'Score Code'})
162+
files.append({'name': 'dmcas_epscorecode.sas',
163+
'file': mas_module.score_code(dest='CAS'),
164+
'role': 'score'})
162165

163166
model['inputVariables'] = [var.as_model_metadata()
164167
for var in mas_module.variables

src/sasctl/utils/pymas/core.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -373,20 +373,16 @@ def score_code(self, input_table=None, output_table=None, columns=None, dest='MA
373373
' end;',
374374
'enddata;')
375375
elif dest == 'CAS':
376-
if input_table is None:
377-
raise ValueError('An input table must be specified when executing the code in CAS.')
378-
379-
output_table = output_table or input_table + '_pymas'
380376
thread = DS2Thread(self.variables, input_table, column_names=columns, return_message=self.return_message,
381377
package=self.package)
382378

383379
code += (str(thread),
384-
' data {} (overwrite=yes);'.format(output_table),
385-
' dcl thread {} t;'.format(thread.name),
386-
' method run();',
387-
' set from t;',
388-
' output {} ;'.format(output_table),
389-
' end;',
390-
' enddata;')
391-
392-
return '\n'.join(code)
380+
'data SASEP.out;',
381+
' dcl thread {} t;'.format(thread.name),
382+
' method run();',
383+
' set from t;',
384+
' output;',
385+
' end;',
386+
'enddata;')
387+
388+
return '\n'.join(code)

src/sasctl/utils/pymas/ds2.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,6 @@ def name(self):
252252
return 'pyMasThread'
253253

254254
def __str__(self):
255-
extras = ['"rc"'] if self.return_code else []
256-
extras += ['"msg"'] if self.return_message else []
257-
258255
array_input = any([v.is_array for v in self.variables if not v.out])
259256

260257
# If passing column data into Python as an array, need extra assignment statements to set values
@@ -272,25 +269,18 @@ def __str__(self):
272269
declarations = '\n'.join([v.as_declaration() for v in self.variables if
273270
v.out or v.is_array])
274271

275-
keep_vars = [v.name for v in self.variables] + extras
272+
keep_vars = [v.name for v in self.variables]
276273

277-
code = (" thread {} / inline;".format(self.name),
278-
" dcl package {} decisionPackage();".format(
279-
self.package.name),
274+
code = ("thread {} / inline;".format(self.name),
275+
" dcl package {} pythonPackage();".format(self.package.name),
280276
declarations,
281-
' dcl double "rc";',
282-
" dcl char(4096) character set utf8 msg;",
283-
# " keep {};".format(' '.join(keep_vars)),
284-
" method run();",
285-
" dcl integer localRC;",
286-
" set {} ( );".format(self.table),
277+
" method run();",
278+
" set SASEP.in;",
287279
var_assignments,
288-
" decisionPackage.{}({});".format(
289-
self.package.methods[0].name,
290-
','.join(keep_vars)),
291-
" output;",
292-
" end;",
293-
" endthread;")
280+
" pythonPackage.{}({});".format(self.package.methods[0].name,','.join(keep_vars)),
281+
" output;",
282+
" end;",
283+
"endthread;")
294284

295285
code = '\n'.join(code)
296286

0 commit comments

Comments
 (0)