fr31-probe.py
import sys,socket,json
from unittest.mock import patch
sys.path.insert(0,'src/cells/cell16')
def deny(*a,**k): raise AssertionError('offline network or Ray denied')
def absent(*a,**k): raise RuntimeError('fixture credentials absent')
with patch.object(socket.socket,'connect',deny), patch.object(socket,'getaddrinfo',deny):
from google.cloud import firestore,bigquery,logging
import ray
with patch.object(firestore,'AsyncClient',absent),patch.object(bigquery,'Client',absent),patch.object(logging,'Client',absent),patch.object(ray,'init',deny),patch.object(ray,'remote',deny),patch.dict('os.environ',{'RAY_CLUSTER_ADDRESS':''}):
import Cell16
from fastapi.testclient import TestClient
writes=[]
class Store:
def collection(self,*a): return self
def document(self,*a): return self
async def set(self,value): writes.append({'set':value['status']})
async def update(self,value): writes.append({'update':value['status']})
with TestClient(Cell16.app) as client:
Cell16.app.state.service._db=Store()
result=client.post('/tasks/send',json={'type':'cmd.kd.start_distillation_job.v1','payload':{'teacher_model_id':'fixture','student_model_architecture':{},'dataset_uri':'fixture://offline'}})
print(json.dumps({'status_code':result.status_code,'response_job_status':result.json().get('status'),'recorded_writes':writes,'ray_enabled':Cell16.CONFIG.ray_enabled,'ray_init_and_remote':'denied by fixture'}))