{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Downloading...\n", "From: https://drive.google.com/uc?id=1H8RHsrgYMd6VC23_OJqrN6o_mL78pWpx\n", "To: e:\\projects\\Bioma-AI\\1-time-series-forecasting\\trend_prediction_app\\trend-prediction-ml\\trend-prediction-pipeline\\collected-news.zip\n", "100%|██████████| 520k/520k [00:02<00:00, 241kB/s]\n" ] }, { "data": { "text/plain": [ "'collected-news.zip'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import gdown\n", "\n", "url = 'https://drive.google.com/uc?id=1H8RHsrgYMd6VC23_OJqrN6o_mL78pWpx'\n", "output = 'collected-news.zip'\n", "gdown.download(url, output, quiet=False)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import pyarrow.csv as pv\n", "import pyarrow.parquet as pq\n", "\n", "filename = 'data/2week_news_data.csv'\n", "\n", "table = pv.read_csv(filename)\n", "pq.write_table(table, filename.replace('csv', 'parquet'))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'E:\\\\projects\\\\Bioma-AI\\\\time-series-forecasting\\\\trend_prediction_app\\\\trend-prediction-ml\\\\trend-prediction-pipeline\\\\data\\\\2week_news_data.csv'" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import os\n", "\n", "dirName = r\"E:\\projects\\Bioma-AI\\time-series-forecasting\\trend_prediction_app\\trend-prediction-ml\\trend-prediction-pipeline\\data\"\n", "fn = [f for f in os.listdir(dirName)\\\n", " if f.endswith('.csv') and os.path.isfile(os.path.join(dirName, f))][0]\n", "path = os.path.join(dirName, fn)\n", "path" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'E:\\\\projects\\\\Bioma-AI\\x01-time-series-forecasting\\trend_prediction_app\\trend-prediction-ml\\trend-prediction-pipeline\\\\data'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def to_raw(string):\n", " return fr\"{string}\"\n", "\n", "dirName = to_raw(\"E:\\projects\\Bioma-AI\\1-time-series-forecasting\\trend_prediction_app\\trend-prediction-ml\\trend-prediction-pipeline\\data\")\n", "\n", "dirName = dirName.replace(\"file:///\", \"\")\n", "\n", "dirName\n", "\n", "dirName = rf\"{dirName}\"\n", "\n", "dirName" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'E:\\\\projects\\\\Bioma-AI\\\\time-series-forecasting\\\\trend_prediction_app\\\\trend-prediction-ml\\\\trend-prediction-pipeline\\\\data\\\\2week_news_data.csv'" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dirName = r\"file:///E:\\projects\\Bioma-AI\\time-series-forecasting\\trend_prediction_app\\trend-prediction-ml\\trend-prediction-pipeline\\data\"\n", "\n", "dirName = dirName.replace(\"file:///\", \"\")\n", "\n", "fn = [f for f in os.listdir(dirName)\\\n", " if f.endswith('.csv') and os.path.isfile(os.path.join(dirName, f))][0]\n", "path = os.path.join(dirName, fn)\n", "path" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ " # r = requests.get(url, stream=True)\n", " # with open(local_filename, \"wb\") as f:\n", " # for chunk in r.iter_content(chunk_size=1024):\n", " # if chunk: # filter out keep-alive new chunks\n", " # f.write(chunk)\n", "\n", " # data_csv = fr\"{data_csv}\"\n", " # print(data_csv)\n", " # dirName = data_csv.replace(\"file:///\", \"\")\n", "\n", " # fn = [f for f in os.listdir(dirName)\\\n", " # if f.endswith('.csv') and os.path.isfile(os.path.join(dirName, f))][0]\n", " # data_csv_file = os.path.join(dirName, fn)\n", "\n", " # table = pa.csv.read_csv(data_csv)\n", " # pa.parquet.write_table(table, data_csv.replace('csv', 'parquet'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## SQLite" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "## Delete Data\n", "\n", "import sqlite3\n", "\n", "try:\n", " with sqlite3.connect('my.db') as conn:\n", " cur = conn.cursor()\n", " delete_stmt = 'DELETE FROM mlruns.db WHERE id = ?'\n", " cur.execute(delete_stmt, (1,))\n", " conn.commit()\n", "except sqlite3.Error as e:\n", " print(e)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "no such table: mlruns.db\n" ] } ], "source": [ "# Select Data\n", "\n", "import sqlite3\n", "\n", "try:\n", " with sqlite3.connect(r'E:\\Projects\\Bioma-AI\\time-series-forecasting\\trend_prediction_app\\trend-prediction-ml\\trend-prediction-pipeline\\mlruns.db') as conn:\n", " cur = conn.cursor()\n", " delete_stmt = 'SELECT * FROM mlruns.db'\n", " cur.execute(delete_stmt, (1,))\n", " conn.commit()\n", "except sqlite3.Error as e:\n", " print(e)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "('e1dd6f53468a43ab8ae216ecd6d00f9b', 'fun-pug-865', 'UNKNOWN', '', '', 'mryan', 'FINISHED', 1725156717665, 1725156717711, '', 'deleted', 'file:///E:/Projects/Bioma-AI/time-series-forecasting/trend_prediction_app/trend-prediction-ml/trend-prediction-pipeline/mlruns/0/e1dd6f53468a43ab8ae216ecd6d00f9b/artifacts', 0, 1725157415352)\n", "('19b0aa8dfd4d43babf1722241eac4d11', 'amazing-flea-532', 'UNKNOWN', '', '', 'mryan', 'FINISHED', 1725156844490, 1725156844527, '', 'deleted', 'file:///E:/Projects/Bioma-AI/time-series-forecasting/trend_prediction_app/trend-prediction-ml/trend-prediction-pipeline/mlruns/0/19b0aa8dfd4d43babf1722241eac4d11/artifacts', 0, 1725157415338)\n", "('e8fb896431de4e37a188ae039901a502', 'rumbling-penguin-621', 'UNKNOWN', '', '', 'mryan', 'FINISHED', 1725157265761, 1725157265802, '', 'deleted', 'file:///E:/Projects/Bioma-AI/time-series-forecasting/trend_prediction_app/trend-prediction-ml/trend-prediction-pipeline/mlruns/0/e8fb896431de4e37a188ae039901a502/artifacts', 0, 1725157415321)\n", "('4efbf5256ae34e6296a00238accfdc9f', 'trusting-doe-440', 'UNKNOWN', '', '', 'mryan', 'FINISHED', 1725157268161, 1725157268196, '', 'deleted', 'file:///E:/Projects/Bioma-AI/time-series-forecasting/trend_prediction_app/trend-prediction-ml/trend-prediction-pipeline/mlruns/0/4efbf5256ae34e6296a00238accfdc9f/artifacts', 0, 1725157415324)\n", "('b0c0116c1805431a953bb8c07c184de9', 'popular-slug-621', 'UNKNOWN', '', '', 'mryan', 'FINISHED', 1725157437890, 1725157437931, '', 'active', 'file:///E:/Projects/Bioma-AI/time-series-forecasting/trend_prediction_app/trend-prediction-ml/trend-prediction-pipeline/mlruns/0/b0c0116c1805431a953bb8c07c184de9/artifacts', 0, None)\n" ] } ], "source": [ "import mlflow\n", "import sqlite3\n", "\n", "# Log some data with MLflow\n", "mlflow.set_tracking_uri(\"sqlite:///mlruns.db\")\n", "\n", "with mlflow.start_run():\n", " mlflow.log_param(\"param1\", 5)\n", " mlflow.log_metric(\"metric1\", 0.1)\n", "\n", "# Query the SQLite database\n", "try:\n", " db_path = r'E:\\Projects\\Bioma-AI\\time-series-forecasting\\trend_prediction_app\\trend-prediction-ml\\trend-prediction-pipeline\\mlruns.db'\n", " with sqlite3.connect(db_path) as conn:\n", " cur = conn.cursor()\n", " \n", " # Example query to fetch all runs\n", " select_stmt = 'SELECT * FROM runs'\n", " cur.execute(select_stmt)\n", " rows = cur.fetchall()\n", " \n", " for row in rows:\n", " print(row)\n", "\n", "except sqlite3.Error as e:\n", " print(f\"SQLite error: {e}\")\n", "except Exception as e:\n", " print(f\"General error: {e}\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Tables in database: [('experiments',), ('alembic_version',), ('experiment_tags',), ('tags',), ('registered_models',), ('runs',), ('registered_model_tags',), ('model_version_tags',), ('model_versions',), ('latest_metrics',), ('metrics',), ('registered_model_aliases',), ('datasets',), ('inputs',), ('input_tags',), ('params',), ('trace_info',), ('trace_tags',), ('trace_request_metadata',)]\n" ] } ], "source": [ "import sqlite3\n", "\n", "db_path = r\"E:\\Projects\\Bioma-AI\\time-series-forecasting\\trend_prediction_app\\trend-prediction-ml\\trend-prediction-pipeline\\mlruns.db\"\n", "\n", "try:\n", " conn = sqlite3.connect(db_path)\n", " cursor = conn.cursor()\n", " cursor.execute(\"SELECT name FROM sqlite_master WHERE type='table';\")\n", " tables = cursor.fetchall()\n", " print(\"Tables in database:\", tables)\n", "except sqlite3.Error as e:\n", " print(f\"SQLite error: {e}\")\n", "finally:\n", " conn.close()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Run ID: a930976208fa4fb48dbbf5cf4d7f600f\n" ] } ], "source": [ "import mlflow\n", "\n", "# Use a new SQLite database file\n", "new_db_path = r\"E:\\Projects\\Bioma-AI\\time-series-forecasting\\trend_prediction_app\\trend-prediction-ml\\trend-prediction-pipeline\\new_mlruns.db\"\n", "mlflow.set_tracking_uri(f\"sqlite:///{new_db_path}\")\n", "\n", "with mlflow.start_run() as run:\n", " mlflow.log_param(\"param1\", \"test\")\n", " print(f\"Run ID: {run.info.run_id}\")\n", "\n", "# Check if the run is properly logged\n", "client = mlflow.tracking.MlflowClient()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "ename": "MlflowException", "evalue": "Run with id=a930976208fa4fb48dbbf5cf4d7f600f not found", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mMlflowException\u001b[0m Traceback (most recent call last)", "Cell \u001b[1;32mIn[7], line 12\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[38;5;66;03m# Get run information using the run ID\u001b[39;00m\n\u001b[0;32m 11\u001b[0m run_id \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124ma930976208fa4fb48dbbf5cf4d7f600f\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m---> 12\u001b[0m run \u001b[38;5;241m=\u001b[39m \u001b[43mclient\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_run\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrun_id\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 13\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRun ID: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mrun\u001b[38;5;241m.\u001b[39minfo\u001b[38;5;241m.\u001b[39mrun_id\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 14\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRun Status: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mrun\u001b[38;5;241m.\u001b[39minfo\u001b[38;5;241m.\u001b[39mstatus\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", "File \u001b[1;32me:\\VM\\miniconda3\\envs\\mlops\\lib\\site-packages\\mlflow\\tracking\\client.py:226\u001b[0m, in \u001b[0;36mMlflowClient.get_run\u001b[1;34m(self, run_id)\u001b[0m\n\u001b[0;32m 182\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mget_run\u001b[39m(\u001b[38;5;28mself\u001b[39m, run_id: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Run:\n\u001b[0;32m 183\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 184\u001b[0m \u001b[38;5;124;03m Fetch the run from backend store. The resulting :py:class:`Run `\u001b[39;00m\n\u001b[0;32m 185\u001b[0m \u001b[38;5;124;03m contains a collection of run metadata -- :py:class:`RunInfo `,\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 224\u001b[0m \n\u001b[0;32m 225\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m--> 226\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_tracking_client\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_run\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrun_id\u001b[49m\u001b[43m)\u001b[49m\n", "File \u001b[1;32me:\\VM\\miniconda3\\envs\\mlops\\lib\\site-packages\\mlflow\\tracking\\_tracking_service\\client.py:104\u001b[0m, in \u001b[0;36mTrackingServiceClient.get_run\u001b[1;34m(self, run_id)\u001b[0m\n\u001b[0;32m 88\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Fetch the run from backend store. The resulting :py:class:`Run `\u001b[39;00m\n\u001b[0;32m 89\u001b[0m \u001b[38;5;124;03mcontains a collection of run metadata -- :py:class:`RunInfo `,\u001b[39;00m\n\u001b[0;32m 90\u001b[0m \u001b[38;5;124;03mas well as a collection of run parameters, tags, and metrics --\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 101\u001b[0m \n\u001b[0;32m 102\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 103\u001b[0m _validate_run_id(run_id)\n\u001b[1;32m--> 104\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstore\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_run\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrun_id\u001b[49m\u001b[43m)\u001b[49m\n", "File \u001b[1;32me:\\VM\\miniconda3\\envs\\mlops\\lib\\site-packages\\mlflow\\store\\tracking\\sqlalchemy_store.py:640\u001b[0m, in \u001b[0;36mSqlAlchemyStore.get_run\u001b[1;34m(self, run_id)\u001b[0m\n\u001b[0;32m 634\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mget_run\u001b[39m(\u001b[38;5;28mself\u001b[39m, run_id):\n\u001b[0;32m 635\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mManagedSessionMaker() \u001b[38;5;28;01mas\u001b[39;00m session:\n\u001b[0;32m 636\u001b[0m \u001b[38;5;66;03m# Load the run with the specified id and eagerly load its summary metrics, params, and\u001b[39;00m\n\u001b[0;32m 637\u001b[0m \u001b[38;5;66;03m# tags. These attributes are referenced during the invocation of\u001b[39;00m\n\u001b[0;32m 638\u001b[0m \u001b[38;5;66;03m# ``run.to_mlflow_entity()``, so eager loading helps avoid additional database queries\u001b[39;00m\n\u001b[0;32m 639\u001b[0m \u001b[38;5;66;03m# that are otherwise executed at attribute access time under a lazy loading model.\u001b[39;00m\n\u001b[1;32m--> 640\u001b[0m run \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_run\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrun_uuid\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrun_id\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msession\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msession\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43meager\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[0;32m 641\u001b[0m mlflow_run \u001b[38;5;241m=\u001b[39m run\u001b[38;5;241m.\u001b[39mto_mlflow_entity()\n\u001b[0;32m 642\u001b[0m \u001b[38;5;66;03m# Get the run inputs and add to the run\u001b[39;00m\n", "File \u001b[1;32me:\\VM\\miniconda3\\envs\\mlops\\lib\\site-packages\\mlflow\\store\\tracking\\sqlalchemy_store.py:524\u001b[0m, in \u001b[0;36mSqlAlchemyStore._get_run\u001b[1;34m(self, session, run_uuid, eager)\u001b[0m\n\u001b[0;32m 519\u001b[0m runs \u001b[38;5;241m=\u001b[39m (\n\u001b[0;32m 520\u001b[0m session\u001b[38;5;241m.\u001b[39mquery(SqlRun)\u001b[38;5;241m.\u001b[39moptions(\u001b[38;5;241m*\u001b[39mquery_options)\u001b[38;5;241m.\u001b[39mfilter(SqlRun\u001b[38;5;241m.\u001b[39mrun_uuid \u001b[38;5;241m==\u001b[39m run_uuid)\u001b[38;5;241m.\u001b[39mall()\n\u001b[0;32m 521\u001b[0m )\n\u001b[0;32m 523\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(runs) \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m--> 524\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m MlflowException(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRun with id=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mrun_uuid\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m not found\u001b[39m\u001b[38;5;124m\"\u001b[39m, RESOURCE_DOES_NOT_EXIST)\n\u001b[0;32m 525\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(runs) \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m1\u001b[39m:\n\u001b[0;32m 526\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m MlflowException(\n\u001b[0;32m 527\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mExpected only 1 run with id=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mrun_uuid\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m. Found \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlen\u001b[39m(runs)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 528\u001b[0m INVALID_STATE,\n\u001b[0;32m 529\u001b[0m )\n", "\u001b[1;31mMlflowException\u001b[0m: Run with id=a930976208fa4fb48dbbf5cf4d7f600f not found" ] } ], "source": [ "import mlflow\n", "from mlflow.tracking import MlflowClient\n", "\n", "# Set the tracking URI to the SQLite database\n", "mlflow.set_tracking_uri(\"sqlite:///E:/Projects/Bioma-AI/time-series-forecasting/trend_prediction_app/trend-prediction-ml/trend-prediction-pipeline/mlruns.db\")\n", "\n", "# Initialize MLflow client\n", "client = MlflowClient()\n", "\n", "# Get run information using the run ID\n", "run_id = \"a930976208fa4fb48dbbf5cf4d7f600f\"\n", "run = client.get_run(run_id)\n", "print(f\"Run ID: {run.info.run_id}\")\n", "print(f\"Run Status: {run.info.status}\")\n", "print(f\"Artifact URI: {run.info.artifact_uri}\")\n", "\n", "# List artifacts in the run\n", "artifacts = client.list_artifacts(run_id)\n", "for artifact in artifacts:\n", " print(f\"Artifact Path: {artifact.path}\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Run ID: 154301663fcc4245a7cc98eea0d123c3\n" ] } ], "source": [ "import mlflow\n", "\n", "# Set the tracking URI to your SQLite database\n", "mlflow.set_tracking_uri(\"sqlite:///mlruns.db\")\n", "\n", "# Start a new run\n", "with mlflow.start_run() as run:\n", " print(f\"Run ID: {run.info.run_id}\")" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Tables in database: [('experiments',), ('alembic_version',), ('experiment_tags',), ('tags',), ('registered_models',), ('runs',), ('registered_model_tags',), ('model_version_tags',), ('model_versions',), ('latest_metrics',), ('metrics',), ('registered_model_aliases',), ('datasets',), ('inputs',), ('input_tags',), ('params',), ('trace_info',), ('trace_tags',), ('trace_request_metadata',)]\n", "Contents of experiments:\n", "(0, 'Default', 'file:///E:/Projects/Bioma-AI/time-series-forecasting/trend_prediction_app/trend-prediction-ml/trend-prediction-pipeline/mlruns/0', 'active', 1725160384768, 1725160384768)\n", "Contents of alembic_version:\n", "('4465047574b1',)\n", "Contents of experiment_tags:\n", "Contents of tags:\n", "Contents of registered_models:\n", "Contents of runs:\n", "Contents of registered_model_tags:\n", "Contents of model_version_tags:\n", "Contents of model_versions:\n", "Contents of latest_metrics:\n", "Contents of metrics:\n", "Contents of registered_model_aliases:\n", "Contents of datasets:\n", "Contents of inputs:\n", "Contents of input_tags:\n", "Contents of params:\n", "Contents of trace_info:\n", "Contents of trace_tags:\n", "Contents of trace_request_metadata:\n" ] } ], "source": [ "import sqlite3\n", "\n", "db_path = r\"E:\\Projects\\Bioma-AI\\time-series-forecasting\\trend_prediction_app\\trend-prediction-ml\\trend-prediction-pipeline\\mlruns.db\"\n", "try:\n", " with sqlite3.connect(db_path) as conn:\n", " cursor = conn.cursor()\n", " cursor.execute(\"SELECT name FROM sqlite_master WHERE type='table';\")\n", " tables = cursor.fetchall()\n", " print(\"Tables in database:\", tables)\n", " \n", " for table in tables:\n", " print(f\"Contents of {table[0]}:\")\n", " cursor.execute(f\"SELECT * FROM {table[0]} LIMIT 10;\")\n", " rows = cursor.fetchall()\n", " for row in rows:\n", " print(row)\n", "except sqlite3.Error as e:\n", " print(f\"SQLite error: {e}\")" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "env: MLFLOW_TRACKING_URI=sqlite:///mlruns.db\n" ] } ], "source": [ "%env MLFLOW_TRACKING_URI=sqlite:///mlruns.db" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "mlops", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.19" } }, "nbformat": 4, "nbformat_minor": 2 }