<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import requests
import time
from koheron_tcp_client import KClient

def install_instrument(host, instrument_name, always_restart=False):
    if not always_restart:
        # Don't restart the instrument if already launched
        current_instrument = requests.get('http://{}/api/instruments/current'.format(host)).json()
        if current_instrument['name'] == instrument_name:
            return

    instruments = requests.get('http://{}/api/instruments/local'.format(host)).json()
    if instruments:
        for name, shas in instruments.items():
            if name == instrument_name and len(shas) > 0:
                r = requests.get('http://{}/api/instruments/run/{}/{}'.format(host, name, shas[0]))
                if int(r.text.split('status:')[1].strip()) < 0:
                    raise RuntimeError("Instrument " + instrument_name + " launch failed.")
                return
    raise ValueError("Instrument " + instrument_name + " not found")

def load_instrument(host, instrument='oscillo'):
    install_instrument(host, instrument)
    client = KClient(host)
    return client
<commit_msg>update api<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import requests
import time
from koheron_tcp_client import KClient

def install_instrument(host, instrument_name, always_restart=False):
    if not always_restart:
        # Don't restart the instrument if already launched
        current_instrument = requests.get('http://{}/api/instruments/live'.format(host)).json()
        if current_instrument['name'] == instrument_name:
            return

    instruments = requests.get('http://{}/api/instruments/local'.format(host)).json()
    if instruments:
        for name, shas in instruments.items():
            if name == instrument_name and len(shas) > 0:
                r = requests.get('http://{}/api/instruments/run/{}/{}'.format(host, name, shas[0]))
                if int(r.text.split('status:')[1].strip()) < 0:
                    raise RuntimeError("Instrument " + instrument_name + " launch failed.")
                return
    raise ValueError("Instrument " + instrument_name + " not found")

def load_instrument(host, instrument='oscillo'):
    install_instrument(host, instrument)
    client = KClient(host)
    return client

{'fraction_non_alphanumeric': 0.13550600343053174, 'fraction_numerical': 0.004288164665523156, 'mean_word_length': 3.036332179930796, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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}}
{'dir': 'git-commits-cleaned', 'id': '5292511', 'n_tokens_mistral': 666, 'n_tokens_neox': 651, 'n_words': 149}