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

Automate GH Pages build #28

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
444927f
Scaffold for automating GH Pages build
CasperWA Apr 23, 2021
9843053
Update versions
CasperWA Aug 18, 2021
25a9bac
Run pre-commit
CasperWA Aug 18, 2021
5eb2920
Update .gitignore
CasperWA Dec 3, 2021
02f0b71
Use SINTEF/ci-cd for workflows
CasperWA Jul 19, 2022
7df2998
Minor fix to workflow value
CasperWA Jul 19, 2022
b3e5a40
Update pre-commit hooks, add isort
CasperWA Jul 19, 2022
6815d16
Running isort and updating with black max line len
CasperWA Jul 19, 2022
649d226
Update pylint disable statements in codebase
CasperWA Jul 19, 2022
0d274d4
Fix typo
CasperWA Jul 19, 2022
4939fd0
Add `Word` to DDL and create full cif-core ontology
CasperWA Jul 21, 2022
beaa794
Remove auto-generated catalog file
CasperWA Jul 21, 2022
5c98deb
Fallback to online DDL ontology
CasperWA Jul 21, 2022
589a5b4
Add new MkDocs framework documentation
CasperWA Jul 21, 2022
e403a5a
Add documentation landing page
CasperWA Jul 21, 2022
cba0d38
Update documentation with proper links
CasperWA Jul 21, 2022
fcdbb96
Beginning version release overview docs page
CasperWA Jul 21, 2022
9cb4e3b
Create _utils.py to hold utility elements
CasperWA Jul 22, 2022
02944b3
Don't add private module to API docs
CasperWA Jul 22, 2022
f01a711
Implement auto-generation when building docs
CasperWA Jul 22, 2022
3bb1554
Remove ignoring NumPy safety issues
CasperWA Aug 19, 2022
b71bb0a
Fix tests according to updated Generator
CasperWA Aug 19, 2022
9301442
Revert "Remove ignoring NumPy safety issues"
CasperWA Aug 19, 2022
a6aee95
Fix API reference documentation
CasperWA Aug 23, 2022
1fced73
Build docs and dic2owl package in CI
CasperWA Aug 23, 2022
06c6b4b
Install the `build` package in CI
CasperWA Aug 23, 2022
b87b7f8
Ensure dependencies are installed for CI
CasperWA Aug 23, 2022
74c6e15
Fix installing dependencies
CasperWA Aug 23, 2022
42cd2c3
Set `create_dirs` configuration to True
CasperWA Aug 23, 2022
e8aa27f
Only create publish_dir in MkDocs plugin
CasperWA Aug 23, 2022
26a742d
Don't try to set `root_dir` in plugin
CasperWA Aug 23, 2022
2a0a0d4
Attempt at fixing plugin
CasperWA Aug 23, 2022
af3ed16
Update ci/cd hook and use `relative` option
CasperWA Aug 24, 2022
8cf4526
Fix API reference documentation
CasperWA Aug 24, 2022
0f666f8
Merge remote-tracking branch 'origin/main' into automate_gh-pages
CasperWA Feb 6, 2023
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
Prev Previous commit
Next Next commit
Create _utils.py to hold utility elements
CasperWA committed Aug 19, 2022
commit 9cb4e3ba2aaf877059f16886d19df6286c13c63f
26 changes: 26 additions & 0 deletions dic2owl/dic2owl/_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Utility functions, classes, and variables for use in dic2owl."""
from contextlib import redirect_stderr
from os import devnull as DEVNULL

# Remove the print statement concerning 'owlready2_optimized'
# when importing owlready2 (which is imported also in ontopy).
with open(DEVNULL, "w", encoding="utf8") as handle:
with redirect_stderr(handle):
from owlready2 import locstr


def lang_en(string: str) -> locstr:
"""Converted to an English-localized string.

Parameters:
string: The string to be converted.

Returns:
An English-localized string. `locstr` is a `str`-based type.

"""
return locstr(string, lang="en")


class MissingAnnotationError(Exception):
"""Raised when using a CIF dictionary annotation not defined in CIF-DDL."""
27 changes: 3 additions & 24 deletions dic2owl/dic2owl/dic2owl.py
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@
with open(DEVNULL, "w", encoding="utf8") as handle:
with redirect_stderr(handle):
from ontopy import World
from owlready2 import locstr

from dic2owl._utils import MissingAnnotationError, lang_en

if TYPE_CHECKING:
from typing import Any, Sequence, Set, Union
@@ -29,33 +29,12 @@

# Workaround for flaw in EMMO-Python
# To be removed when EMMO-Python doesn't requires ontologies to import SKOS
import ontopy.ontology # pylint: disable=wrong-import-position
import ontopy.ontology # pylint: disable=wrong-import-position,wrong-import-order

ontopy.ontology.DEFAULT_LABEL_ANNOTATIONS = [
"http://www.w3.org/2000/01/rdf-schema#label",
]

ONTOLOGY_DIR = Path(__file__).resolve().parent.parent.parent.joinpath("ontology")
"""The absolute, normalized path to the `ontology` directory in this
repository"""


def lang_en(string: str) -> locstr:
"""Converted to an English-localized string.

Parameters:
string: The string to be converted.

Returns:
An English-localized string. `locstr` is a `str`-based type.

"""
return locstr(string, lang="en")


class MissingAnnotationError(Exception):
"""Raised when using a cif-dictionary annotation not defined in ddl"""


# pylint: disable=too-few-public-methods
class Generator:
@@ -97,7 +76,7 @@ def __init__(
"https://raw.githubusercontent.com/emmo-repo/CIF-ontology/main"
"/ontology/cif-ddl.ttl"
)
self.ddl = self.world.get_ontology(cif_ddl).load()
self.ddl: "Ontology" = self.world.get_ontology(cif_ddl).load()
self.ddl.sync_python_names()
self.onto.imported_ontologies.append(self.ddl)

3 changes: 3 additions & 0 deletions docs/api_reference/_utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# _utils

::: dic2owl._utils