File size: 1,837 Bytes
f726fd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""Single released task-stream entry point."""
from copy import deepcopy
from rescopebench.case_validation import ReleasedCase
from copy import deepcopy as ext_deepcopy
from .spec import CASE_DIR, DATA, DATA_INITIAL_SNAPSHOT, DATA_TOOLS, DATA_TASKS, DATA_PROMPT, DATA_SCHEDULE
from .runtime import World

class Driver(ReleasedCase):
    case_id = 'redcap'
    case_version = 'redcap-independent-packets-evolution-v3'

    def __init__(self):
        self.source = deepcopy(CASE_DIR / 'raw')
        self.initial_snapshot = deepcopy(DATA_INITIAL_SNAPSHOT)
        self.tools = deepcopy(DATA_TOOLS)
        self.tasks = deepcopy(DATA_TASKS)
        self.directory = deepcopy(DATA)
        self.prompt = deepcopy(DATA_PROMPT)
        self.lifecycle_schedule = deepcopy(DATA_SCHEDULE)

    def create_world(self):
        world = World(source_root=self.source)
        World._redcap_reusable_authority_restore(world, ext_deepcopy(self.initial_snapshot))
        return world

    def begin(self, world, task):
        receipt = world.activate_task(str(task['private_task_id']))
        if receipt['event_id'] != task['event_id']:
            raise ValueError('REDCap v7 boundary identity differs from frozen task')
        return {'status': 'success', 'boundary': receipt}

    def call(self, world, name, arguments):
        return world.dispatch(name, arguments, 'session-redcap-closeout-4x9')

    def grade(self, world, task):
        return world.grade(str(task['private_task_id']))

    def public_grade(self, grade):
        return {'score': grade['score'], 'public_components': {f'artifact_{index}': {'correct': int(bool(row['complete'])), 'total': 1} for (index, row) in enumerate(grade['deliverables'], 1)}}

    def close(self, world):
        close = getattr(world, 'close', None)
        if callable(close):
            close()