| 173 | spec = datamodel_pb2.SandboxSpec(policy=_baseline_policy()) |
| 174 | |
| 175 | def call_models() -> str: |
| 176 | import ssl |
| 177 | import urllib.request |
| 178 | |
| 179 | ctx = ssl.create_default_context() |
| 180 | ctx.check_hostname = False |
| 181 | ctx.verify_mode = ssl.CERT_NONE |
| 182 | |
| 183 | req = urllib.request.Request("https://inference.local/v1/models", method="GET") |
| 184 | resp = urllib.request.urlopen(req, timeout=30, context=ctx) |
| 185 | return resp.read().decode() |
| 186 | |
| 187 | with sandbox(spec=spec, delete_on_exit=True) as sb: |
| 188 | result = sb.exec_python(call_models, timeout_seconds=60) |