Skip to content

Commit

Permalink
examples: add metric pull from mlflow for demo
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsextonMITRE committed Sep 10, 2024
1 parent a10da3e commit ff90623
Showing 1 changed file with 35 additions and 22 deletions.
57 changes: 35 additions & 22 deletions examples/v1-client-tensorflow-mnist-classifier/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 12,
"metadata": {
"tags": []
},
Expand All @@ -53,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -176,7 +176,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"metadata": {
"tags": []
},
Expand All @@ -194,9 +194,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"{'username': 'pluginuser', 'status': 'Login successful'}"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"try:\n",
" client.users.create('pluginuser','[email protected]','pleasemakesuretoPLUGINthecomputer','pleasemakesuretoPLUGINthecomputer')\n",
Expand All @@ -214,7 +225,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -252,7 +263,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 17,
"metadata": {
"scrolled": true,
"tags": []
Expand Down Expand Up @@ -492,7 +503,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -516,7 +527,7 @@
},
{
"cell_type": "code",
"execution_count": 130,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -544,7 +555,7 @@
},
{
"cell_type": "code",
"execution_count": 131,
"execution_count": 32,
"metadata": {
"scrolled": true
},
Expand Down Expand Up @@ -575,7 +586,7 @@
},
{
"cell_type": "code",
"execution_count": 132,
"execution_count": 21,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -613,7 +624,7 @@
},
{
"cell_type": "code",
"execution_count": 133,
"execution_count": 33,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -642,23 +653,25 @@
},
{
"cell_type": "code",
"execution_count": 139,
"execution_count": 31,
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'JobsClient' object has no attribute 'get_mlflow_run_id'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[139], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mclient\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mjobs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_mlflow_run_id\u001b[49m(infer_job[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mid\u001b[39m\u001b[38;5;124m'\u001b[39m])\n",
"\u001b[0;31mAttributeError\u001b[0m: 'JobsClient' object has no attribute 'get_mlflow_run_id'"
"name": "stdout",
"output_type": "stream",
"text": [
"bfac3e7023404ff6a6312ae8da2e0826\n",
"{'compile_metrics': 0.5866386294364929, 'loss': 0.9697718620300293}\n"
]
}
],
"source": [
"client.jobs.get_mlflow_run_id(infer_job['id'])"
"from mlflow.tracking import MlflowClient\n",
"mlflow_client = MlflowClient()\n",
"mlflow_runid = client.jobs.get_mlflow_run_id(infer_job['id'])['mlflowRunId'].replace('-','') # why\n",
"print(mlflow_runid)\n",
"mlflow_run = mlflow_client.get_run(mlflow_runid)\n",
"pprint.pprint(mlflow_run.data.metrics)"
]
},
{
Expand Down

0 comments on commit ff90623

Please sign in to comment.