SAS Viya. Kevin D. Smith

Чтение книги онлайн.

Читать онлайн книгу SAS Viya - Kevin D. Smith страница 8

Автор:
Жанр:
Серия:
Издательство:
SAS Viya - Kevin D. Smith

Скачать книгу

Loads an action set in new sessions ...

      6 log Shows and modifies logging levels

      7 queryActionSet Shows whether an action set is loaded

      8 queryName Checks whether a name is an action o...

      9 reflect Shows detailed parameter information...

      10 serverStatus Shows the status of the server

      11 about Shows the status of the server

      12 shutdown Shuts down the server

      13 userInfo Shows the user information for your ...

      14 actionSetInfo Shows the build information from loa...

      15 history Shows the actions that were run in t...

      16 casCommon Provides parameters that are common ...

      17 ping Sends a single request to the server...

      18 echo Prints the supplied parameters to th...

      19 modifyQueue Modifies the action response queue s...

      20 getLicenseInfo Shows the license information for a ...

      21 refreshLicense Refresh SAS license information from...

      22 httpAddress Shows the HTTP address for the serve...

      The keys are commonly alphanumeric, so the CASResults object was extended to enable you to access keys as attributes as well. This just keeps your code a bit cleaner. However, you should be aware that if a result key has the same name as a Python dictionary method, the dictionary method takes precedence. In the following code, we access the builtins key again, but this time we access it as if it were an attribute.

      In [7]: out.builtins

       Out[7]:

      name description

      0 addNode Adds a machine to the server

      1 removeNode Remove one or more machines from the...

      2 help Shows the parameters for an action o...

      3 listNodes Shows the host names used by the server

      4 loadActionSet Loads an action set for use in this ...

      5 installActionSet Loads an action set in new sessions ...

      6 log Shows and modifies logging levels

      7 queryActionSet Shows whether an action set is loaded

      8 queryName Checks whether a name is an action o...

      9 reflect Shows detailed parameter information...

      10 serverStatus Shows the status of the server

      11 about Shows the status of the server

      12 shutdown Shuts down the server

      13 userInfo Shows the user information for your ...

      14 actionSetInfo Shows the build information from loa...

      15 history Shows the actions that were run in t...

      16 casCommon Provides parameters that are common ...

      17 ping Sends a single request to the server...

      18 echo Prints the supplied parameters to th...

      19 modifyQueue Modifies the action response queue s...

      20 getLicenseInfo Shows the license information for a ...

      21 refreshLicense Refresh SAS license information from...

      22 httpAddress Shows the HTTP address for the serve...

      Just like the help action, all of the action sets and actions are available as attributes and methods on the CAS connection object. For example, the userinfo action is called as follows.

      In [8]: conn.userinfo()

       Out[8]:

      [userInfo]

      {'anonymous': False,

      'groups': ['users'],

      'hostAccount': True,

      'providedName': 'username',

      'providerName': 'Active Directory',

      'uniqueId': 'username',

      'userId': 'username'}

      + Elapsed: 0.000291s, mem: 0.0826mb

      The result this time is a CASResults object, the contents of which is a dictionary under a single key (userInfo) that contains information about your user account. Although all actions return a CASResults object, there are no strict rules about what keys and values are in that object. The returned values are determined by the action and vary depending on the type of information returned. Analytic actions typically return one or more DataFrames. If you aren’t using IPython to format your results automatically, you can cast the result to a dictionary and then print it using pprint for a nicer representation.

      In [9]: from pprint import pprint

      In [10]: pprint(dict(conn.userinfo()))

      {'userInfo': {'anonymous': False,

      'groups': ['users'],

      'hostAccount': True,

      'providedName': 'username',

      'providerName': 'Active Directory',

      'uniqueId': 'username',

      'userId': 'username'}}

      When calling the help and userinfo actions, we actually used a shortcut. In some cases, you might need to specify the fully qualified name of the action, which includes the action set name. This can happen if two action sets have an action of the same name, or an action name collides with an existing method or attribute name on the CAS object. The userinfo action is contained in the builtins action set. To call it using the fully qualified name, you use builtins.userinfo rather than userinfo on the CAS object. The builtins level in this call corresponds to a CASActionSet object that contains all of the actions in the builtins action set.

      In [11]: conn.builtins.userinfo()

      The preceding code provides you with the same result as the previous example does.

Скачать книгу