Skip to content

Identifying the current environment (DEV or PRD)

Blip is currently adopting a new model of data environments. Now, every data squad in Blip have access to two separate environments. One is the development environment (also know as the "dev environment"), and the other, is the production environment (also know as the "prd environment").

For example, the clients squad (also known as the "DEBI-CSPS squad") have access to two different Databricks workspaces. One is the dev environment (Databricks workspace dbw-clients-dev-brazilsouth), and the other, is the prd environment (Databricks workspace dbw-clients-prd-brazilsouth). Every data squad in Blip should have such structure of environments to work with.

The blipdataforge library provide tools to identify which is the current environment that your code is currently running on. Just import the get_context() function from the contexts module of the library, then, use the environment_is_prod property to identify if the current environment is a prd environment or not.

from blipdataforge.contexts import get_context

current_context = get_context()
if current_context.environment_is_prod:
    # Code that runs only on the PRD environment
else:
    # Code that runs only on the DEV environment

This tool might be useful for you, specially for selecting the correct token for each environment, or, selecting the correct API or AWS Bucket addreses for each environment.

Understanding more about these environments

The idea behind a dev and prd environments is to separate a place to play crazy, to test new ideas, to be inovative (the dev environment), from another place which is reserved to be stable and to be safe (the prd environment).

That is the basic difference between these environments. The dev environment should be your playground, where you can test if your code works, or, to develop new features for your product. While the prd environment should only contain code that was already tested, and that it is guaranteed to work well.

Each environment (dev or prd) can be presented in different formats for you depending on the specific data tool that you are using. If you are in Databricks, for example, there are normally two different Databricks workspaces available for you.

Each Databricks workspace represents a particular environment. For example, the DAGeneral squad in Blip have access to the Databricks workspaces dbw-dageneral-dev-brazilsouth and dbw-dageneral-prd-brazilsouth, which are the dev and prd environments, respectively, for this squad in Databricks.

We also have different environments for Azure Data Factory (ADF). So, for example, the DAGeneral squad have two different factories in ADF, one for the dev environment (adf-dageneral-dev-brazilsouth), and the other, for the prd environment (adf-dageneral-prd-brazilsouth).

Some useful resources to understand more: