<commit_before>from drivnal.constants import *
from drivnal.client import Client
from drivnal.task import Task
from drivnal.event import Event
import drivnal.utils as utils
from drivnal import server
import os
import flask
import time

@server.app.route('/task/<volume_id>', methods=['GET'])
def task_get(volume_id):
    client = Client()
    volume = client.get_volume(volume_id)

    if not volume:
        return utils.jsonify({
            'error': VOLUME_NOT_FOUND,
            'error_msg': VOLUME_NOT_FOUND_MSG,
        }, 404)

    tasks = []

    for task in reversed(volume.get_tasks()):
        task_data = {
            'id': task.id,
            'volume': volume.id,
            'volume_name': volume.name,
            'type': task.type,
            'state': task.state,
            'time': task.time,
            'has_log': False,
        }

        if task.snapshot_id:
            task_data['snapshot_id'] = task.snapshot_id

        tasks.append(task_data)

    return utils.jsonify(tasks)

@server.app.route('/task/<volume_id>/<task_id>', methods=['PUT'])
def task_put(volume_id, task_id):
    client = Client()<commit_msg>Add log to tasks with available snapshot logs<commit_after>from drivnal.constants import *
from drivnal.client import Client
from drivnal.task import Task
from drivnal.event import Event
import drivnal.utils as utils
from drivnal import server
import os
import flask
import time

@server.app.route('/task/<volume_id>', methods=['GET'])
def task_get(volume_id):
    client = Client()
    volume = client.get_volume(volume_id)

    if not volume:
        return utils.jsonify({
            'error': VOLUME_NOT_FOUND,
            'error_msg': VOLUME_NOT_FOUND_MSG,
        }, 404)

    tasks = []

    for task in reversed(volume.get_tasks()):
        task_data = {
            'id': task.id,
            'volume': volume.id,
            'volume_name': volume.name,
            'type': task.type,
            'state': task.state,
            'time': task.time,
            'has_log': False,
        }

        if task.snapshot_id:
            snapshot = volume.get_snapshot(task.snapshot_id)
            if snapshot and os.path.isfile(snapshot.log_path):
                task_data['has_log'] = True
            task_data['snapshot_id'] = task.snapshot_id

        tasks.append(task_data)

    return utils.jsonify(tasks)

@server.app.route('/task/<volume_id>/<task_id>', methods=['PUT'])
def task_put(volume_id, task_id):
    client = Client()
{'fraction_non_alphanumeric': 0.11774193548387096, 'fraction_numerical': 0.0024193548387096775, 'mean_word_length': 2.509193776520509, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4591839', 'n_tokens_mistral': 779, 'n_tokens_neox': 779, 'n_words': 176}