diff --git a/docs/examples/DataSet/Extracting-runs-from-one-DB-file-to-another.ipynb b/docs/examples/DataSet/Extracting-runs-from-one-DB-file-to-another.ipynb index 05cf4d5c8fbb..58802eef6d10 100644 --- a/docs/examples/DataSet/Extracting-runs-from-one-DB-file-to-another.ipynb +++ b/docs/examples/DataSet/Extracting-runs-from-one-DB-file-to-another.ipynb @@ -24,7 +24,7 @@ "metadata": {}, "outputs": [], "source": [ - "import os \n", + "import os\n", "\n", "import numpy as np\n", "\n", @@ -47,15 +47,40 @@ "metadata": {}, "outputs": [], "source": [ - "source_path = os.path.join(os.getcwd(), 'extract_runs_notebook_source.db')\n", - "target_path = os.path.join(os.getcwd(), 'extract_runs_notebook_target.db')" + "source_path = os.path.join(os.getcwd(), \"extract_runs_notebook_source.db\")\n", + "target_path = os.path.join(os.getcwd(), \"extract_runs_notebook_target.db\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Upgrading database; v0 -> v1: : 0it [00:00, ?it/s]\n", + "Upgrading database; v1 -> v2: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 407.89it/s]\n", + "Upgrading database; v2 -> v3: : 0it [00:00, ?it/s]\n", + "Upgrading database; v3 -> v4: : 0it [00:00, ?it/s]\n", + "Upgrading database; v4 -> v5: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 333.17it/s]\n", + "Upgrading database; v5 -> v6: : 0it [00:00, ?it/s]\n", + "Upgrading database; v6 -> v7: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 166.47it/s]\n", + "Upgrading database; v7 -> v8: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 250.05it/s]\n", + "Upgrading database; v8 -> v9: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 499.56it/s]\n", + "Upgrading database; v0 -> v1: : 0it [00:00, ?it/s]\n", + "Upgrading database; v1 -> v2: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 333.33it/s]\n", + "Upgrading database; v2 -> v3: : 0it [00:00, ?it/s]\n", + "Upgrading database; v3 -> v4: : 0it [00:00, ?it/s]\n", + "Upgrading database; v4 -> v5: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 333.38it/s]\n", + "Upgrading database; v5 -> v6: : 0it [00:00, ?it/s]\n", + "Upgrading database; v6 -> v7: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 166.56it/s]\n", + "Upgrading database; v7 -> v8: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 499.74it/s]\n", + "Upgrading database; v8 -> v9: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 500.45it/s]\n" + ] + } + ], "source": [ "source_conn = connect(source_path)\n", "target_conn = connect(target_path)" @@ -67,11 +92,11 @@ "metadata": {}, "outputs": [], "source": [ - "exp = Experiment(name='extract_runs_experiment',\n", - " sample_name='no_sample',\n", - " conn=source_conn)\n", + "exp = Experiment(\n", + " name=\"extract_runs_experiment\", sample_name=\"no_sample\", conn=source_conn\n", + ")\n", "\n", - "my_inst = DummyInstrument('my_inst', gates=['voltage', 'current'])\n", + "my_inst = DummyInstrument(\"my_inst\", gates=[\"voltage\", \"current\"])\n", "station = Station(my_inst)" ] }, @@ -84,16 +109,16 @@ "name": "stdout", "output_type": "stream", "text": [ - "Starting experimental run with id: 1\n", - "Starting experimental run with id: 2\n", - "Starting experimental run with id: 3\n", - "Starting experimental run with id: 4\n", - "Starting experimental run with id: 5\n", - "Starting experimental run with id: 6\n", - "Starting experimental run with id: 7\n", - "Starting experimental run with id: 8\n", - "Starting experimental run with id: 9\n", - "Starting experimental run with id: 10\n" + "Starting experimental run with id: 1. \n", + "Starting experimental run with id: 2. \n", + "Starting experimental run with id: 3. \n", + "Starting experimental run with id: 4. \n", + "Starting experimental run with id: 5. \n", + "Starting experimental run with id: 6. \n", + "Starting experimental run with id: 7. \n", + "Starting experimental run with id: 8. \n", + "Starting experimental run with id: 9. \n", + "Starting experimental run with id: 10. \n" ] } ], @@ -102,13 +127,12 @@ "meas.register_parameter(my_inst.voltage)\n", "meas.register_parameter(my_inst.current, setpoints=(my_inst.voltage,))\n", "\n", - "#Add 10 runs with gradually more and more data\n", + "# Add 10 runs with gradually more and more data\n", "\n", "for run_id in range(1, 11):\n", " with meas.run() as datasaver:\n", " for step, noise in enumerate(np.random.randn(run_id)):\n", - " datasaver.add_result((my_inst.voltage, step),\n", - " (my_inst.current, noise))" + " datasaver.add_result((my_inst.voltage, step), (my_inst.current, noise))" ] }, { @@ -125,9 +149,7 @@ { "cell_type": "code", "execution_count": 6, - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "extract_runs_into_db(source_path, target_path, 3, 7)" @@ -139,7 +161,7 @@ "metadata": {}, "outputs": [], "source": [ - "target_exp = load_experiment_by_name(name='extract_runs_experiment', conn=target_conn)" + "target_exp = load_experiment_by_name(name=\"extract_runs_experiment\", conn=target_conn)" ] }, { @@ -150,8 +172,8 @@ { "data": { "text/plain": [ - "extract_runs_experiment#no_sample#1@C:\\Users\\wihpniel\\src\\qcodes\\docs\\examples\\DataSet\\extract_runs_notebook_target.db\n", - "----------------------------------------------------------------------------------------------------------------------\n", + "extract_runs_experiment#no_sample#1@C:\\Users\\jenielse\\source\\repos\\Qcodes\\docs\\examples\\DataSet\\extract_runs_notebook_target.db\n", + "-------------------------------------------------------------------------------------------------------------------------------\n", "1-results-1-my_inst_voltage,my_inst_current-3\n", "2-results-2-my_inst_voltage,my_inst_current-7" ] @@ -184,7 +206,7 @@ { "data": { "text/plain": [ - "'aaaaaaaa-0c00-0007-0000-016bf9fabe38'" + "'aaaaaaaa-0000-0000-0000-017ea07e4a31'" ] }, "execution_count": 9, @@ -204,7 +226,7 @@ { "data": { "text/plain": [ - "'aaaaaaaa-0c00-0007-0000-016bf9fabe38'" + "'aaaaaaaa-0000-0000-0000-017ea07e4a31'" ] }, "execution_count": 10, @@ -270,7 +292,7 @@ "metadata": {}, "outputs": [], "source": [ - "extra_source_path = os.path.join(os.getcwd(), 'extract_runs_notebook_source_aux.db')" + "extra_source_path = os.path.join(os.getcwd(), \"extract_runs_notebook_source_aux.db\")" ] }, { @@ -279,12 +301,18 @@ "metadata": {}, "outputs": [ { - "name": "stderr", + "name": "stdout", "output_type": "stream", "text": [ - "Upgrading database: : 0it [00:00, ?it/s]\n", - "Upgrading database: : 0it [00:00, ?it/s]\n", - "Upgrading database, version 5 -> 6: : 0it [00:00, ?it/s]\n" + "Upgrading database; v0 -> v1: : 0it [00:00, ?it/s]\n", + "Upgrading database; v1 -> v2: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 500.04it/s]\n", + "Upgrading database; v2 -> v3: : 0it [00:00, ?it/s]\n", + "Upgrading database; v3 -> v4: : 0it [00:00, ?it/s]\n", + "Upgrading database; v4 -> v5: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 333.89it/s]\n", + "Upgrading database; v5 -> v6: : 0it [00:00, ?it/s]\n", + "Upgrading database; v6 -> v7: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 199.91it/s]\n", + "Upgrading database; v7 -> v8: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 333.44it/s]\n", + "Upgrading database; v8 -> v9: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 333.36it/s]\n" ] } ], @@ -298,9 +326,9 @@ "metadata": {}, "outputs": [], "source": [ - "exp = Experiment(name='extract_runs_experiment_aux',\n", - " sample_name='no_sample',\n", - " conn=source_extra_conn)\n" + "exp = Experiment(\n", + " name=\"extract_runs_experiment_aux\", sample_name=\"no_sample\", conn=source_extra_conn\n", + ")" ] }, { @@ -312,16 +340,16 @@ "name": "stdout", "output_type": "stream", "text": [ - "Starting experimental run with id: 1\n", - "Starting experimental run with id: 2\n", - "Starting experimental run with id: 3\n", - "Starting experimental run with id: 4\n", - "Starting experimental run with id: 5\n", - "Starting experimental run with id: 6\n", - "Starting experimental run with id: 7\n", - "Starting experimental run with id: 8\n", - "Starting experimental run with id: 9\n", - "Starting experimental run with id: 10\n" + "Starting experimental run with id: 1. \n", + "Starting experimental run with id: 2. \n", + "Starting experimental run with id: 3. \n", + "Starting experimental run with id: 4. \n", + "Starting experimental run with id: 5. \n", + "Starting experimental run with id: 6. \n", + "Starting experimental run with id: 7. \n", + "Starting experimental run with id: 8. \n", + "Starting experimental run with id: 9. \n", + "Starting experimental run with id: 10. \n" ] } ], @@ -330,13 +358,12 @@ "meas.register_parameter(my_inst.current)\n", "meas.register_parameter(my_inst.voltage, setpoints=(my_inst.current,))\n", "\n", - "#Add 10 runs with gradually more and more data\n", + "# Add 10 runs with gradually more and more data\n", "\n", "for run_id in range(1, 11):\n", " with meas.run() as datasaver:\n", " for step, noise in enumerate(np.random.randn(run_id)):\n", - " datasaver.add_result((my_inst.current, step),\n", - " (my_inst.voltage, noise))" + " datasaver.add_result((my_inst.current, step), (my_inst.voltage, noise))" ] }, { @@ -347,7 +374,7 @@ { "data": { "text/plain": [ - "'aaaaaaaa-0c00-0007-0000-016bf9fac5ba'" + "'aaaaaaaa-0000-0000-0000-017ea07e5986'" ] }, "execution_count": 16, @@ -374,7 +401,9 @@ "metadata": {}, "outputs": [], "source": [ - "target_exp_aux = load_experiment_by_name(name='extract_runs_experiment_aux', conn=target_conn)" + "target_exp_aux = load_experiment_by_name(\n", + " name=\"extract_runs_experiment_aux\", conn=target_conn\n", + ")" ] }, { @@ -392,7 +421,7 @@ { "data": { "text/plain": [ - "'aaaaaaaa-0c00-0007-0000-016bf9fac5ba'" + "'aaaaaaaa-0000-0000-0000-017ea07e5986'" ] }, "execution_count": 19, @@ -453,8 +482,11 @@ "metadata": {}, "outputs": [], "source": [ - "from qcodes.dataset.sqlite.queries import get_guids_from_run_spec\n", - "from qcodes.dataset.data_set import load_by_guid, load_by_run_spec" + "from qcodes.dataset.data_set import (\n", + " load_by_guid,\n", + " load_by_run_spec,\n", + " get_guids_by_run_spec,\n", + ")" ] }, { @@ -465,8 +497,8 @@ { "data": { "text/plain": [ - "['aaaaaaaa-0c00-0007-0000-016bf9fabe38',\n", - " 'aaaaaaaa-0c00-0007-0000-016bf9fac5ba']" + "['aaaaaaaa-0000-0000-0000-017ea07e4a31',\n", + " 'aaaaaaaa-0000-0000-0000-017ea07e5986']" ] }, "execution_count": 22, @@ -475,7 +507,7 @@ } ], "source": [ - "guids = get_guids_from_run_spec(target_conn, captured_run_id=3)\n", + "guids = get_guids_by_run_spec(conn=target_conn, captured_run_id=3)\n", "guids" ] }, @@ -487,8 +519,8 @@ { "data": { "text/plain": [ - "results #1@C:\\Users\\wihpniel\\src\\qcodes\\docs\\examples\\DataSet\\extract_runs_notebook_target.db\n", - "---------------------------------------------------------------------------------------------\n", + "results #1@C:\\Users\\jenielse\\source\\repos\\Qcodes\\docs\\examples\\DataSet\\extract_runs_notebook_target.db\n", + "------------------------------------------------------------------------------------------------------\n", "my_inst_voltage - numeric\n", "my_inst_current - numeric" ] @@ -510,8 +542,8 @@ { "data": { "text/plain": [ - "results #4@C:\\Users\\wihpniel\\src\\qcodes\\docs\\examples\\DataSet\\extract_runs_notebook_target.db\n", - "---------------------------------------------------------------------------------------------\n", + "results #4@C:\\Users\\jenielse\\source\\repos\\Qcodes\\docs\\examples\\DataSet\\extract_runs_notebook_target.db\n", + "------------------------------------------------------------------------------------------------------\n", "my_inst_current - numeric\n", "my_inst_voltage - numeric" ] @@ -542,18 +574,17 @@ "name": "stdout", "output_type": "stream", "text": [ - " captured_run_id experiment_name sample_name sample_id location work_station\n", - "----------------- --------------------------- ------------- ----------- ---------- --------------\n", - " 3 extract_runs_experiment no_sample 2863311530 12 7\n", - " 3 extract_runs_experiment_aux no_sample 2863311530 12 7\n", + " captured_run_id captured_counter experiment_name sample_name sample_id location work_station\n", + "----------------- ------------------ --------------------------- ------------- ----------- ---------- --------------\n", + " 3 3 extract_runs_experiment no_sample 2863311530 0 0\n", + " 3 3 extract_runs_experiment_aux no_sample 2863311530 0 0\n", "Caught a NameError\n" ] } ], "source": [ "try:\n", - " load_by_run_spec(captured_run_id=3,\n", - " conn=target_conn)\n", + " load_by_run_spec(captured_run_id=3, conn=target_conn)\n", "except NameError:\n", " print(\"Caught a NameError\")" ] @@ -573,8 +604,8 @@ { "data": { "text/plain": [ - "results #4@C:\\Users\\wihpniel\\src\\qcodes\\docs\\examples\\DataSet\\extract_runs_notebook_target.db\n", - "---------------------------------------------------------------------------------------------\n", + "results #4@C:\\Users\\jenielse\\source\\repos\\Qcodes\\docs\\examples\\DataSet\\extract_runs_notebook_target.db\n", + "------------------------------------------------------------------------------------------------------\n", "my_inst_current - numeric\n", "my_inst_voltage - numeric" ] @@ -585,9 +616,9 @@ } ], "source": [ - "load_by_run_spec(captured_run_id=3,\n", - " experiment_name='extract_runs_experiment_aux',\n", - " conn=target_conn)" + "load_by_run_spec(\n", + " captured_run_id=3, experiment_name=\"extract_runs_experiment_aux\", conn=target_conn\n", + ")" ] }, { @@ -600,7 +631,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -614,9 +645,16 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.4" + "version": "3.10.0" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }