%watermark
¶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 series.
The watermark line magic can be installed by executing
pip install watermark
Alternatively, you can install the latest development version directly from GitHub via
pip install -e git+https://github.com/rasbt/watermark#egg=watermark
%watermark
magic¶To load the watermark
magic, execute the following line in your IPython notebook or current IPython shell
%load_ext watermark
The version of watermark
itself can be retrieved as follows:
%watermark --watermark
Watermark: 2.3.0
In order to display the optional watermark
arguments, type
%watermark?
Docstring: :: %watermark [-a AUTHOR] [-gu GITHUB_USERNAME] [-e EMAIL] [-ws WEBSITE] [-d] [-n] [-t] [-i] [-z] [-u] [-c CUSTOM_TIME] [-v] [-p PACKAGES] [-co] [-h] [-m] [-g] [-r] [-b] [-w] [-iv] IPython magic function to print date/time stamps and various system information. optional arguments: -a AUTHOR, --author AUTHOR prints author name -gu GITHUB_USERNAME, --github_username GITHUB_USERNAME prints author github username -e EMAIL, --email EMAIL prints author email -ws WEBSITE, --website WEBSITE prints author or project website -d, --date prints current date as YYYY-mm-dd -n, --datename prints date with abbrv. day and month names -t, --time prints current time as HH-MM-SS -i, --iso8601 prints the combined date and time including the time zone in the ISO 8601 standard with UTC offset -z, --timezone appends the local time zone -u, --updated appends a string "Last updated: " -c CUSTOM_TIME, --custom_time CUSTOM_TIME prints a valid strftime() string -v, --python prints Python and IPython version -p PACKAGES, --packages PACKAGES prints versions of specified Python modules and packages -co, --conda prints name of current conda environment -h, --hostname prints the host name -m, --machine prints system and machine info -g, --githash prints current Git commit hash -r, --gitrepo prints current Git remote address -b, --gitbranch prints current Git branch -w, --watermark prints the current version of watermark -iv, --iversions prints the name/version of all imported modules File: ~/code/github_rasbt/watermark/watermark/magic.py
%watermark [-a AUTHOR] [-gu GITHUB_USERNAME] [-e EMAIL] [-ws WEBSITE] [-d] [-n] [-t] [-i] [-z] [-u] [-c CUSTOM_TIME] [-v] [-p PACKAGES] [-h] [-m] [-g] [-r] [-b] [-w] [-iv] IPython magic function to print date/time stamps and various system information. options: -a AUTHOR, --author AUTHOR prints author name -gu GITHUB_USERNAME, --github_username GITHUB_USERNAME prints author github username -e EMAIL, --email EMAIL prints author email -ws WEBSITE, --website WEBSITE prints author or project website -d, --date prints current date as YYYY-mm-dd -n, --datename prints date with abbrv. day and month names -t, --time prints current time as HH-MM-SS -i, --iso8601 prints the combined date and time including the time zone in the ISO 8601 standard with UTC offset -z, --timezone appends the local time zone -u, --updated appends a string "Last updated: " -c CUSTOM_TIME, --custom_time CUSTOM_TIME prints a valid strftime() string -v, --python prints Python and IPython version -p PACKAGES, --packages PACKAGES prints versions of specified Python modules and packages -h, --hostname prints the host name -m, --machine prints system and machine info -g, --githash prints current Git commit hash -r, --gitrepo prints current Git remote address -b, --gitbranch prints current Git branch -w, --watermark prints the current version of watermark -iv, --iversions prints the name/version of all imported modules
%watermark
Last updated: 2022-01-03T19:44:42.841436-06:00 Python implementation: CPython Python version : 3.9.6 IPython version : 7.30.1 Compiler : Clang 11.1.0 OS : Darwin Release : 21.1.0 Machine : arm64 Processor : arm CPU cores : 8 Architecture: 64bit
%watermark -u -t -d
Last updated: 2022-01-03 19:44:42
%watermark -u --iso8601
Last updated: 2022-01-03T19:44:42.855544-06:00
%watermark -u -n -t -z
Last updated: Mon Jan 03 2022 19:44:42CST
%watermark -v
Python implementation: CPython Python version : 3.9.6 IPython version : 7.30.1
%watermark -m
Compiler : Clang 11.1.0 OS : Darwin Release : 21.1.0 Machine : arm64 Processor : arm CPU cores : 8 Architecture: 64bit
%watermark -v -m -p numpy,scipy,sklearn
Python implementation: CPython Python version : 3.9.6 IPython version : 7.30.1 numpy : 1.22.0 scipy : 1.7.3 sklearn: 1.0.2 Compiler : Clang 11.1.0 OS : Darwin Release : 21.1.0 Machine : arm64 Processor : arm CPU cores : 8 Architecture: 64bit
%watermark -a "John Doe" -u -d -v -m
Author: John Doe Last updated: 2022-01-03 Python implementation: CPython Python version : 3.9.6 IPython version : 7.30.1 Compiler : Clang 11.1.0 OS : Darwin Release : 21.1.0 Machine : arm64 Processor : arm CPU cores : 8 Architecture: 64bit
import scipy as sp
from sklearn import metrics
import numpy.linalg as linalg
%watermark --iversions
scipy : 1.7.3 numpy : 1.22.0 sklearn: 1.0.2