     (b-python-template-module t)))
 
 (add-hook 'python-mode-hook
-	  '(lambda ()
-	     (set (make-local-variable 'compile-command)
-		  (b-python-compile-command))
-             (abbrev-mode)))
+          '(lambda ()
+             (set (make-local-variable 'compile-command)
+                  (b-python-compile-command))
+             (abbrev-mode)
+             (b-python-maybe-pykern-fmt-run)))
 
 (progn
   (define-key python-mode-map "\C-c\C-m" 'compile)

   ((string-match "\\(/test_[^/]+\\|_test\\)\\.py$" (buffer-file-name)) "pytest")
   ((string-match "\\.py$" (buffer-file-name)) "module")
   (t nil)))

(defun b-python-sirepo-service-restart (service)
  "Start sirepo service in project root"

	(b-python-project-root
	 (directory-file-name (file-name-directory pwd)))))))

(defun b-python-pykern-fmt-run ()
  (shell-command (concat "pykern fmt run "
                         (buffer-file-name)))
  (minibuffer-message "Running pykern fmt")
  (revert-buffer :ignore-auto :noconfirm))

(defun b-python-template nil
  "inserts template according to file name"
  (interactive)
