Participants will need to have access to the following resources and tools prior to the training:
- GitHub account - register for a free GitHub account here
- Install GitHub Desktop Please make sure you have some kind of git client installed on your machine. If you are new to Git, please install GitHub Desktop
- Protege - Install Protege 5.5, download it here
- Review tutorial on Contributing to Ontologies
- See 'How to' guide on Pull Requests
What is delivered as part of the course¶
Description: How to create and manage pull requests to ontology files in GitHub.
- How to create a really good pull request
- GitHub Pull Request Workflow
- How to find a reviewer for your pull request in an open source environment
- How to review a pull request
- How to change a pull request in response to review
- How to update from master
- Resolve conflicts on branch
Monarch OBO training Tutorials¶
Pull Requests Part 1¶
Pull Requests Part 2¶
How to create a really good pull request¶
What is a Pull Request?¶
A pull request (PR) is an event in Git where a contributor (you!) asks a maintainer of a Git repository to review changes (e.g. edits to an ontology file) they want to merge into a project (e.g. the owl file) (see reference). A contributor creates a pull request to propose and collaborate on changes to a repository. These changes are proposed in a branch, which ensures that the default branch only contains finished and approved work. See more details here.
How to write a great descriptive title¶
When committing a pull request, you must include a title and a description (more details in the workflow below.) Tips below (adapted from Hugo Dias):
The title of the PR should be self-explanatory
Do: Describe what was changed in the pull request
Example: Add new term: MONDO:0100503 DPH5-related diphthamide-deficiency syndrome`
Don't: write a vague title that has very little meaning.
Example: Add new term
Don't: use the branch name in the pull request (sometimes GitHub will offer this as a default name)
- Example: issue-5024
What kind of information to include in the description¶
- Describe what was changed in the pull request
- Explain why this PR exists
- Make it clear how it does what it sets out to do. E.g., Does it edit the ontology-edit.owl file? Does it edit another file(s)?
- What was your motivation for the chosen solution?
- Use screenshots to demonstrate what has changed. See How to guide on creating screenshots
- Follow the Single Responsibility Principle: The pull request should do only one thing.
- Note: sometimes a small edit can change a lot of code, for example, if you want to change all of the created_by annotations to dc:creator. That's okay.
- The pull request should be atomic: it should be small and self contained with simple changes that affect a little code a possible
- Whenever possible, break pull-requests into smaller ones
- Commit early, commit often
- Include specific information like the ID and label for terms changed. Note, you can easily obtain term metadata like OBO ID, IRI, or the term label in Protege by clicking the three lines above the Annotations box (next to the term name), see screenshot below. You can also copy the IRI in markdown, which is really convenient for pasting into GitHub.
- Make additional changes on a single PR that goes beyond the scope of the ticket or PR. For example, if you are adding a new term, don't also fix definitions or formatting for other terms.
GitHub Pull Request Workflow¶
Update the local copy of the ontology¶
- In GitHub Desktop, navigate to your local ontology directory of your ontology
- Make sure you are on the master/main branch and click Pull origin (or Fetch origin)
Create a New Working Branch¶
- When starting to work on a ticket or making edits to an ontology, you should create a new branch of the repository to edit the ontology file.
- Make sure you are on the master branch before creating a new branch. Please do not create a new branch off of an existing branch (unless the situation explicitly calls for it).
- To create a new branch, click on Current Branch and select New Branch
- Name your branch. Some recommended best practices for branch name are to name the branch after the issue number, for example issue-206. If you are not addressing a ticket per se, you could name the branch: 'initals-edits-date', e.g. nv-edits_2022-07-12, or give it a name specific to what you are doing, e.g. fix-typos-2022-07-12.
Continuing work on an existing Working Branch¶
- If you are continuing to do work on an existing branch, in addition to updating master, go to your branch by selecting Current Branch in GitHub Desktop and either search for or browse for the branch name.
A video is below.
- OPTIONAL: To update the working branch with respect to the current version of the ontology, select Branch from the top menu, Update from master. This step is optional because it is not necessary to work on the current version of the ontology; all changes will be synchronized when git merge is performed.
Editing an ontology on a branch¶
- Create a new branch, open Protege. Protege will display your branch name in the lower left corner (or it will show Git: master)
- Make necessary edits in Protege.
Committing, pushing and making pull requests¶
- Review: GitHub Desktop will display the diff or changes made to the ontology.
- Before committing, view the diff and ensure the changes were intended. Examples of a diff are pasted below. Large diffs are a sign that something went wrong. In this case, do not commit the changes and ask for help instead or consider discarding your changes and starting the edits again. To discard changes, right click on the changed file name and select Discard changes.
Example 1 (Cell Ontology):
Example 2 (Mondo):
Write a good commit messages¶
Commit message: Before Committing, you must add a commit message. In GitHub Desktop in the Commit field in the lower left, there is a subject line and a description.
Give a very descriptive title: Add a descriptive title in the subject line. For example: add new class ONTOLOGY:ID [term name] (e.g. add new class MONDO:0000006 heart disease)
Write a detailed summary of what the change is in the Description box, referring to the issue. The sentence should clearly state how the issue is addressed.
NOTE: You can use the word ‘fixes’ or ‘closes’ in the commit message - these are magic words in GitHub; when used in combination with the ticket number, it will automatically close the ticket. Learn more on this GitHub Help Documentation page about Closing issues via commit messages.
‘Fixes’ and “Closes’ is case-insensitive and can be plural or singular (fixes, closes, fix, close).
If you don’t want to close the ticket, just refer to the ticket # without the word ‘fixes’ or use ‘adresses’ or 'addresses'. The commit will be associated with the correct ticket but the ticket will remain open.
Push: To incorporate the changes into the remote repository, click Commit to [branch name], then click Push.
Make a pull request (PR)¶
- You can either make a pull request (PR) directly from GitHub Desktop, or via the GitHub web browser.
- To make a PR from GitHub Desktop, click the button 'Create Pull Request'. You will be directed to your web browser and GitHub repo.
- Click Create Pull Request.
- If your PR is a work-in-progress and not ready for review, you can save it as a draft PR and convert it to a PR when it is ready for review.
- If you do not create a PR directly from GitHub Dekstop, you can go to your GitHub repo and you will see a yellow banner on top that notifies you of a pending PR.
- Navigate to the tab labeled as ‘Code’. You should see your commit listed at the top of the page in a light yellow box. If you don’t see it, click on the ‘Branches’ link to reveal it in the list, and click on it.
- Click the green button ‘Compare & pull request’ on the right.
- You may now add comments, if applicable and request a reviewer. See section below on reviewers.
- You can see the diff for your file by clicking 'Files Changed'. Examine it as a sanity check.
- Go back to the Conversation tab.
- Click on the green box ‘Pull request’ to generate a pull request.
How to find a reviewer for your pull request in an open source environment¶
- Publicly managed ontologies do not have a structure in place to automatically deal with PRs.
- If you make a PR to an open source project, you should open a separate social channel to the developers to notify them of your PR (e.g. find the project mailing list, Slack, etc.). You should introduce yourself and give some context.
- Depending on the level of your permissions for the repository, you may or may not be able to assign a reviewer yourself.
- If you have write access to the repository, you can assign a reviewer.
- Otherwise, you can tag people in the description of your pull request.
Tips for finding reviewers:
An ontology repository should have an owner assigned. This may be described in the ReadMe file or on the OBO Foundry website. For example, the contact person for Mondo is Nicole Vasilevsky.
- The primary owner can likely review your PR or triage your request to the appropriate person.
- If you are addressing a specific ticket, you may want to assign the person who created the ticket to review.
How to review a pull request (PR)¶
If you are assigned to review a pull request, you should receive an email notification. You can also check for PRs assigned to you by going to https://github.com/pulls/assigned.
What kind of person do we need for what kind of pull request?¶
It depends on what the pull request is addressing. Remember the QC checks will check for things like unsatisfiable classes and many other checks (that vary between ontologies). Your job as a reviewer is to check for things that the QC checks won't pick up and need human judgement.
- If it is content changes, like adding new terms, or reclassifying a term, an ontology curator could review your PR.
- If the PR is addressing quality control or technical aspects, one of the ontology semantic engineers would probably be a good fit.
If you don't know who to assign, we recommend assigning the ontology contact person and they can triage the request.
To review a PR, you should view the 'Files changed' and view the diff(s). You can review changes in a pull request one file at a time.
- While reviewing the files in a pull request, you can leave individual comments on specific changes.
Things to look out for when reviewing a PR:¶
Make sure the changes made address the ticket. In the example above, Sabrina addressed a ticket that requested adding a new term to Mondo, which is what she did on the PR (see https://github.com/monarch-initiative/mondo/pull/5078).
Examples of things to look for in content changes (like adding new terms or revising existing terms):
- Poorly written definitions
- Missing or misformatted database cross-references
- Incorrectly scoped synonyms
Make sure there are not any unintended or unwanted changes on the PR. See example below. Protege reordered the location of a term in the file.
- Check that the logic is correct. This can be a difficult thing to do. Some tips:
- Open the branch in Protege and examine the hierarchy in Protege
- Compare the logic that was use to the logic used in an existing term
- If the ontology uses Design Patterns, ensure the logic is consistent with the Design Patterns
- Ask an expert in ontology logic to help review the PR
- Remember there is no magic bullet to ensuring an ontology is logically sound, but do the best you can
Adding your review¶
- After you finish reviewing each file, you can mark the file as viewed. This collapses the file, helping you identify the files you still need to review.
- A progress bar in the pull request header shows the number of files you've viewed.
- You can leave comments and requests for changes on the PR inline for on the PR when viewing the 'Files changed'.
- You can add a single comment, or start a review if you have multiple comments.
After reviewing the file(s), you can approve the pull request or request additional changes by submitting your review with a summary comment.
Comment (Submit general feedback without explicit approval)
- Approve (Submit feedback and approve merging these changes)
Request changes (Submit feedback that must be addressed before merging)
In addition or instead of adding inline comments, you can leave comments on the Conversation page. The conversation page is a good place to discuss the PR, and for the original creator to respond to the reviewer comments.
GitHub added a 'suggested Changes' feature that allows a PR reviewer to suggest an exact change in a comment in a PR. You can add inline comments and commit your comment using 'inline commits'. Read more about it here.
- Go to the 'Files changed' tab of a pull request
- Hover over the line you want to fix, and a blue box with a plus sign appears near the gutter on the left
- Click that to display the normal line comment form
- Click the button with a plus and minus sign, it adds a suggestion block to the comment text area with the existing text
- You can make changes to the text inside the suggestion box. Note that you can add context for your suggested changes outside of the suggestion block
- When you create the comment, it will show up to the maintainer as a diff
- The maintainer can see what changes you are suggesting and accept them with a click
When are you done with your review?¶
If you review the PR and the changes properly address what was described in the description, then it should be sufficient. Not every PR needs comments, it can be approved without any comments or requests for changes. Feel free to ask for help with your review, and/or assign additional reviewers.
Some of the content above was adapted from GitHub Docs.
How to change a pull request in response to review¶
- Check out your branch in GitHub Desktop and open the file in Protege.
- Make the suggested changes.
- Check the diff.
- Commit your changes on your branch.
- Note, you do not need to create another PR, your commits will show up on the same PR.
- Resolve the comments on the PR.
- Notify the reviewer that your PR is ready for re-review.
How to update from master¶
- In GitHub Desktop, navigate to your branch.
- In the top file menu, select Branch -> Update from master.
Resolve conflicts on branch¶
Conflicts arise when edits are made on two separate branches to the same line in a file. (reference). When editing an ontology file (owl file or obo file), conflicts often arise when adding new terms to an ontology file on separate branches, or when there are a lot of open pull requests.
Conflicts in ontology files can be fixed either on the command line or using GitHub Desktop. In this lesson, we describe how to fix conflicts using GitHub Desktop.
Fix conflicts in GitHub desktop¶
- In GitHub Desktop, go to your master/main branch and fetch pull.
- Go to branch with conflict.
- Pull branch.
- Branch -> update from master.
- Open in Sublime or Atom.
- Make changes in file (open the ontology file in a text editor (like Sublime) and search for the conflicts. These are usually preceded by <<<<<. Fix the conflicts, then save).
- In GitHub Desktop, continue merge.
- In terminal:
open [ontology file name](e.g.
open mondo-edit.obo) or open in Protege manually.
- Save as (nothing should have changed in the diff).
- Check the diff in GitHub online.
Watch a video below with an example fixing a conflict in the Mondo ontology file.
Some examples of conflicts that Nicole fixed in Mondo are below: