|
Setting the Scene
|
This lesson focuses on core tools and practices for keeping your Jupyter Notebooks readable and maintainable.
The lesson follows on from the novice Software Carpentry lesson, but this is not a prerequisite for attending as long as you have some basic Python and command line skills, and you have been using them for a while writing code to help with your work.
|
|
Section 1: Setting Up Environment For Collaborative Code Development
|
In order to develop (write, test, debug, backup) code efficiently, you need to use a number of different tools.
When there is a choice of tools for a task you will have to decide which tool is right for you, which may be a matter of personal preference or what the team or community you belong to is using.
|
|
Introduction to Our Software Project
|
Programming interfaces define how individual modules within a software application interact among themselves or how the application itself interacts with its users.
MVC is a software design architecture which divides the application into three interconnected modules: Model (data), View (user interface), and Controller (input/output and data manipulation).
The software project we use throughout this course is an example of an MVC application that allows us to inspect and analyze astronomical light curves.
|
|
Virtual Environments For Software Development
|
Virtual environments keep Python versions and dependencies required by different projects separate.
A virtual environment is itself a directory structure.
Use venv to create and manage Python virtual environments.
Use pip to install and manage Python external (third-party) libraries.
pip allows you to declare all dependencies for a project in a separate file (by convention called requirements.txt) which can be shared with collaborators/users and used to replicate a virtual environment.
Use pip3 freeze > requirements.txt to take snapshot of your project’s dependencies.
Use pip3 install -r requirements.txt to replicate someone else’s virtual environment on your machine from the requirements.txt file.
|
|
Integrated Software Development Environments
|
An IDE is an application that provides a comprehensive set of facilities for software development, including syntax highlighting, code search and completion, version control, testing and debugging.
Jupyter Lab launches within the pre-existing virtual environment
We can run terminal commands within Jupyter Lab
|
|
Best practices for Jupyter
|
The interactivity of Notebooks, while convenient, enables chaotic style of software development.
We must follow best practices for Jupyter Lab to avoid chaos in the Notebooks.
|
|
Jupyter Magics and Resource Profiling
|
For our software to be usable, we need to take care not only of its correctness, but also of its performance.
Profiling is necessary for large computationally expensive projects or for the software that will be processing large datasets.
Finding bottlenecks and ineffective subroutines is an important part of refactoring, but it is also a useful thing to do at the stage of planning the architecture of the software.
|
|
Verifying Code Style Using Linters
|
|
|
Wrap-up
|
|