Skip to content

Good Code

Logging

This is something I often use whenever I am in the process of building software and I think there are some key things that need to be documented. It is often much better than print statements. I often do this when I'm not really sure if what I did is correct in the process. It's really important to log. Especially when you're doing server computing and you need a history of what was going on.

My Style

  • INFO - General stuff of where I am at in the program so I can follow the control of flow
  • DEBUG - Typically more about sizes/shapes of my matrices or possibly in the checks
  • WARNING - Where things could go wrong but I have ignored this part due to some reason.

Resources

  • Python Logging: A Stroll Through the Source Code - RealPython
  • Python Logging Cheat Sheet - gist
  • The Hitchhikers Guide to Python: Logging - blog
  • Good Logging Practice in Python - blog
  • Logging CookBook - Python Docs
  • Corey Schafer
  • Logging Basics - Logging to Files, Setting Levels, and Formating - Youtube
  • Logging Advanced: Loggers, Handlers, and Formatters - Youtube

Testing

Something that we all should do but don't always do. It's important for the long run but it seems annoying for the short game. But overall, you cannot go wrong with tests; you just can't.

My Style

  • Package - PyTest
  • IDE - VSCode

Resources

  • Testing Python Applications with PyTest - Blog
  • Getting Started with Testing in Python - RealPython
  • Testing Your Python Code with PyTest - SciPy 2019
  • Learn PyTest in 60 Minutes: Python Unit Testing Framework - Youtube
  • Python Testing in VSCode - VSCode Docs
  • Eric Ma
  • Testing Data Science Code - YouTube
  • Best Testing Practices - PyCon 2017

Repository Organization

Packaging

Type Checking

Continuous Integration

WorkFlow

  1. JupyterLab - Prototyping, Remote Computing
  2. VSCode - Package Management, Remote Computing
  3. Remote Computing - SSH (JLab, VSCode)