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

Issue31 ontologies wout aeon #56

Merged
merged 93 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
55d87fd
ontology terms query
Nov 14, 2020
84570c6
concatonating printouts under same ?term
Nov 15, 2020
e719e43
(nearly)all namespaces + prefixes
Nov 15, 2020
a811f19
test: wip
Nov 15, 2020
221eb52
reverting sparql query to non concatonating version
Nov 15, 2020
6c0a6bf
sparql query: correct typo of subclasof in place of subpropertyof
Nov 15, 2020
3bcefcc
running ontology_terms.rq query in application
Nov 16, 2020
6a7a2a7
wip class SMWCategoryOrProp: should SMW term be cat or prop
Nov 16, 2020
3420ffe
SPARQL requeries var name change: ?subject -> ?term
Nov 16, 2020
88bb073
clarifying excution order n var names in SMWCategoryORProp
Nov 16, 2020
94e7e09
wip:wiki terms definition page's content created - NEEDS WORK
Nov 16, 2020
8931237
sparql query: excluding terms from NSs rdf,drfs,xml,xsd - wiki elemen…
Nov 16, 2020
7e1b08f
prefix look up with both http and https
Nov 16, 2020
6bc4ed6
pytest test_term_creation_from_remote_onto
Nov 17, 2020
dd9fdec
vio added to all_ns_prefixes
Nov 20, 2020
3d8e978
excluding suclass and subproperty values that are blank nodes
Nov 20, 2020
f4f24b5
Property template Equilavent URI uses {{term}}
Nov 20, 2020
44c84a1
all_ns_dict declared outside class
Nov 20, 2020
687ef43
WIP: property Has type:: mapping
Nov 20, 2020
6b4c49c
def determine_smw_prop_datatype in class SMWCategoryORProp
Nov 22, 2020
c5b8dd4
creating overview page
Nov 22, 2020
459c587
removed distracting print
Nov 22, 2020
5e189c5
wikidetails.yml for local from master in issue31 branch
Nov 27, 2020
6326c82
changes from README and setup.py from master
Nov 27, 2020
bf33e2c
updating with MR #38 changes
Nov 29, 2020
ac58b64
updating with MR #39 changes
Nov 29, 2020
6f9f30e
updates from MR #36
Nov 29, 2020
5e823db
dumb commit to see in workflows are run
Nov 29, 2020
2ef2c23
on push to issue31 branch, in additon to master
Nov 29, 2020
5c2414e
Merge pull request #40 from TIBHannover/issu31_updates_from_35_37
Nov 29, 2020
b904fd1
badge
Nov 29, 2020
08c54a5
user prompted to write prefix on ns without prefix
Nov 29, 2020
d61bfbb
remove self.item form SMWCategoryORProp
Dec 2, 2020
14c2b1b
removed redundant jinja de render_template() variable term
Dec 2, 2020
2eb1026
pytest: removed uncessary escapes from regex
Dec 2, 2020
c77033c
in Jinja templates and functions item -> term
Dec 2, 2020
99d3847
term_description: replaced by term_dict['label']
Dec 2, 2020
1f9fb29
term_description_lang replace by term_dict['label'].language
Dec 3, 2020
735b757
warning msg when URI is not resolved
Dec 3, 2020
42b75ca
cli: --format application/rdf+xml -> rdf
Dec 3, 2020
c005200
Merge pull request #42 from TIBHannover/issue41_refactor
Dec 3, 2020
64441b3
self.create_wiki_item() inside def __init__
Dec 3, 2020
60850cb
Merge pull request #44 from TIBHannover/issue41_refactor
Dec 3, 2020
976f82d
test to QueryOntology class
Dec 5, 2020
09c4239
test to QueryOntology class
Dec 5, 2020
2c5703f
clearning texts
Dec 5, 2020
6722776
not smw: for tests that require VM
Dec 5, 2020
9d04166
flake8s
Dec 5, 2020
01e9b82
tox in github actions workflow
Dec 5, 2020
ed52e12
pytest in githuaction workflow
Dec 5, 2020
58e8ed5
always install requirements.txt
Dec 5, 2020
6ed8e5c
actions: macOS-latest added to strategy matrix
Dec 5, 2020
f211dd6
tox with py36 and coverage
Dec 6, 2020
4c2f6b6
tox in github action workflow
Dec 6, 2020
ecf7312
readm me
Dec 6, 2020
e844cdf
github actions back to pytest
Dec 6, 2020
49f2aaf
test to mw+smw vm
Dec 7, 2020
b722d60
removed confident2wikidata_mapping.py
Dec 7, 2020
1fb23fa
test_MWpage
Dec 7, 2020
2710320
tests def determine_smw_catORprop
Dec 7, 2020
9122bd0
flake8
Dec 7, 2020
9b916cf
SMWImportOverview test
Dec 7, 2020
8b64e85
SMWImportOverview with ontology_format arg. replaces hard-coded rdf f…
Dec 7, 2020
53e5a44
revered def query_ontology graph parse format
Dec 7, 2020
9715ebf
tests n code changes for URI resolution
Dec 9, 2020
e961b12
def test_smwimportoverview() execute test against all ontos in onto var
Dec 9, 2020
559b060
flake8s
Dec 9, 2020
75c2a1c
requests Accept headers corrected
Dec 9, 2020
ea0eb5e
Merge pull request #45 from TIBHannover/43_pytest_actions
Dec 9, 2020
1508842
removing last character from prefix if it is numeric
Dec 10, 2020
add1ce8
Basic Report Class
Dec 11, 2020
d27a236
test Report
Dec 11, 2020
60cdaa7
Merge pull request #49 from TIBHannover/47_bfo1_prefix_bug
Dec 11, 2020
d49719e
Merge branch 'issue31_ontologies_wout_aeon' of github.com:TIBHannover…
Dec 11, 2020
3865664
import report under Report.report
Dec 11, 2020
f674365
create report.txt
Dec 11, 2020
131b9b5
when writing: report includes links to the SMW_import pages
Dec 11, 2020
a637783
versobe/no verbose printouts
Dec 15, 2020
dfa1a7c
witing to report.txt
Dec 15, 2020
f17104e
writing content of Mediawiki:Smw_import pages to report.txt
Dec 15, 2020
aa96235
Merge pull request #51 from TIBHannover/48_report_printout
Dec 15, 2020
bbf7997
Terms written to SMW_import pages. Test
Dec 17, 2020
ea36aeb
flake8; Subcategory -> Subproperty in Property definition pages
Dec 17, 2020
f62f806
Merge pull request #52 from TIBHannover/50_bug_empty_SMW_import
Dec 17, 2020
aed9651
README update
Dec 17, 2020
6618abd
smw_import_info in SPARQL & Templates
Dec 17, 2020
01db8a1
rm query_classes_properties.rq
Dec 17, 2020
7ea9253
removed reference to aeon:smw properties from README
Dec 17, 2020
4543ae5
Merge pull request #54 from TIBHannover/53_aeo_smw_import_info
Dec 17, 2020
fe8ec28
pytest in .github/workflows/pytest.yml
Dec 18, 2020
74d9176
pytest badge; flake8 action
Dec 18, 2020
805052f
Merge pull request #55 from TIBHannover/pytest_action
Dec 18, 2020
c8b5480
Merge branch 'master' into issue31_ontologies_wout_aeon
Dec 18, 2020
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
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ exclude =
dist,
build,
prototypes,
test_*,
cli_args.py
notebooks
max-complexity = 10
15 changes: 3 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ name: ontology2smw build

on:
push:
branches: [ master ]
branches: [ master, issue31_ontologies_wout_aeon ]
pull_request:
branches: [ master ]

branches: [ master, issue31_ontologies_wout_aeon ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: [3.6, 3.7, 3.8]
# exclude:
# - os: windows-latest
Expand All @@ -31,11 +30,6 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -V
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install pytest
# pip install -r requirements.txt
- name: install application
run: |
python setup.py install
Expand All @@ -45,6 +39,3 @@ jobs:
- name: run application
run: |
ontology2smw --format ttl --ontology https://raw.githubusercontent.com/tibonto/aeon/master/aeon.ttl
# - name: Test with pytest
# run: |
# pytest
34 changes: 34 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: pytest

on:
push:
branches: [ master, issue31_ontologies_wout_aeon ]
pull_request:
branches: [ master, issue31_ontologies_wout_aeon ]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: install application
run: |
python setup.py install
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -r requirements.txt
- name: pytest
run: |
pytest -m "not smw"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ confident2wikidata_mapping.yml
/.tox/
/vm/.vagrant/
/notebooks/
/report.txt
55 changes: 26 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
![ontology2smw build](https://github.com/TIBHannover/ontology2smw/workflows/ontology2smw%20build/badge.svg)
![pytest](https://github.com/TIBHannover/ontology2smw/workflows/pytest/badge.svg)

# Ontology to SMW
_**Automating an RDF ontology import into Semantic Mediawiki**_

Expand All @@ -10,13 +12,10 @@ the wiki pages, which point to IRIs of the imported ontology(s).
The process of importing is simple, but time consuming. Hence making it a perfect candidate for an automated process,
which can be run at anytime a new version of the ontology is published, hence this python script.

**In order for the terms of an ontology to be imported to SMW instance they should include the property
`aeon:SMW_datatype` and the appropriate [SMW datatype](https://www.semantic-mediawiki.org/wiki/Help:List_of_datatypes) or Category for Classes**

![ontology2smw import workflow](docs/ontology2smw_aeon.svg?raw=true)

Supports:
* python3.6, python3.7, python3.8
* python3.6, python3.7, python3.8


## Install:
Expand All @@ -33,6 +32,7 @@ pip install --upgrade setuptools
python setup.py install
```


## Run:

**Run:**
Expand All @@ -43,12 +43,10 @@ Using a remote ontology:<br/>`ontology2smw --format ttl --ontology https://raw.g

Writing to wiki pages:<br/>`ontology2smw --format ttl --ontology https://raw.githubusercontent.com/tibonto/aeon/master/aeon.ttl --write`

Using local ontology:<br/>`ontology2smw --format ttl --ontology XYZ.ttl`


Asking for help:<br/>`ontology2smw --help`
```bash
usage: __main__.py [-h] [-w] [-o ONTOLOGY] [-f {application/rdf+xml,ttl}]
usage: ontology2smw [-h] [-w] [-o ONTOLOGY] [-f {rdf,ttl}] [-v] [-r]


___
{ . . }
Expand All @@ -61,8 +59,12 @@ optional arguments:
-w, --write writes the output to wiki or file. Default: False (dry-run).
-o ONTOLOGY, --ontology ONTOLOGY
Ontology file or URI. Default: https://raw.githubusercontent.com/tibonto/aeon/master/aeon.ttl
-f {application/rdf+xml,ttl}, --format {application/rdf+xml,ttl}
-f {rdf,ttl}, --format {rdf,ttl}
Ontology format. Default value: ttl
-v, --verbose Verbose output. Default: False.
-r, --report Save report in file report.txt Default: False.


```

<!--
Expand Down Expand Up @@ -92,18 +94,19 @@ Details for that wiki, VM, bot username and password are set in `wikidetails.yml



### Test on local Virtual Machine
### Try on local Virtual Machine
In order to test ontology2smw in action in a isolated virtual
environment, the repository includes a Ansible playbook which creates a VM with Mediawiki installed, and also creates a Bot account for wiki user Admin.

The playbook sets Mediawiki with:
* URL: http://192.168.100.100/w
* SemanticMediawiki extension
* bot account for Admin, with details (in wikidetail.yml):
* user: Admin
* user password: adminpassword
* bot: Admin@ontology2smwbot
* bot password: botpasswordbotpasswordbotpassword
* wiki user: Admin
* wiki user password: adminpassword
* wiki bot: Admin@ontology2smwbot
* wiki bot password: botpasswordbotpasswordbotpassword


Requirements:
* [VirtualBox](https://www.virtualbox.org/)
Expand All @@ -130,23 +133,17 @@ cd ontology2smw
pip install -r requirements.txt
python -m ontology2smw
```


## Properties from other ontologies
...

## queries with [ARQ](https://jena.apache.org/documentation/query/)
`arq --data=aeon/aeon.ttl --query=ontology2smw/queries/ontology.rq`

`arq --data=aeon/aeon.ttl --query=ontology2smw/queries/query_classes.rq`
## Test

`arq --data=aeon/aeon.ttl --query=ontology2smw/queries/query_properties.rq`
**Tox:** automated testing on py36, py37, py38
`tox -p all -v`

* pytest
* flake8s
* test coverage report

# Other Scripts
## confident2wikidata_mapping.py
Script to make a YAML file that holds the mapping of AEON/ConfIDent properties to Wikidata properties,
by parsing the annotation properties aeon:WikidataLabel and aeon:WikidatURI from the recent ontology TTL.

:param source The URL of the recent aeon ontology (defaults to AEON/ConfIDent branch)
:param outfile_path The file path of the YAML generated by the script
**pytest**
* without running target VM running Mediawiki + SMW `pytest -m "not smw"`
* with VM running Mediawiki + SMW `pytest` for all the tests
4 changes: 2 additions & 2 deletions docs/function_calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ BEFORE REFACTORING
* (loop):
* def append_smw_import_content
* instantiate_smwimport
* def query_ontology KEEP
* def get_ontology_details KEEP
* def create_smw_import_pages


AFTER REFACTORING

* def sparql2smwpage
* (loop):
* def query_ontology KEEP
* def get_ontology_details KEEP
* def create_smw_import_pages


Expand Down
2 changes: 1 addition & 1 deletion ontology2smw/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def main():
writetowiki_decision()

sparql2smwpage(
sparql_fn='ontology2smw/queries/query_classes_properties.rq',
sparql_fn='ontology2smw/queries/ontology_terms.rq',
format_=args.format,
source=args.ontology,
)
Expand Down
Loading