SIENTIAPDE-1174
SIENTIAPDE-1174 Update tests.ipynb to normalize counter and rollout values, and fix MLFlowRepository initialization error - Changed execution_count for a cell to null for consistency. - Updated normalization logic for counter and rollout values to scale between -100 and 100. - Fixed TypeError in MLFlowRepository initialization by ensuring the logger argument is provided.
This commit is contained in:
28
tests.ipynb
28
tests.ipynb
@@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": null,
|
||||
"id": "b10e5c25",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -142,9 +142,9 @@
|
||||
" counter[i] = counter[i-1] + counter_steps[i-1]\n",
|
||||
" rollout[i] = rollout[i-1] + rollout_steps[i-1]\n",
|
||||
"\n",
|
||||
"# if any of the values is greater than 100, set it to 100\n",
|
||||
"counter = np.where(counter > 100, 100, counter)\n",
|
||||
"rollout = np.where(rollout > 100, 100, rollout)\n",
|
||||
"# normalize values between -100 and 100, lowest value is -100, highest value is 100\n",
|
||||
"counter = (counter - min(counter)) / (max(counter) - min(counter)) * 200 - 100\n",
|
||||
"rollout = (rollout - min(rollout)) / (max(rollout) - min(rollout)) * 200 - 100\n",
|
||||
"\n",
|
||||
"# Create DataFrame\n",
|
||||
"df = pd.DataFrame({\n",
|
||||
@@ -165,27 +165,19 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 2,
|
||||
"id": "e7c8eeb1",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "RestException",
|
||||
"evalue": "RESOURCE_DOES_NOT_EXIST: Run with id=1 not found",
|
||||
"ename": "TypeError",
|
||||
"evalue": "MLFlowRepository.__init__() missing 1 required positional argument: 'logger'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
||||
"\u001b[31mRestException\u001b[39m Traceback (most recent call last)",
|
||||
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[7]\u001b[39m\u001b[32m, line 9\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mlaborious\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mutils\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mrepository\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mmodel_repository\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m MLFlowRepository\n\u001b[32m 3\u001b[39m mlflow_repository = MLFlowRepository(\n\u001b[32m 4\u001b[39m host=\u001b[33m\"\u001b[39m\u001b[33mhttp://localhost:5080/\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 5\u001b[39m username=\u001b[33m\"\u001b[39m\u001b[33maignosi\u001b[39m\u001b[33m\"\u001b[39m,\n\u001b[32m 6\u001b[39m password=\u001b[33m\"\u001b[39m\u001b[33maignosi\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 7\u001b[39m )\n\u001b[32m----> \u001b[39m\u001b[32m9\u001b[39m \u001b[43mmlflow_repository\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_experiment_by_run_id\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m1\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
|
||||
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/projects/sientia/sientia-dataops-laborious_temporal/laborious/utils/repository/model_repository.py:93\u001b[39m, in \u001b[36mMLFlowRepository.get_experiment_by_run_id\u001b[39m\u001b[34m(self, run_id)\u001b[39m\n\u001b[32m 91\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mget_experiment_by_run_id\u001b[39m(\u001b[38;5;28mself\u001b[39m, run_id: \u001b[38;5;28mstr\u001b[39m) -> \u001b[38;5;28mdict\u001b[39m:\n\u001b[32m 92\u001b[39m \u001b[38;5;66;03m# Get the run information using the run_id\u001b[39;00m\n\u001b[32m---> \u001b[39m\u001b[32m93\u001b[39m run = \u001b[43mmlflow\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_run\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrun_id\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 95\u001b[39m \u001b[38;5;66;03m# Extract the experiment ID from the run\u001b[39;00m\n\u001b[32m 96\u001b[39m experiment_id = run.info.experiment_id\n",
|
||||
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/projects/sientia/sientia-dataops-laborious_temporal/venv/lib/python3.11/site-packages/mlflow/tracking/fluent.py:580\u001b[39m, in \u001b[36mget_run\u001b[39m\u001b[34m(run_id)\u001b[39m\n\u001b[32m 546\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mget_run\u001b[39m(run_id: \u001b[38;5;28mstr\u001b[39m) -> Run:\n\u001b[32m 547\u001b[39m \u001b[38;5;250m \u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 548\u001b[39m \u001b[33;03m Fetch the run from backend store. The resulting :py:class:`Run <mlflow.entities.Run>`\u001b[39;00m\n\u001b[32m 549\u001b[39m \u001b[33;03m contains a collection of run metadata -- :py:class:`RunInfo <mlflow.entities.RunInfo>`,\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 578\u001b[39m \u001b[33;03m run_id: 7472befefc754e388e8e922824a0cca5; lifecycle_stage: active\u001b[39;00m\n\u001b[32m 579\u001b[39m \u001b[33;03m \"\"\"\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m580\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mMlflowClient\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_run\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrun_id\u001b[49m\u001b[43m)\u001b[49m\n",
|
||||
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/projects/sientia/sientia-dataops-laborious_temporal/venv/lib/python3.11/site-packages/mlflow/tracking/client.py:179\u001b[39m, in \u001b[36mMlflowClient.get_run\u001b[39m\u001b[34m(self, run_id)\u001b[39m\n\u001b[32m 139\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mget_run\u001b[39m(\u001b[38;5;28mself\u001b[39m, run_id: \u001b[38;5;28mstr\u001b[39m) -> Run:\n\u001b[32m 140\u001b[39m \u001b[38;5;250m \u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 141\u001b[39m \u001b[33;03m Fetch the run from backend store. The resulting :py:class:`Run <mlflow.entities.Run>`\u001b[39;00m\n\u001b[32m 142\u001b[39m \u001b[33;03m contains a collection of run metadata -- :py:class:`RunInfo <mlflow.entities.RunInfo>`,\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 177\u001b[39m \u001b[33;03m status: FINISHED\u001b[39;00m\n\u001b[32m 178\u001b[39m \u001b[33;03m \"\"\"\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m179\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_tracking_client\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_run\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrun_id\u001b[49m\u001b[43m)\u001b[49m\n",
|
||||
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/projects/sientia/sientia-dataops-laborious_temporal/venv/lib/python3.11/site-packages/mlflow/tracking/_tracking_service/client.py:73\u001b[39m, in \u001b[36mTrackingServiceClient.get_run\u001b[39m\u001b[34m(self, run_id)\u001b[39m\n\u001b[32m 59\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 60\u001b[39m \u001b[33;03mFetch the run from backend store. The resulting :py:class:`Run <mlflow.entities.Run>`\u001b[39;00m\n\u001b[32m 61\u001b[39m \u001b[33;03mcontains a collection of run metadata -- :py:class:`RunInfo <mlflow.entities.RunInfo>`,\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 70\u001b[39m \u001b[33;03m raises an exception.\u001b[39;00m\n\u001b[32m 71\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 72\u001b[39m _validate_run_id(run_id)\n\u001b[32m---> \u001b[39m\u001b[32m73\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mstore\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_run\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrun_id\u001b[49m\u001b[43m)\u001b[49m\n",
|
||||
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/projects/sientia/sientia-dataops-laborious_temporal/venv/lib/python3.11/site-packages/mlflow/store/tracking/rest_store.py:137\u001b[39m, in \u001b[36mRestStore.get_run\u001b[39m\u001b[34m(self, run_id)\u001b[39m\n\u001b[32m 129\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 130\u001b[39m \u001b[33;03mFetch the run from backend store\u001b[39;00m\n\u001b[32m 131\u001b[39m \n\u001b[32m (...)\u001b[39m\u001b[32m 134\u001b[39m \u001b[33;03m:return: A single Run object if it exists, otherwise raises an Exception\u001b[39;00m\n\u001b[32m 135\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 136\u001b[39m req_body = message_to_json(GetRun(run_uuid=run_id, run_id=run_id))\n\u001b[32m--> \u001b[39m\u001b[32m137\u001b[39m response_proto = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_call_endpoint\u001b[49m\u001b[43m(\u001b[49m\u001b[43mGetRun\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mreq_body\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 138\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m Run.from_proto(response_proto.run)\n",
|
||||
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/projects/sientia/sientia-dataops-laborious_temporal/venv/lib/python3.11/site-packages/mlflow/store/tracking/rest_store.py:59\u001b[39m, in \u001b[36mRestStore._call_endpoint\u001b[39m\u001b[34m(self, api, json_body)\u001b[39m\n\u001b[32m 57\u001b[39m endpoint, method = _METHOD_TO_INFO[api]\n\u001b[32m 58\u001b[39m response_proto = api.Response()\n\u001b[32m---> \u001b[39m\u001b[32m59\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcall_endpoint\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mget_host_creds\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mendpoint\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mjson_body\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mresponse_proto\u001b[49m\u001b[43m)\u001b[49m\n",
|
||||
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/projects/sientia/sientia-dataops-laborious_temporal/venv/lib/python3.11/site-packages/mlflow/utils/rest_utils.py:220\u001b[39m, in \u001b[36mcall_endpoint\u001b[39m\u001b[34m(host_creds, endpoint, method, json_body, response_proto, extra_headers)\u001b[39m\n\u001b[32m 218\u001b[39m call_kwargs[\u001b[33m\"\u001b[39m\u001b[33mjson\u001b[39m\u001b[33m\"\u001b[39m] = json_body\n\u001b[32m 219\u001b[39m response = http_request(**call_kwargs)\n\u001b[32m--> \u001b[39m\u001b[32m220\u001b[39m response = \u001b[43mverify_rest_response\u001b[49m\u001b[43m(\u001b[49m\u001b[43mresponse\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mendpoint\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 221\u001b[39m js_dict = json.loads(response.text)\n\u001b[32m 222\u001b[39m parse_dict(js_dict=js_dict, message=response_proto)\n",
|
||||
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/projects/sientia/sientia-dataops-laborious_temporal/venv/lib/python3.11/site-packages/mlflow/utils/rest_utils.py:152\u001b[39m, in \u001b[36mverify_rest_response\u001b[39m\u001b[34m(response, endpoint)\u001b[39m\n\u001b[32m 150\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m response.status_code != \u001b[32m200\u001b[39m:\n\u001b[32m 151\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m _can_parse_as_json_object(response.text):\n\u001b[32m--> \u001b[39m\u001b[32m152\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m RestException(json.loads(response.text))\n\u001b[32m 153\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m 154\u001b[39m base_msg = (\n\u001b[32m 155\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mAPI request to endpoint \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mendpoint\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 156\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mfailed with error code \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse.status_code\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m != 200\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 157\u001b[39m )\n",
|
||||
"\u001b[31mRestException\u001b[39m: RESOURCE_DOES_NOT_EXIST: Run with id=1 not found"
|
||||
"\u001b[31mTypeError\u001b[39m Traceback (most recent call last)",
|
||||
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mlaborious\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mutils\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mrepository\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mmodel_repository\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m MLFlowRepository\n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m mlflow_repository = \u001b[43mMLFlowRepository\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 4\u001b[39m \u001b[43m \u001b[49m\u001b[43mhost\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mhttp://localhost:5080/\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 5\u001b[39m \u001b[43m \u001b[49m\u001b[43musername\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43maignosi\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 6\u001b[39m \u001b[43m \u001b[49m\u001b[43mpassword\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43maignosi\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\n\u001b[32m 7\u001b[39m \u001b[43m)\u001b[49m\n\u001b[32m 9\u001b[39m mlflow_repository.get_experiment_by_run_id(\u001b[33m\"\u001b[39m\u001b[33m1\u001b[39m\u001b[33m\"\u001b[39m)\n",
|
||||
"\u001b[31mTypeError\u001b[39m: MLFlowRepository.__init__() missing 1 required positional argument: 'logger'"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user