rasbt / watermark

An IPython magic extension for printing date and time stamps, version numbers, and hardware information
Other
884 stars 90 forks source link
ipython jupyter magic-extension python

Build status PyPI version Python 3.7 License

watermark

An IPython magic extension for printing date and time stamps, version numbers, and hardware information.

Sections


Examples

[top]

Using watermark in Jupyter notebooks and IPython sessions

More examples can be found in this Jupyter notebook.

Binder


Using watermark as a module

from watermark import watermark
print(watermark())
Last updated: 2022-09-13T16:28:56.177487-05:00

Python implementation: CPython
Python version       : 3.9.13
IPython version      : 8.4.0

Compiler    : Clang 13.0.1 
OS          : Darwin
Release     : 21.6.0
Machine     : arm64
Processor   : arm
CPU cores   : 10
Architecture: 64bit
print(watermark(packages="numpy,scipy"))
numpy: 1.23.2
scipy: 1.9.1

See help(watermark) for more options.

Installation and updating

[top]

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


Note:

To remove an old watermark installation (installed via the deprecated %install_ext magic extension), simply delete it from the .ipython/extensions/ directory, which is typically located in a user's home directory.

Usage

[top]

After successful installation, the watermark magic extension can be loaded via:

%load_ext watermark


To get an overview of all available commands, type:

%watermark?


  %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


Development guidelines

[top]

In line with NEP 29, this project supports:


Changelog

[top]

v. 2.4.3 (May 23, 2023)

v. 2.4.1 and v 2.4.2 (May 23, 2023)

v. 2.4.0 (May 23, 2023)

v. 2.3.1 (May 27, 2022)

v. 2.3.0 (January 3, 2022)

import numpy
import watermark.watermark as watermark

watermark(iversions=True, globals_=globals())

v. 2.2.0 (February 17, 2021)

v. 2.1.0 (November 23, 2020)

v. 2.0.2 (November 19, 2019)

v. 2.0.1 (October 04, 2019)

v. 2.0.0 (October 04, 2019)

v. 1.8.2 (July 28, 2019)

v. 1.8.1 (January 26, 2019)

v. 1.8.0 (January 02, 2019)

import scipy as sp
from sklearn import metrics
import numpy.linalg as linalg
%watermark --iversions

will return

scipy     1.1.0
sklearn   0.20.1
numpy     1.15.4

v. 1.7.0 (October 13, 2018)

(Via contribution by James Myatt)

v. 1.6.1 (June 10, 2018)

v. 1.6.0 (Jan uary18, 2018)

v. 1.5.0 (August 27, 2017)

v. 1.4.0 (April 18, 2017)

v. 1.3.4 (October 15, 2016)

v. 1.3.3 (September 1, 2016)

v. 1.3.2 (August 16, 2016)

v. 1.3.1 (June 6, 2016)

v. 1.3.0 (May 21, 2016)

v. 1.2.3 (January 29, 2016)

v. 1.2.2 (June 17, 2015)

v. 1.2.1 (March 3, 2015)

v. 1.2.0 (October 1, 2014)