<jupyter_start><jupyter_text>An example Jupyter notebook for parallel programming<jupyter_code>import ipyparallel

# attach to a running cluster
cluster = ipyparallel.Client(profile='janus-cpu')
print('profile:', cluster.profile)
print("IDs:", cluster.ids) # Print process id numbers
# The %px magic executes a single Python command on
# the engines specified by the targets attribute of
# the DirectView instance.
#
# http://ipython.org/ipython-doc/stable/parallel/magics.html#px
%px import socket
%px print("hosts:", socket.gethostname())

# calculate square numbers in parallel. Print result.
squares = cluster[:].map_sync(lambda x: x**2, range(32))
print("squares:", squares)<jupyter_output>[stdout:0] hosts: cnode0114.rc.int.colorado.edu
[stdout:1] hosts: cnode0114.rc.int.colorado.edu
[stdout:2] hosts: cnode0114.rc.int.colorado.edu
[stdout:3] hosts: cnode0114.rc.int.colorado.edu
squares: [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961]
{'fraction_non_alphanumeric': 0.14299424184261036, 'fraction_numerical': 0.10076775431861804, 'mean_word_length': 5.7727272727272725, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '34639', 'license': 'MIT', 'n_tokens_mistral': 458, 'n_tokens_neox': 365, 'n_words': 108, 'path': 'Deployment/Parallel.ipynb', 'repo_name': 'rctraining/2016-XSEDE-Tutorial-on-JupyterHub', 'size': '1042'}