top of page
  • Writer's pictureMauricio Cordeiro

Why You Should Use Devcontainers for Your Geospatial Development

Discover the advantages of using DevContainers and Codespaces for seamless geospatial development across platforms and devices


Introduction

In one of my latest stories, published here on TDS (Configuring a Minimal Docker Image for Spatial Analysis with Python), I demonstrated how to configure a Docker image for Python with essential geospatial analysis tools such as GDAL and XArray. Managing package dependencies can be challenging, particularly when working with specialized geospatial libraries. In this regard, Docker containers offer an elegant solution for deploying systems to cloud servers. But what about the development process itself? In this post, I’ll discuss the key factors that changed my perspective on managing development environments and how DevContainers and Codespaces can transform geospatial development workflows.

The Reasons

1- The Need for Consistent Environments Across Platforms



I'm working on a new package that pulls climatological data from the Brazilian space research agency (INPE). Last week I had to run this package on my former windows laptop for some performance assessments. This recent experience highlighted the challenges of managing dependencies and configurations across platforms. The new package required support for the GRIB2 data format, which is commonly used by national meteorological centers, weather agencies, and researchers. However, installing the necessary dependencies on Windows proved to be troublesome, ultimately causing my whole development environment to crash. That cost me an entire day trying to fix the windows environment and worse, due to differences in package versions available for each platform I had to workaround syntax disparities in the code. This incident underscored the importance of having a consistent development environment across platforms to avoid such headaches.

2- Complexity of Geospatial Packages

Geospatial packages are essentially scientific software. As so, they are often originate within academia, developed by researchers or interns who may lack proper software engineering expertise. These issues have already been discussed in a previous post: 7 Reasons Why Scientific Software are Not Well Designed.

As a result, these packages frequently suffer from a lack of support, robustness, and proper software engineering design. This complexity can create additional hurdles when trying to set up and maintain development environments, particularly when integrating these packages with other tools and libraries.

To make things worse, some of these packages are built on the top of older softwares and command line tools, that are written in different languages, and putting them to work requires not only the installation of the Python package itself, but separate install procedure also specific configurations on the environment. To cite just one example, the cfgrib requires eccodes library to correctly encode/decode the GRIB2 file format. Taken directly from the eccodes documentation:

3- Accessing Code from Any Device

Another situation that prompted me to reconsider development environment management was when I needed to access my code from my wife’s computer. I know, it is an emergency, but it can happen sometimes when you don't have your laptop available. While all my code was hosted on GitHub, it was not feasible to install all the required development tools on her machine for such small task. This frustration led me to explore DevContainers and Codespaces as potential solutions.

The Solution

DevContainers for Seamless Development

DevContainers, a feature introduced in Visual Studio Code in 2019, allow developers to standardize their development environment across machines. By harnessing the power of Docker containers, DevContainers encapsulate dependencies and configurations, ensuring a consistent experience regardless of the local system.

Simply put, developers can connect VSCode to a container and maintain a high-quality development experience while utilizing containerized environments.

GitHub Codespaces

With DevContainers, setting up a GitHub Codespaces for your projects becomes a breeze. GitHub Codespaces provides a fully-fledged, cloud-powered VSCode environment with support for extensions and various development tools (Figure 1). You can even run Jupyter notebooks inside it, plot maps, and access it from virtually any device with a browser.

As of November 9, 2022, GitHub Codespaces offers 120 free core hours and 15GB of storage each month. It's not enough for full-time coding, but it is a valuable resource for emergency coding situations when your primary development machine is unavailable.

Conclusion

While DevContainers offer numerous advantages, there are some potential drawbacks to be aware of. One such drawback is the need to install Docker on the development machine. For developers who are not familiar with Docker, this requirement may introduce a learning curve and additional complexity to the setup process.

Additionally, running Docker containers can consume significant system resources, which could lead to performance issues on machines with limited hardware capabilities. It is important to consider these drawbacks when deciding whether to adopt DevContainers for geospatial development.

And you? Have you ever experienced using DevContainers or Codespaces? Any other advantages or drawbacks you are facing on? Leave in the comments you thoughts about it.

Thanks and see you in the next article.


155 views0 comments

Comments


bottom of page