Palantir Foundry may run multiple compute sessions that require exclusive worker allocations. Implement a session manager that assigns the smallest available worker IDs when a session starts and returns its allocation later.
Create a SessionManager class with these methods:
start_session(session_id, units): Allocate exactly units currently free workers to session_id. Return True if successful. If the session already exists or insufficient workers are available, make no changes and return False.get_allocation(session_id): Return the worker IDs assigned to the session in ascending order. Return None if the session does not exist.Also implement run_session_manager(capacity, operations) for evaluation. capacity is the number of workers, identified by integers from 0 through capacity - 1. Each operation is a dictionary with op equal to "start" or "get". A start operation includes session_id and units; a get operation includes session_id. Return one result per operation, using the return value of the corresponding method.
op = "start" or op = "get"def run_session_manager(capacity, operations):