<commit_before>#!/usr/bin/env python

import nbx.client as client
import urllib2
import urllib

def list_sessions(cl):
    cl.list_sessions()

def attach_session(cl, target):
    cl._list_sessions()
    cl.attach(target)

def cd_to_cwd(cl, target):
    cl._list_sessions()
    return cl.kernel_path(target)

def main():
    import argparse
    import os
    parser = argparse.ArgumentParser(description="");

    parser.add_argument('action', nargs="?", action="store", default=None)
    parser.add_argument('target', nargs="?", action="store")
    parser.add_argument('--host', default="127.0.0.1")
    parser.add_argument('--port', default="8888")

    args = parser.parse_args()

    host = args.host
    port = args.port
    target = args.target
    action = args.action
    cwd = os.getcwd()

    cl = client.client(host, port)

    if not action and not target:
        action = 'list'

    if action in ['list']:
        list_sessions(cl)

    if action in ['attach']:
        attach_session(cl, target)

    if action in ['cd']:
        import pipes
        print cd_to_cwd(cl, target)

if __name__ == '__main__':
    main()
<commit_msg>renamed cd to pwd since we can't cd within a subprocess<commit_after>#!/usr/bin/env python

import nbx.client as client
import urllib2
import urllib

def list_sessions(cl):
    cl.list_sessions()

def attach_session(cl, target):
    cl._list_sessions()
    cl.attach(target)

def kernel_pwd(cl, target):
    cl._list_sessions()
    return cl.kernel_path(target)

def main():
    import argparse
    import os
    parser = argparse.ArgumentParser(description="");

    parser.add_argument('action', nargs="?", action="store", default=None)
    parser.add_argument('target', nargs="?", action="store")
    parser.add_argument('--host', default="127.0.0.1")
    parser.add_argument('--port', default="8888")

    args = parser.parse_args()

    host = args.host
    port = args.port
    target = args.target
    action = args.action
    cwd = os.getcwd()

    cl = client.client(host, port)

    if not action and not target:
        action = 'list'

    if action in ['list']:
        list_sessions(cl)

    if action in ['attach']:
        attach_session(cl, target)

    if action in ['pwd']:
        import pipes
        print kernel_pwd(cl, target)

if __name__ == '__main__':
    main()

{'fraction_non_alphanumeric': 0.1340471092077088, 'fraction_numerical': 0.009421841541755889, 'mean_word_length': 3.119929453262787, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7007406', 'n_tokens_mistral': 805, 'n_tokens_neox': 769, 'n_words': 190}