<jupyter_start><jupyter_text>How `map` works in plain Python<jupyter_code>map(str.upper, ["San", "Diego", "Supercomputer", "Center"])
def process_job(filename):
    # to avoid importing functions better
    # define the function in a module and import it
    from time import sleep
    sleep(3)
    open(filename, 'w').close()
    return "Done " + filename
!rm out/*.dat
process_job("out/mytest.dat")
ls out/
filenames = ["out/%03d.dat" % (i) for i in range(200)]
print filenames<jupyter_output><empty_output><jupyter_text>Open console with:    `watch ls -C out/`<jupyter_code># block=True, waits for jobs to complete and return results
%time lview.map(process_job, filenames, block=True)
# default returns immediately, it is asynchronous
results = lview.map(process_job, filenames)
results.display_outputs()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12410501193317422, 'fraction_numerical': 0.007159904534606206, 'mean_word_length': 5.5546875, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '137891', 'license': 'MIT', 'n_tokens_mistral': 289, 'n_tokens_neox': 280, 'n_words': 79, 'path': 'SDSC-2016-Joyce-modified/hpc3_python_hpc/3_ipythonparallel.ipynb', 'repo_name': 'bjoyce3/SDSC_summer_institute_2016_Joyce', 'size': '838'}