<jupyter_start><jupyter_text>Sample code for connecting to CAS using the SWAT package<jupyter_code>import os
import swat<jupyter_output><empty_output><jupyter_text>There are two ways of connecting to CAS: * using REST API calls or * using a SAS-native binary protocol.The binary protocol is faster. *Note*: we're using the internal Kubernetes service name of the CAS pod for connecting. We can do that because both ends (CAS and Jupyter) are running as pods inside the Kubernetes cluster. Thus we can use a "shortcut" and our communication stays inside the cluster. As full TLS is enabled you need to upload the ca_cert.pem and set it to an environment variable CAS_CLIENT_SSL_CA_LIST.<jupyter_code>os.environ['CAS_CLIENT_SSL_CA_LIST'] = 'ca_cert.pem'
sess=swat.CAS('sas-cas-server-default-client', 5570, 'viya_admin', '<<PASSWORD>>')
sess.serverStatus()
sess.terminate()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08102108768035517, 'fraction_numerical': 0.004439511653718091, 'mean_word_length': 6.216, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '169385', 'license': 'Apache-2.0', 'n_tokens_mistral': 290, 'n_tokens_neox': 275, 'n_words': 105, 'path': 'SWAT-CAS-Connection-NoteBooks/JupHub-Python-CAS_Connection.ipynb', 'repo_name': 'sascommunities/hackinsas-2021', 'size': '904'}