<commit_before>import os
import uuid
import time
import json

from flask import Flask

app = Flask(__name__)
app.debug = True

def check(endpoint):
    def actual_check(function):
        start_time = time.time()
        ret = function()
        total_time = time.time() - start_time
        return json.dumps({
            'status': ret,
            'time': total_time
        })
    return app.route(endpoint)(actual_check)


@check('/nfs/home')
def nfs_home_check():
    content = str(uuid.uuid4())
    path = os.path.join('/data/project/canary/nfs-test/', content)
    try:
        with open(path, 'w') as f:
            f.write(content)

        with open(path) as f:
            actual_content = f.read()

        if actual_content == content:<commit_msg>Use a decorator to wrap the actual checks<commit_after>import os
import uuid
import time
import json

from flask import Flask

app = Flask(__name__)
app.debug = True


def check(endpoint):
    def actual_decorator(func):
        def actual_check():
            start_time = time.time()
            try:
                ret = func()
            except:
                # FIXME: log this error somewhere
                ret = False
            total_time = time.time() - start_time
            return json.dumps({
                'status': ret,
                'time': total_time
            })
        return app.route(endpoint)(actual_check)
    return actual_decorator


@check('/nfs/home')
def nfs_home_check():
    content = str(uuid.uuid4())
    path = os.path.join('/data/project/canary/nfs-test/', content)
    try:
        with open(path, 'w') as f:
            f.write(content)

        with open(path) as f:
            actual_content = f.read()

        if actual_content == content:
{'fraction_non_alphanumeric': 0.11060433295324971, 'fraction_numerical': 0.0011402508551881414, 'mean_word_length': 2.015463917525773, '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': '5139738', 'n_tokens_mistral': 530, 'n_tokens_neox': 520, 'n_words': 137}