Add diagnostics to Python API and CLI

Change-Id: Ib26adada4a5610f7eb6a3458caa4ca4b18d804ca