"""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()