File size: 2,268 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 46 47 48 49 50 51 | """Single released task-stream entry point."""
from copy import deepcopy
from rescopebench.case_validation import ReleasedCase
from .spec import CASE_DIR, DATA, DATA_TOOLS, DATA_TASKS, DATA__TARGET_IDS_BY_TASK, DATA_PROMPT, DATA_SCHEDULE
from .runtime import World
class Driver(ReleasedCase):
case_id = 'course_registration'
case_version = 'course-independent-placements-evolution-v3'
def __init__(self):
self.source = deepcopy(CASE_DIR / 'raw')
self.tools = deepcopy(DATA_TOOLS)
self.tasks = deepcopy(DATA_TASKS)
self._target_ids_by_task = deepcopy(DATA__TARGET_IDS_BY_TASK)
self.directory = deepcopy(DATA)
self.prompt = deepcopy(DATA_PROMPT)
self.lifecycle_schedule = deepcopy(DATA_SCHEDULE)
def create_world(self):
return World(self.source)
def begin(self, world, task):
receipt = world.prepare_episode(task['private_task_id'])
if receipt.get('event_id') != task['event_id']:
raise ValueError('actual boundary identity differs from the frozen public task')
return {'status': 'success', 'boundary': receipt}
def call(self, world, name, arguments):
return world.dispatch(name, arguments, 'operator-course-registration-dev')
def grade(self, world, task):
grade = world.grade(task['private_task_id'])
grade['completed_artifacts'] = grade.get('completed_artifacts', grade.get('complete_artifacts', 0))
actual_target_ids = {row.get('target_id') for row in grade.get('deliverables', [])}
if actual_target_ids != self._target_ids_by_task[task['private_task_id']]:
raise ValueError('grade target identities differ from the frozen public task')
return grade
def public_grade(self, grade):
components = {}
for row in grade['deliverables']:
for name in ('queue_custody', 'transition_committed', 'eligibility_verified', 'seat_credit_invariants_hold'):
components[row['target_id'] + ':' + name] = {'correct': int(row[name]), 'total': 1}
return {'score': grade['score'], 'public_components': components}
def close(self, world):
close = getattr(world, 'close', None)
if close is not None:
close()
|