Skip to content

Commit

Permalink
Merge pull request #9856 from obophenotype/issue-9579-2
Browse files Browse the repository at this point in the history
Documenting differences in ontology files (attempt 2)
  • Loading branch information
matentzn authored Apr 4, 2024
2 parents 66c7e43 + 2ca8da1 commit fd279fa
Show file tree
Hide file tree
Showing 5 changed files with 21,081 additions and 0 deletions.
139 changes: 139 additions & 0 deletions .github/workflows/ontology_diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: 'Create OAK diffs on Pull requests'

on:
# Triggers the workflow on pull request events for the master branch
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build_branch:
runs-on: ubuntu-latest
container: obolibrary/odkfull:v1.5
steps:
- uses: actions/checkout@v4
- name: Build ontology
run: |
cd src/ontology; make IMP=FALSE PAT=FALSE MIR=FALSE hp.obo -B
cp hp.obo tmp/hp-branch.obo
- name: Upload tmp/hp-branch.obo
uses: actions/upload-artifact@v4
with:
name: hp-branch.obo
path: src/ontology/tmp/hp-branch.obo
retention-days: 1
build_main:
runs-on: ubuntu-latest
container: obolibrary/odkfull:v1.5
steps:
- uses: actions/checkout@v3
with:
ref: master
- name: Classify ontology
run: |
cd src/ontology; make IMP=FALSE PAT=FALSE MIR=FALSE hp.obo -B
cp hp.obo tmp/hp-main.obo
- name: Upload tmp/hp-main.obo
uses: actions/upload-artifact@v4
with:
name: hp-main.obo
path: src/ontology/tmp/hp-main.obo
retention-days: 1
diff:
needs:
- build_branch
- build_main
runs-on: ubuntu-latest
container: obolibrary/odkfull:v1.5
steps:
- uses: actions/checkout@v4
- name: Download main build
uses: actions/download-artifact@v4
with:
name: hp-main.obo
path: src/ontology/tmp/
- name: Download branch build
uses: actions/download-artifact@v4
with:
name: hp-branch.obo
path: src/ontology/tmp/
- name: Diff classification
run: |
pip install -U oaklib
cd src/ontology;
runoak -i simpleobo:tmp/hp-main.obo diff -X simpleobo:tmp/hp-branch.obo -o reports/difference_main-branch_base.md --output-type md
- name: Upload diff
uses: actions/upload-artifact@v4
with:
name: difference_main-branch_base.md
path: src/ontology/reports/difference_main-branch_base.md
post_comment:
needs: diff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download reasoned diff
uses: actions/download-artifact@v4
with:
name: difference_main-branch_base.md
path: src/ontology/reports/
# - name: Prepare reasoned comment
# run: "echo \"<details>\n <summary> Here's a diff of how these changes impact the classified ontology: </summary> \n\" >comment.md; cat src/ontology/reports/difference_main-branch_base.md >>comment.md"
# - name: Post reasoned comment
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# uses: NejcZdovc/[email protected]
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# file: "../../comment.md"
# identifier: "REASONED"
# Post or update comment on pull request if difference_md.md exists
- name: Post or update comment on pull request
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = 'src/ontology/reports/difference_main-branch_base.md';
if (fs.existsSync(path)) {
let content = fs.readFileSync(path, 'utf8');
if (content) {
// GitHub's max issue body size is approximately 65536 characters
const maxBodySize = 65536;
const truncateMsg = '\n</details>\n\n ### WARNING: This diff is too large and has been truncated. For full diff see [here](https://github.com/${{ github.repository }}/blob/${{ github.head_ref }}/src/ontology/reports/difference_main-branch_base.md).';
if (content.length > maxBodySize) {
// Truncate the content to fit within the GitHub comment size limit
content = content.substring(0, maxBodySize - truncateMsg.length) + truncateMsg;
}
const { owner, repo } = context.repo;
const { number } = context.issue;
const existingComments = await github.rest.issues.listComments({
owner,
repo,
issue_number: number
});
const existingComment = existingComments.data.find(comment => comment.user.login === 'github-actions[bot]');
if (existingComment) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existingComment.id,
body: content
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number: number,
body: content
});
}
} else {
console.log("The markdown file is empty."); // Debug print if the file is empty
}
} else {
console.log("The markdown file does not exist."); // Debug print if the file does not exist
}
30 changes: 30 additions & 0 deletions src/ontology/hp.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -577,3 +577,33 @@ $(TMPDIR)/hp-%-merged.owl: hp-base.owl tmp/%.owl

mappings:
$(MAKE_FAST) ../mappings/hp-snomed.lexmatch.sssom.tsv

##################
### KGCL Diff ####
##################

.PHONY: kgcl-diff
kgcl-diff: kgcl-diff-release-base

.PHONY: kgcl-diff-md-release-base kgcl-diff-table-release-base kgcl-diff-txt-release-base kgcl-diff-yaml-release-base
kgcl-diff-md-release-base: reports/difference_release_base.md
kgcl-diff-table-release-base: reports/difference_release_base.tsv
kgcl-diff-txt-release-base: reports/difference_release_base.txt
kgcl-diff-yaml-release-base: reports/difference_release_base.yaml
kgcl-diff-release-base: kgcl-diff-md-release-base kgcl-diff-table-release-base kgcl-diff-txt-release-base kgcl-diff-yaml-release-base

tmp/hp-released.obo:
wget http://purl.obolibrary.org/obo/hp.obo -O tmp/hp-released.obo

reports/difference_release_base.md: tmp/hp-released.obo hp.obo
runoak -i simpleobo:tmp/hp-released.obo diff -X simpleobo:hp.obo -o $@ --output-type md

reports/difference_release_base.tsv: tmp/hp-released.obo hp.obo
runoak -i simpleobo:tmp/hp-released.obo diff -X simpleobo:hp.obo \
-o $@ --output-type csv --statistics --group-by-property oio:hasOBONamespace

reports/difference_release_base.txt: tmp/hp-released.obo hp.obo
runoak -i simpleobo:tmp/hp-released.obo diff -X simpleobo:hp.obo -o $@ --output-type kgcl

reports/difference_release_base.yaml: tmp/hp-released.obo hp.obo
runoak -i simpleobo:tmp/hp-released.obo diff -X simpleobo:hp.obo -o $@ --output-type yaml
Loading

0 comments on commit fd279fa

Please sign in to comment.