<jupyter_start><jupyter_text>How to call python functions using `CmdInterface`<jupyter_code>from cmdint import CmdInterface
from cmdint.Utils import ProgressBar
import time<jupyter_output><empty_output><jupyter_text>Create a dummy function to be executed using `CmdInterface`.<jupyter_code>def my_python_function(my_arg: str):
    for i in range(10):
        print(my_arg + ' ' + str(i))<jupyter_output><empty_output><jupyter_text>Another dummy with progress bar.<jupyter_code>def my_python_function_with_progress():
    bar = ProgressBar(10)
    for i in range(10):
        time.sleep(1)
        bar.next()<jupyter_output><empty_output><jupyter_text>Set output logfile and tell `CmdInterface` to delete a potentially present old logfile.<jupyter_code>CmdInterface.set_static_logfile('python_function_logging.json', delete_existing=True)<jupyter_output><empty_output><jupyter_text>Create instance of `CmdInterface` that calls the previously defined python function `my_python_function`.<jupyter_code>test_my_python_function = CmdInterface(my_python_function)
test_my_python_function.add_arg('my_arg', 'BLABLA')
test_my_python_function.run()<jupyter_output>Warning, repo /home/neher/cmdint/cmdint is dirty!
2019-02-05 09:13:48 >> my_python_function START
2019-02-05 09:13:48 >> my_python_function END<jupyter_text>Another call with our progress bar function. The progress bar in the output logfile is updated continuously, as is all other output.<jupyter_code>test_my_python_function_with_progress = CmdInterface(my_python_function_with_progress)
test_my_python_function_with_progress.run()
CmdInterface.anonymize_log(out_log_name='python_function_logging.json')<jupyter_output>Warning, repo /home/neher/cmdint/cmdint is dirty!
2019-02-05 09:14:58 >> my_python_function_with_progress START
2019-02-05 09:15:08 >> my_python_function_with_progress END
Anonymizing python_function_logging.json
{'fraction_non_alphanumeric': 0.08787718369507676, 'fraction_numerical': 0.03335097935415564, 'mean_word_length': 8.310344827586206, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 31, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '25091', 'license': 'Apache-2.0', 'n_tokens_mistral': 662, 'n_tokens_neox': 617, 'n_words': 123, 'path': 'examples/python_function_logging/python_function_logging.ipynb', 'repo_name': 'MIC-DKFZ/cmdint', 'size': '1889'}