<commit_before>
import os
import subprocess
from kokki import *

class ArrayProvider(Provider):
    def action_create(self):
        if not os.path.exists(self.resource.name):
            subprocess.check_call(["/sbin/mdadm",
                    "--create", self.resource.name,
                    "-R",
                    "-c", str(self.resource.chunksize),
                    "--level", str(self.resource.level),
                    "--metadata", self.resource.metadata,
                    "--raid-devices", str(len(self.resource.devices)),
                ] + self.resource.devices)
            self.resource.updated()
    
    def action_stop(self):
        if os.path.exists(self.resource.name):
            subprocess.check_call(["/sbin/mdadm",
                    "--stop", self.resource.name])
            self.resource.updated()

    def action_assemble(self):
        if not os.path.exists(self.resource.name):
            subprocess.check_call(["/sbin/mdadm",
                    "--assemble", self.resource.name,
                ] + self.resource.devices)
            self.resource.updated()
<commit_msg>Wait for expected state of array in mdadm<commit_after>
import os
import subprocess
import time
from kokki import *

class ArrayProvider(Provider):
    def action_create(self):
        if not os.path.exists(self.resource.name):
            subprocess.check_call(["/sbin/mdadm",
                    "--create", self.resource.name,
                    "-R",
                    "-c", str(self.resource.chunksize),
                    "--level", str(self.resource.level),
                    "--metadata", self.resource.metadata,
                    "--raid-devices", str(len(self.resource.devices)),
                ] + self.resource.devices)
            self.wait_for_array(True)
            self.resource.updated()
    
    def action_stop(self):
        if os.path.exists(self.resource.name):
            subprocess.check_call(["/sbin/mdadm",
                    "--stop", self.resource.name])
            self.wait_for_array(False)
            self.resource.updated()

    def action_assemble(self):
        if not os.path.exists(self.resource.name):
            subprocess.check_call(["/sbin/mdadm",
                    "--assemble", self.resource.name,
                ] + self.resource.devices)
            self.wait_for_array(True)
            self.resource.updated()

    def wait_for_array(self, exists):
        for i in range(10):
            if exists == os.path.exists(self.resource.name):
                break
            time.sleep(0.5)

{'fraction_non_alphanumeric': 0.1295215869311552, 'fraction_numerical': 0.0015558148580318942, 'mean_word_length': 1.6735966735966736, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6977046', 'n_tokens_mistral': 726, 'n_tokens_neox': 689, 'n_words': 118}