{ "cells": [ { "cell_type": "markdown", "id": "e61bc5e0fdea", "metadata": {}, "source": "# Async resources and durable jobs\n\nThis example requires SDK 0.7. Default execution uses synthetic transport, not an FM. Explicit live mode uses the qualified bounded classifier. Async calls and durable background jobs are different: await starts/waits for a request, while the job identity supports reconnect after local timeout/cancellation." }, { "cell_type": "code", "id": "cad39e42473a", "metadata": {}, "source": "from support import notebook_async_client, synthetic_table\ncolumns, train, labels, query = synthetic_table()", "outputs": [], "execution_count": null }, { "cell_type": "code", "id": "3342fa06b8a4", "metadata": {}, "source": "async with notebook_async_client() as client:\n model = next(m for m in await client.models() if m[\"id\"] == \"tabicl-v2\")\n assert model[\"status\"] == \"available\" and \"classification\" in model[\"tasks\"]\n dataset = await client.upload(columns=columns+[\"label\"], rows=[r.tolist()+[y] for r,y in zip(train,labels)], target=\"label\")\n job = await client.submit_fit(dataset[\"id\"], model=\"tabicl-v2\", task=\"classification\", seed=9)\n durable_id = job.id\n reconnected = client.job(durable_id) # factory is not awaited\n predictor = await reconnected.result(timeout=120)\n result = await client.predict(predictor[\"id\"], columns=columns, rows=query.tolist())\n assert len(result[\"predictions\"]) == 32\n assert result[\"model_version\"] == predictor[\"model_version\"]", "outputs": [], "execution_count": null }, { "cell_type": "markdown", "id": "bb18f4d2e001", "metadata": {}, "source": "The async context closes its HTTP client. Cancelling a local await or hitting a local wait deadline leaves durable work intact. Explicit await job.cancel() requests remote cancellation; subsequent result retrieval still requires current workspace authorization. GET-only bounded retries do not replay POST fits or uploads. Resumable files and true large batch APIs remain held; native causal async methods follow the released task contracts." } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }