Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor code cleanup and fetching prev uat.rdf from remote #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
*.js
*.html
*.xlsx

.idea
termrecords/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# release-prep
Check list and scripts to support releasing a new UAT version

## Project Description
This project provides scripts and checklists to facilitate the release of a new UAT version. It includes tools for exporting RDF data, generating release notes, and comparing different versions of the UAT.

## PoolParty Export

Project > Export > RDF Project Export
Expand Down
12 changes: 2 additions & 10 deletions UAT_#.#.#_release_note-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Release Date: ##/##/####
* Added ## new concepts.
* Deprecated ## concepts.
* The preferred label of ## concepts were updated to add context, clarity, and consistency.
* Added or updated AltLabels for ## concepts, remove AltLabels for ## concepts.
* Added or updated AltLabels for ## concepts, removed AltLabels for ## concepts.
* Added ## definition and ## scope notes.
* Added ## new related links, removed ## related links.
* Resolves Issues in [Milestone Colrada](https://github.com/astrothesaurus/UAT/milestone/5?closed=1).
Expand All @@ -24,50 +24,42 @@ Release Date: ##/##/####
| New Concept URI | New Concept PrefLabel |
| --- | --- |


#### Updated the preferred label of ## concepts:

| Concept URI | Old PrefLabel | New PrefLabel |
| --- | --- | --- |


#### Added ## new related concept links:

| Concept URI | Concept PrefLabel | Related Concept URI | Related Concept PrefLabel |
| --- | --- | --- | --- |


#### Alternate Labels added or updated for ## concepts:

| Concept URI | PrefLabel | Alternate Labels |
| --- | --- | --- |


#### Definitions added for ## concepts:

| Concept URI | PrefLabel | Definition |
| --- | --- | --- |


#### Scope Notes added for ## concepts:

| Concept URI | PrefLabel | Scope Note |
| --- | --- | --- |


#### Deprecated ## Concepts:

| Deprecated Concept URI | Deprecated Concept PrefLabel | Reason |
| --- | --- | --- |


#### Removed ## related concept links:

| Concept URI | Concept PrefLabel | Related Concept URI | Related Concept PrefLabel |
| --- | --- | --- | --- |


#### Removed alternate labels for ## concepts:

| Concept URI | PrefLabel | Removed AltLabels |
| --- | --- | --- |
| --- | --- | --- |
136 changes: 56 additions & 80 deletions UAT_transform.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# coding: utf-8
from datetime import datetime

import os
import json
import shutil
import rdflib
import unicodedata
import pandas as pd
from datetime import datetime
from rdflib import URIRef, Graph

print ("Reading the SKOS file...this may take a few seconds.")

timestamp = datetime.now().strftime("%Y_%m%d_%H%M")
timestamp: str = datetime.now().strftime("%Y_%m%d_%H%M")

##### RDF File Location #####
##### assign this variable to location of UAT SKOS-RDF file exported from VocBench #####
Expand All @@ -24,8 +20,8 @@

#reads SKOS-RDF file into a RDFlib graph for use in these scripts
#uat
g = rdflib.Graph()
g.parse((rdf))#.encode('utf8'))
graph: Graph = rdflib.Graph()
graph.parse(rdf)#.encode('utf8'))

# #notes
# h = rdflib.Graph()
Expand All @@ -35,29 +31,30 @@
# k = rdflib.Graph()
# k.parse((depc))#.encode('utf8'))

w3baseUrl: str = 'https://www.w3.org/2009/08/skos-reference/skos.html#'

#defines certain properties within the SKOS-RDF file
prefLabel = rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#prefLabel')
broader = rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#broader')
Concept = rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#Concept')
vocstatus = rdflib.term.URIRef('http://art.uniroma2.it/ontologies/vocbench#hasStatus')
altLabel = rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#altLabel')
TopConcept = rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#topConceptOf')
ednotes = rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#editorialNote')
chnotes = rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#changeNote')
scopenotes = rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#scopeNote')
example = rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#example')
related = rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#related')
definition = rdflib.term.URIRef('http://www.w3.org/2004/02/skos/core#definition')
comment = rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#comment')
title = rdflib.term.URIRef('http://purl.org/dc/terms/title')
label = rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#label')
dep = rdflib.term.URIRef('http://www.w3.org/2002/07/owl#deprecated')
prefLabel: URIRef = rdflib.term.URIRef(w3baseUrl + 'prefLabel')
broader: URIRef = rdflib.term.URIRef(w3baseUrl + 'broader')
Concept: URIRef = rdflib.term.URIRef(w3baseUrl + 'Concept')
altLabel: URIRef = rdflib.term.URIRef(w3baseUrl + 'altLabel')
TopConcept: URIRef = rdflib.term.URIRef(w3baseUrl + 'topConceptOf')
ednotes: URIRef = rdflib.term.URIRef(w3baseUrl + 'editorialNote')
chnotes: URIRef = rdflib.term.URIRef(w3baseUrl + 'changeNote')
scopenotes: URIRef = rdflib.term.URIRef(w3baseUrl + 'scopeNote')
example: URIRef = rdflib.term.URIRef(w3baseUrl + 'example')
related: URIRef = rdflib.term.URIRef(w3baseUrl + 'related')
definition: URIRef = rdflib.term.URIRef(w3baseUrl + 'definition')
comment: URIRef = rdflib.term.URIRef('https://www.w3.org/2000/01/rdf-schema#comment')
title: URIRef = rdflib.term.URIRef('https://www.dublincore.org/specifications/dublin-core/dcmi-terms/#title')
label: URIRef = rdflib.term.URIRef('https://www.w3.org/2000/01/rdf-schema#label')
dep: URIRef = rdflib.term.URIRef('https://www.w3.org/2002/07/owl#deprecated')

#a list of all top concepts
alltopconcepts = [bv for bv in g.subjects(predicate=TopConcept)]
alltopconcepts = [bv for bv in graph.subjects(predicate=TopConcept)]

#a list of all concepts
allconcepts = [gm for gm in g.subjects(rdflib.RDF.type, Concept)]
allconcepts = [gm for gm in graph.subjects(rdflib.RDF.type, Concept)]

# #a list of all concepts
# alldepconcepts = [km for km in k.subjects(rdflib.RDF.type, Concept)]
Expand All @@ -67,7 +64,7 @@ def getnarrowerterms(term):
narrowerterms = {}
terminal = rdflib.term.URIRef(term)
try:
for nts in g.subjects(predicate=broader, object=terminal):
for nts in graph.subjects(predicate=broader, object=terminal):
try:
narrowerterms[terminal].append(nts)
except KeyError:
Expand All @@ -81,7 +78,7 @@ def getbroaderterms(term):
terminal = rdflib.term.URIRef(term)
broaderterms = {}
try:
for bts in g.objects(subject=terminal, predicate=broader):
for bts in graph.objects(subject=terminal, predicate=broader):
try:
broaderterms[terminal].append(bts)
except KeyError:
Expand All @@ -95,7 +92,7 @@ def getaltterms(term):
terminal = rdflib.term.URIRef(term)
alternateterms = {}
try:
for ats in g.objects(subject=terminal, predicate=altLabel):
for ats in graph.objects(subject=terminal, predicate=altLabel):
try:
alternateterms[terminal].append(ats)
except KeyError:
Expand All @@ -112,7 +109,7 @@ def getrelatedterms(term):
terminal = rdflib.term.URIRef(term)
relatedterms = {}
try:
for rts in g.objects(subject=terminal, predicate=related):
for rts in graph.objects(subject=terminal, predicate=related):
try:
relatedterms[terminal].append(rts)
except KeyError:
Expand All @@ -126,15 +123,14 @@ def getednotes(term):
d = rdflib.term.URIRef(term)
# each editorial note in pool party is its own note to iterate over
edlist = []
for ednoteterm in g.objects(subject=d, predicate=ednotes):
for t in g.objects(subject=ednoteterm, predicate=title):
for z in g.objects(subject=ednoteterm, predicate=comment):
for ednoteterm in graph.objects(subject=d, predicate=ednotes):
for t in graph.objects(subject=ednoteterm, predicate=title):
for z in graph.objects(subject=ednoteterm, predicate=comment):
edlist.append({"title": t, "comment": z})

if edlist == []:
if not edlist:
return None
else:
return edlist
return edlist


#a function to return change notes for a term
Expand All @@ -147,96 +143,76 @@ def getchangenotes(term):
d = rdflib.term.URIRef(term)
# each editorial note in pool party is its own note to iterate over
chlist = []
for chnoteterm in g.objects(subject=d, predicate=chnotes):
for t in g.objects(subject=chnoteterm, predicate=title):
for z in g.objects(subject=chnoteterm, predicate=comment):
for chnoteterm in graph.objects(subject=d, predicate=chnotes):
for t in graph.objects(subject=chnoteterm, predicate=title):
for z in graph.objects(subject=chnoteterm, predicate=comment):
chlist.append({"title": t, "comment": z})

if chlist == []:
if not chlist:
return None
else:
return chlist
return chlist

#a function to return scope notes for a term
def getscopenotes(term):
d = rdflib.term.URIRef(term)
for scnoteterm in g.objects(subject=d, predicate=scopenotes):
for scnoteterm in graph.objects(subject=d, predicate=scopenotes):
return scnoteterm

#a function to return example notes for a term
def getexample(term):
d = rdflib.term.URIRef(term)
exlist = []
for termex in g.objects(subject=d, predicate=example):
for termex in graph.objects(subject=d, predicate=example):
exlist.append(termex)

if exlist == []:
if not exlist:
return None
else:
return exlist


#a function to return the status of a term
def getvocstatus(term):
d=rdflib.term.URIRef(term)
for vcstatus in g.objects(subject=d, predicate=vocstatus):
return vcstatus
return exlist

#a function to return the status of a term
def getdefinition(term):
d=rdflib.term.URIRef(term)
for deftest in g.objects(subject=d, predicate=definition):
for deftest in graph.objects(subject=d, predicate=definition):
return deftest

#a function to return the human readable form of the prefered version of a term
#returns default English only
def lit(term):
d = rdflib.term.URIRef(term)
for prefterm in g.objects(subject=d, predicate=prefLabel):
for prefterm in graph.objects(subject=d, predicate=prefLabel):
if prefterm.language == "en": # print only main english language for main pref label
return prefterm

#a function to return the human readable form of the prefered version of a term
#returns Pref Labels in all languages
def lit2(term):
d = rdflib.term.URIRef(term)
prefList = []
for prefterm in g.objects(subject=d, predicate=prefLabel):
prefList.append(prefterm)
return prefList
preflist = []
for prefterm in graph.objects(subject=d, predicate=prefLabel):
preflist.append(prefterm)
return preflist

def getlabel(term):
d = rdflib.term.URIRef(term)
for deplabel in g.objects(subject=d, predicate=label):
for deplabel in graph.objects(subject=d, predicate=label):
return deplabel


def getdepstatus(term):
d = rdflib.term.URIRef(term)
for depcon in g.objects(subject=d, predicate=dep):
for depcon in graph.objects(subject=d, predicate=dep):
return depcon

#returns a list of all deprecated terms in the file
alldepconcepts = []
for term in allconcepts:
depstatus = (getdepstatus(term))
if str(depstatus) == "true":
alldepconcepts.append(term)

def populatedeprecatedterms():
for term in allconcepts:
depstatus = (getdepstatus(term))
if str(depstatus) == "true":
alldepconcepts.append(term)
populatedeprecatedterms()
#print(deprecated)

def getallchilds(term, childlist):
childs = getnarrowerterms(term)
if childs != None:
for kids in childs:
if unicode(lit(kids)) in deprecated:
pass
else:
childlist.append(unicode(lit(kids)))
getallchilds(kids, childlist)




##### Transformation Scripts #####
##### comment out scripts you don't want to run at this time #####
Expand Down
8 changes: 4 additions & 4 deletions checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
* Prepare and finalize local UAT repo, commit changes
* Update UAT transformation scripts in GitHub if needed
* Select new image for website header rotation
* Write annoucement blog post, schedule for release
* Write announcement blog post, schedule for release
* Update this checklist if needed

### Launch Day (Friday)
* Push UAT repo (includes new UAT version, notes, etc) to GitHub
* Upload new json and javascript files to UAT website
* Push new version to UAT API
* Check webtools to make sure everything updated/didn't break:
* [AAS Journal Submission](http://aas.msubmit.net/)
* [UAT Concept Selector](http://astrothesaurus.org/concept-select/)
* [AAS Journal Submission](https://aas.msubmit.net/)
* [UAT Concept Selector](https://astrothesaurus.org/concept-select/)
* [UAT Sorting Tool](https://uat.astrothesaurus.org/)
* [UAT Browse and Search App](https://astrothesaurus.org/thesaurus/search-the-uat/)
* Troubleshoot anything that didn't update or is broken
* Update current version number on [UAT homepage](http://astrothesaurus.org/)
* Update current version number on [UAT homepage](https://astrothesaurus.org/)
* Update current version number on [UAT About Page](https://astrothesaurus.org/about/)
Loading