{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "[Sebastian Raschka](http://sebastianraschka.com) \n", "\n", "
\n", "I would be happy to hear your comments and suggestions. \n", "Please feel free to drop me a note via\n", "[twitter](https://twitter.com/rasbt), [email](mailto:bluewoodtree@gmail.com), or [google+](https://plus.google.com/+SebastianRaschka).\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# IPython magic function documentation - `%watermark`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "I wrote this simple `watermark` IPython magic function to conveniently add date- and time-stamps to my IPython notebooks. Also, I often want to document various system information, e.g., for my [Python benchmarks](https://github.com/rasbt/One-Python-benchmark-per-day) series.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Installation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The watermark line magic can be installed by executing\n", "\n", "```bash\n", "pip install watermark\n", "```\n", "\n", "Alternatively, you can install the latest development version directly from GitHub via\n", "\n", "```bash\n", "pip install -e git+https://github.com/rasbt/watermark#egg=watermark\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Loading the `%watermark` magic" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To load the `watermark` magic, execute the following line in your IPython notebook or current IPython shell" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%load_ext watermark" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Usage" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In order to display the optional `watermark` arguments, type" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "%watermark?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n",
    "%watermark [-a AUTHOR] [-d] [-n] [-t] [-i] [-z] [-u] [-c CUSTOM_TIME]\n",
    "                 [-v] [-p PACKAGES] [-h] [-m] [-g] [-w]\n",
    "\n",
    "IPython magic function to print date/time stamps\n",
    "and various system information.\n",
    "\n",
    "optional arguments:\n",
    "  -a AUTHOR, --author AUTHOR\n",
    "                        prints author name\n",
    "  -d, --date            prints current date as YYYY-mm-dd\n",
    "  -n, --datename        prints date with abbrv. day and month names\n",
    "  -t, --time            prints current time as HH-MM-SS\n",
    "  -i, --iso8601         prints the combined date and time including the time\n",
    "                        zone the ISO 8601 standard with UTC offset\n",
    "  -z, --timezone        appends the local time zone\n",
    "  -u, --updated         appends a string \"Last updated: \"\n",
    "  -c CUSTOM_TIME, --custom_time CUSTOM_TIME\n",
    "                        prints a valid strftime() string\n",
    "  -v, --python          prints Python and IPython version\n",
    "  -p PACKAGES, --packages PACKAGES\n",
    "                        prints versions of specified Python modules and\n",
    "                        packages\n",
    "  -h, --hostname        prints the host name\n",
    "  -m, --machine         prints system and machine info\n",
    "  -g, --githash         prints current Git commit hash\n",
    "  -w, --watermark       prints the current version of watermark\n",
    "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Examples" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2016-08-16T18:03:25-04:00\n", "\n", "CPython 3.5.1\n", "IPython 5.0.0\n", "\n", "compiler : GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)\n", "system : Darwin\n", "release : 15.6.0\n", "machine : x86_64\n", "processor : i386\n", "CPU cores : 4\n", "interpreter: 64bit\n" ] } ], "source": [ "%watermark" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2016-08-16 18:03:31\n" ] } ], "source": [ "%watermark -t -d" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2016-08-16T18:03:42-04:00\n" ] } ], "source": [ "%watermark --iso8601" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "last updated: Tue Aug 16 2016 18:03:47 EDT\n" ] } ], "source": [ "%watermark -u -n -t -z" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPython 3.5.1\n", "IPython 5.0.0\n" ] } ], "source": [ "%watermark -v" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "compiler : GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)\n", "system : Darwin\n", "release : 15.6.0\n", "machine : x86_64\n", "processor : i386\n", "CPU cores : 4\n", "interpreter: 64bit\n" ] } ], "source": [ "%watermark -m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPython 3.5.1\n", "IPython 5.0.0\n", "\n", "numpy 1.11.1\n", "scipy 0.17.1\n", "\n", "compiler : GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)\n", "system : Darwin\n", "release : 15.6.0\n", "machine : x86_64\n", "processor : i386\n", "CPU cores : 4\n", "interpreter: 64bit\n", "Git hash : fbeb63abe159172529542e202a8c92ec3227099d\n" ] } ], "source": [ "%watermark -v -m -p numpy,scipy -g" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "John Doe 2016-08-16 \n", "\n", "CPython 3.5.1\n", "IPython 5.0.0\n", "\n", "compiler : GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)\n", "system : Darwin\n", "release : 15.6.0\n", "machine : x86_64\n", "processor : i386\n", "CPU cores : 4\n", "interpreter: 64bit\n" ] } ], "source": [ "%watermark -a \"John Doe\" -d -v -m" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import numpy as np\n", "import scipy as sp" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "numpy 1.12.1\n", "scipy 0.19.1\n", "\n" ] } ], "source": [ "%watermark --iversions" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.6.1" } }, "nbformat": 4, "nbformat_minor": 1 }