4 "signature": "sha256:7a1fb9fe0590432e08d22db547bfd8825adc67f4ba099ab1a13587be26b31767"
12 "cell_type": "heading",
16 "Testing the Virtual Machine Configuration"
20 "cell_type": "markdown",
23 "To check the virtual machine (VM) configuration, select *Run All* from the *Cell* menu above and then read through this notebook."
27 "cell_type": "heading",
35 "cell_type": "markdown",
38 "Show the current directory the notebook server is running in *in the virtual machine*."
52 "cell_type": "markdown",
55 "Show the version of Python that the notebook is running - it should be a variant of Python 3.4."
73 "#py3 libraries are still throwing warnings\n",
74 "#We can disable the display of them within a notebook by using:\n",
76 "#warnings.simplefilter(action = \"ignore\", category = FutureWarning)"
86 "sys.getdefaultencoding()"
93 "cell_type": "heading",
97 "Check to see that key libraries are installed"
104 "#!pip3 install --upgrade pandas"
106 "language": "python",
114 "import pandas as pd"
116 "language": "python",
124 "import matplotlib.pyplot as plt"
126 "language": "python",
134 "plt.plot([1,2,3,4])\n",
135 "plt.ylabel('some numbers')\n",
138 "language": "python",
143 "cell_type": "heading",
147 "Database server tests"
151 "cell_type": "markdown",
154 "A handful of quick tests just to see that the database servers are running."
158 "cell_type": "heading",
166 "cell_type": "markdown",
169 "Test that the PostgreSQL database is running... This example also shows how to connect to the database."
176 "from pandas import read_sql_query as psql"
178 "language": "python",
186 "from sqlalchemy import create_engine\n",
187 "engine = create_engine('postgresql://test:test@localhost:5432/tm351test')"
189 "language": "python",
197 "#This alternative method may also be used\"\n",
198 "#import psycopg2 as pg\n",
199 "#If connecting to the default port, you can omit the port parameter\n",
200 "#engine = pg.connect(dbname='tm351test', host='localhost', user='test', password='test' , port=5432)"
202 "language": "python",
210 "psql(\"SELECT table_schema,table_name FROM information_schema.tables \\\n",
211 " ORDER BY table_schema,table_name;\", engine)"
213 "language": "python",
218 "cell_type": "heading",
226 "cell_type": "markdown",
229 "Test that the mongoDB database is running... This example also shows how to connect to the database."
236 "from pymongo import MongoClient"
238 "language": "python",
246 "#If connecting to the default port, you can omit the second (port number) parameter\n",
247 "c = MongoClient('localhost', 27017)"
249 "language": "python",
257 "db = c['test-database']"
259 "language": "python",
267 "collection = db.test_collection"
269 "language": "python",
277 "post_id = collection.insert({'test':'asasas'})"
279 "language": "python",
289 "language": "python",
297 "for r in collection.find():\n",
300 "language": "python",
305 "cell_type": "heading",
309 "Additional Install Tests"
313 "cell_type": "markdown",
316 "Check to see that we can install other libraries as required - such as ones from github."
323 "#!pip3 uninstall -y folium\n",
324 "#!pip3 install git+https://github.com/tbicr/folium.git@fixed#folium"
326 "language": "python",
335 "#This initialisation route appears to be broken at the moment?\n",
336 "#The tbicr patch above works but I think it's an earlier version that does not support clusters\n",
337 "#folium.initialize_notebook()"
339 "language": "python",
347 "map = folium.Map(location=[40, -99], zoom_start=4)\n",
348 "map.simple_marker([40.67, -73.94], popup='Add <b>popup</b> text here.')\n",
351 "language": "python",
359 "from IPython.display import HTML\n",
360 "def inline_map(map):\n",
362 " Embeds the HTML source of the map directly into the IPython notebook.\n",
364 " This method will not work if the map depends on any files (json data). Also this uses\n",
365 " the HTML5 srcdoc attribute, which may not be supported in all browsers.\n",
367 " map._build_map()\n",
368 " return HTML('<iframe srcdoc=\"{srcdoc}\" style=\"width: 100%; height: 510px; border: none\"></iframe>'.format(srcdoc=map.HTML.replace('\"', '"')))\n",
370 "def embed_map(map, path=\"map.html\"):\n",
372 " Embeds a linked iframe to the map into the IPython notebook.\n",
374 " Note: this method will not capture the source of the map into the notebook.\n",
375 " This method should work for all maps (as long as they use relative urls).\n",
377 " map.create_map(path=path)\n",
378 " return HTML('<iframe src=\"files/{path}\" style=\"width: 100%; height: 510px; border: none\"></iframe>'.format(path=path))"
380 "language": "python",
390 "language": "python",
395 "cell_type": "heading",
406 "%install_ext https://raw.github.com/cjdrake/ipython-magic/master/gvmagic.py"
408 "language": "python",
418 "language": "python",
426 "%%dot digraph G {\n",
431 "language": "python",
440 " subgraph clusterA {\n",
442 " subgraph clusterC {\n",
446 " subgraph clusterB {\n",
452 "language": "python",
457 "cell_type": "heading",
468 "#The shell service isn't being properly started at the moment. We can kick it into action with the following command:\n",
469 "! /usr/local/lib/node_modules/tty.js/bin/tty.js --port 3000 --daemonize"
471 "language": "python",
476 "cell_type": "heading",
480 "More Py 3 patches for now..."
487 "!pip3 uninstall -y statsmodels\n",
488 "!pip3 install git+https://github.com/statsmodels/statsmodels.git"
490 "language": "python",
498 "#!pip3 uninstall -y ggplot\n",
499 "!pip3 install git+https://github.com/yhat/ggplot.git"
501 "language": "python",
509 "#I've been filing issues... as updates appear, the quickest way to get the is from master repo\n",
510 "!pip3 uninstall -y pandasql\n",
511 "#!pip3 install git+https://github.com/yhat/pandasql.git\n",
512 "#The original repo keeps breaking things in Python 3 - below is my fix\n",
513 "#I wonder if we should clone repos and freeze them in a presentation branch to be used for that presentation's VM?\n",
514 "!pip3 install git+https://github.com/psychemedia/pandasql.git"
516 "language": "python",
524 "#http://nbviewer.ipython.org/gist/pascal-schetelat/8382651\n",
525 "#No installer - just download file... TO DO\n",
526 "#!pip3 install git+https://github.com/pascal-schetelat/Slope.git"
528 "language": "python",
533 "cell_type": "heading",
541 "cell_type": "markdown",
544 "If you saw no major errors or warnings and everything seemed to work okay, carry on with the next activity described in the course materials."
548 "cell_type": "markdown",
551 "If you did get errors or warning messages, please check the [FAQ wiki](https://learn2.open.ac.uk/mod/ouwiki/view.php?id=556345) and the [Technical Help and FAQs Forum](https://learn2.open.ac.uk/mod/forumng/view.php?id=555623). If there is nothing there that helps, please post details of the issues you encountered, and *don't panic*. There are plenty of other things you can get on with while we try to sort the issue(s) for you - so once you've posted your issues, carry on with the next activity described in the course materials."