File size: 1,655 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 | """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_PROMPT, DATA_SCHEDULE
from .runtime import fn_grade_task, fn_public_grade, World
class Driver(ReleasedCase):
case_id = 'k8s_operations'
case_version = 'k8s-namespace-migration-evolution-v6'
def __init__(self):
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):
return World(CASE_DIR / 'raw', in_memory=True)
def begin(self, world, task):
boundary = world.prepare_task(task['private_task_id'])
if boundary['public']['event_id'] != task['event_id']:
raise ValueError('frozen task and runtime event differ')
world._formal_entry = world.snapshot()
world._formal_eligible = world.eligible_nodes()
return {'status': 'success', **boundary}
def call(self, world, name, arguments):
return world.dispatch(name, arguments)
def grade(self, world, task):
if world.current_task_id != task['private_task_id']:
raise ValueError('Kubernetes grade task is not current')
return fn_grade_task(world.task(), world._formal_entry, world.snapshot(), world._formal_eligible)
def public_grade(self, grade):
return fn_public_grade(grade, [artifact['release_id'] for artifact in grade['artifacts']])
def close(self, world):
world.close()
|