Читать книгу SAS Viya - Kevin D. Smith - Страница 31

Resolving CAS Action Parameter Problems

Оглавление

CAS action parameter problems can come in many forms: invalid parameter names, invalid parameter values, incorrect nesting of parameter lists, and so on. It can sometimes be difficult to immediately identify the problem. We provide you with some tips in this section that hopefully simplify your correction of CAS action parameter errors.

Let’s start with an action call that creates a parameter error. We haven’t covered the actions being used in this example, but you don’t need to know what they do in order to see what the error is and how to fix it.

In [65]: out = conn.summary(table=dict(name='test',

....: groupby=['var1', 'var2', 3]))

ERROR: An attempt was made to convert parameter 'table.groupby[2]' from int64 to parameter list, but the conversion failed.

ERROR: The action stopped due to errors.

In the preceding action call, we see that we get an error concerning table.groupby[2]. When you start building parameter structures that are deeply nested, it can be difficult to see exactly what element the message refers to. One of the best tools to track down the error is the cas.trace_actions option. We haven’t reached the section on setting SWAT options, but you can simply submit the following code in order to enable this option:

In [66]: swat.set_option('cas.trace_actions', True)

With this option enabled, we see all of the actions and action parameters printed out in a form that matches the error message from the server. Let’s run the summary action from In[65] again.

In [67]: out = conn.summary(table=dict(name='test',

....: groupby=['var1', 'var2', 3]))

[simple.summary]

table.groupby[0] = "var1" (string)

table.groupby[1] = "var2" (string)

table.groupby[2] = 3 (int64)

table.name = "test" (string)

ERROR: An attempt was made to convert parameter 'table.groupby[2]' from int64 to parameter list, but the conversion failed.

ERROR: The action stopped due to errors.

This time we can see from the printed output that table.groupby[2] is the value 3. According to the definition of the summary action, those values must be strings, so that is the source of the error. We can now go into our action call and change the 3 to the proper value.

If you still do not see the problem, it might be a good idea to separate the parameter construction from the action call as we saw in the section on specifying action parameters. Let’s build the action parameters, one at a time, including the erroneous value.

In [68]: params = swat.vl()

In [69]: params.table.name = 'test'

In [70]: params.table.groupby[0] = 'var1'

In [71]: params.table.groupby[1] = 'var2'

In [72]: params.table.groupby[2] = 3

In [73]: out = conn.summary(**params)

[simple.summary]

table.groupby[0] = "var1" (string)

table.groupby[1] = "var2" (string)

table.groupby[2] = 3 (int64)

table.name = "test" (string)

ERROR: An attempt was made to convert parameter 'table.groupby[2]' from int64 to parameter list, but the conversion failed.

ERROR: The action stopped due to errors.

Of course, in this case the error is pretty obvious since we entered it in a line by itself. But you have parameters that are built in programmatic ways that might not be so obvious. Now our parameters are held in an object that has a syntax that maps perfectly to the output that is created by the cas.trace_actions option as well as the error message from the server. When we see this error message, we can simply display it directly from the params variable to see what the problem is and correct it.

In [74]: params.table.groupby[2]

Out[74]: 3

In [75]: params.table.groupby[2] = 'var3'

Now let’s move on to the remaining class of errors.

SAS Viya

Подняться наверх