Turtle File Quality Control #32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Turtle File Quality Control | |
on: | |
push: | |
paths: | |
- 'data/**' | |
workflow_dispatch: | |
workflow_run: | |
workflows: [RDF Generation] | |
types: | |
- completed | |
jobs: | |
quality-control: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the repository | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
# Step 2: Set up Python | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
# Step 3: Install RDFLib | |
- name: Install RDFLib | |
run: pip install rdflib | |
# Step 4: Create Validation Script | |
- name: Create Validation Script | |
run: | | |
echo " | |
import sys | |
from rdflib import Graph | |
def validate_turtle(file_path): | |
try: | |
g = Graph() | |
g.parse(file_path, format='turtle') | |
print(f'File {file_path} is valid.') | |
return True | |
except Exception as e: | |
print(f'Error in {file_path}: {e}', file=sys.stderr) | |
return False | |
if __name__ == '__main__': | |
files = sys.argv[1:] | |
all_valid = all(validate_turtle(file) for file in files) | |
with open('qc-status.txt', 'w') as f: | |
f.write('valid' if all_valid else 'not valid') | |
if not all_valid: | |
sys.exit(1) | |
" > validate_ttl.py | |
# Step 5: Validate Turtle Files and Write QC Status | |
- name: Run Turtle Validation | |
run: python validate_ttl.py data/AOPWikiRDF.ttl data/AOPWikiRDF-Genes.ttl data/AOPWikiRDF-Void.ttl | |
# Step 6: Upload QC Status File | |
- name: Upload QC Status | |
uses: actions/upload-artifact@v4 | |
with: | |
name: qc-status | |
path: qc-status.txt | |
retention-days: 7 |