2. Github

What is Github?

Github is a developer platform that allows developers to create, store, manage and share their code. It uses Git, a distributed version control that tracks changes in any set of computer files, usually used for coordinating work among programmers who are collaboratively developing source code during software development.

Create Github branch from Jira

Creating a branch for Natural State may vary depending on your supervisor. However, as of current, one can create a branch from either Jira or VS Code. This step uses Jira to keep in sync with other assigned workloads in Jira.

For example, go to your assigned subtask in Jira. On the right, you will see a box interface called Details. Next to the Development text, click Create Branch and follow the prompts. Always create a branch from the development branch. This will create a remote Github branch for your assigned task.

Creating branch from Jira

Creating and activating a virtual environment in VS Code

Assuming that the WSL installation and its integration with VS Code successful, there should be a bash terminal option in your VS code terminal dropdown. For most (if not all) of your work in VS Code, you will be using bash.

Bash terminal in VS Code

A virtual environment is an isolated space where you can work on your Python projects, separately from your system-installed Python. It keeps dependencies used by different projects separate.

To create a virtual environment in bash, use the following code:

python3 -m venv .venv

This creates a folder with the name .venv in VS code.

Inside the .venv folder are four foulders, namely bin, include, lib and lib64. Inside the bin folder is the activate file.

To activate our virtual environment, use:

source .venv/bin/activate

Creating a local branch

Unlike the remote branch created via Jira above, a local branch is exists on the local machine and can be seen only by the local user.

It is highly advisable that when working on tasks on your VS code, you create a separate local branch from the default Main branch. For example, to work on task TDW-393-enrich-gx assigned on Jira, create a local branch by inserting this code:

git checkout -b `TDW-393-enrich-gx`

This will create a local branch TDW-393-enrich-gx and automatically switch to that branch. To ensure you are on the right branch, check with git branch.

Cloning from Github

To access code for Natural State, including and excluding for the task of great expectations, assuming that there is already some pre-existing code for your work you may (or will) need to clone a github repository from Natural State’s Github account.

This step will assume you are working with the same folder from which the great expectations work is based on. Therefore you will clone the NIP-Lakehouse-Data repository.

Go to the Code<> dropdown menu inside the NIP-Lakehouse-Data repository.

Copy the link under the HTTPS tab for cloning this repository.

The Github repo url

Go to VS Code bash terminal

To clone the NIP-Lakehouse-Data repository, insert this code:

git clone https://github.com/Natural-State/NIP-Lakehouse-Data.git

Replace the url with the repository for great expectations repository you may be working in, if changed.

This will clone the NIP-Lakehouse-Data repository to your defined directory path in VS Code. The defined directory path becomes your local repository.

In your VS code, navigate to the cloned repository using

cd NIP-Lakehouse

To confirm that you are inside the appropriate local repo, run the below code:

git remote -v

If it returns the url to the remote Github repository you cloned from, you can add and commit changes from here.

Adding and committing

For any changes you make to any file in the local repo, first prepare the changes for committing by inserting git add .

git add . prepares the entire repository, including untouched files for committing. A more focused approach is git add <file_name> or git add <file_name1> <file_name2> for multiple files.

To commit changes, insert git commit -m "<description_of_changes>".

Pushing changes

Assuming you are done with making appropriate changes to your file, you should push changes to the specific branch. For example, assuming you are still in the local branch TDW-393-enrich-gx, you can push your local changes to the remote branch TDW-393-enrich-gx via this code:

git push origin TDW-393-enrich-gx:TDW-393-enrich-gx

The above code will push the commits in the local repository TDW-393 to the online remote repository TDW-393.

From there you can initiate a pull request from Github. Make sure you assign your line manager as reviewer for approval prior to merging.