Skip to content

Commit

Permalink
Merge pull request #7 from Kurrawong/jae/update-py3.12
Browse files Browse the repository at this point in the history
chore: upgrade project to support python 3.12
  • Loading branch information
edmondchuc authored Jun 20, 2024
2 parents 00402a8 + 1395873 commit c1ee841
Show file tree
Hide file tree
Showing 23 changed files with 624 additions and 719 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
type: string

env:
PYTHON_VERSION: "3.11"
PYTHON_VERSION: "3.12"
GIT_MAIN_BRANCH: main

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
NODE_VERSION: "18"
PYTHON_VERSION: "3.11"
PYTHON_VERSION: "3.12"
LAMBDA_FUNCTION_NAME: vocexcel
PROJECT_NAME: "vocexcel"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
IMAGE_NAME: ghcr.io/rdflib/vocexcel
PYTHON_VERSION: "3.11"
PYTHON_VERSION: "3.12"
GIT_MAIN_BRANCH: main

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
types: [opened, synchronize, reopened]

env:
PYTHON_VERSION: "3.11"
PYTHON_VERSION: "3.12"

jobs:
test:
Expand Down
1,219 changes: 562 additions & 657 deletions poetry.lock

Large diffs are not rendered by default.

13 changes: 4 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = """Another Excel to RDF converter for SKOS vocabs, \
authors = ["Nicholas Car <nick@kurrawong.ai>"]

[tool.poetry.dependencies]
python = ">=3.8.1,<3.12"
python = ">=3.12,<4.0.0"
openpyxl = "^3.0.9"
rdflib = "^7.0.0"
pydantic = "^1.9.0"
Expand All @@ -15,7 +15,7 @@ dateutils = "^0.6.12"
colorama = "^0.4.4"
Pillow = "^9.1.0"
pytest = "^7.2.0"
setuptools = "^62.3.2"
setuptools = "^70.0.0"
google-api-python-client = "^2.51.0"
pipdeptree = "^2.3.3"
jinja2 = "^3.1.2"
Expand Down Expand Up @@ -44,12 +44,7 @@ build-backend = "poetry.core.masonry.api"
vocexcel = "vocexcel.convert:main"

[tool.ruff]
select = [
"I001",
"I002"
]
select = ["I001", "I002"]

[tool.pytest.ini_options]
pythonpath = [
"."
]
pythonpath = ["."]
2 changes: 2 additions & 0 deletions tests/test_multilingual.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

sys.path.append(str(Path(__file__).parent.parent.absolute() / "vocexcel"))
from pathlib import Path

from rdflib import Graph

from vocexcel import convert

TESTS_DATA_DIR_PATH = Path(__file__).parent.absolute() / "data"
Expand Down
1 change: 1 addition & 0 deletions tests/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from rdflib.namespace import SKOS

from vocexcel import convert

TESTS_DATA_DIR_PATH = Path(__file__).parent.absolute() / "data"


Expand Down
4 changes: 3 additions & 1 deletion tests/test_template_040.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@


def test_empty_template():
with pytest.raises(ConversionError, match=".*7 validation errors for ConceptScheme.*"):
with pytest.raises(
ConversionError, match=".*7 validation errors for ConceptScheme.*"
):
convert.excel_to_rdf(TEMPLATES_DIR_PATH / "VocExcel-template-040.xlsx")


Expand Down
4 changes: 3 additions & 1 deletion tests/test_template_041.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@


def test_empty_template():
with pytest.raises(ConversionError, match=".*7 validation errors for ConceptScheme.*"):
with pytest.raises(
ConversionError, match=".*7 validation errors for ConceptScheme.*"
):
convert.excel_to_rdf(TEMPLATES_DIR_PATH / "VocExcel-template-041.xlsx")


Expand Down
4 changes: 3 additions & 1 deletion tests/test_template_042.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@


def test_empty_template():
with pytest.raises(ConversionError, match=".*7 validation errors for ConceptScheme.*"):
with pytest.raises(
ConversionError, match=".*7 validation errors for ConceptScheme.*"
):
convert.excel_to_rdf(TEMPLATES_DIR_PATH / "VocExcel-template-042.xlsx")


Expand Down
4 changes: 3 additions & 1 deletion tests/test_template_043.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def test_simple():

def test_exhaustive_template_is_isomorphic():
g1 = Graph().parse(TESTS_DATA_DIR_PATH / "043_exhaustive.ttl")
g2 = convert.excel_to_rdf(TESTS_DATA_DIR_PATH / "043_exhaustive.xlsx", output_format="graph")
g2 = convert.excel_to_rdf(
TESTS_DATA_DIR_PATH / "043_exhaustive.xlsx", output_format="graph"
)
assert compare.isomorphic(g1, g2), "Graphs are not Isomorphic"


Expand Down
2 changes: 1 addition & 1 deletion tests/test_template_060.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from rdflib.namespace import SKOS

sys.path.append(str(Path(__file__).parent.parent.absolute() / "vocexcel"))
from vocexcel import convert
from vocexcel.convert_060 import (
excel_to_rdf,
extract_additions_concept_properties,
Expand All @@ -14,7 +15,6 @@
extract_concepts,
extract_prefixes,
)
from vocexcel import convert
from vocexcel.utils import ConversionError, expand_namespaces, load_workbook

TEMPLATES_DIR_PATH = Path(__file__).parent.parent.absolute() / "templates"
Expand Down
17 changes: 10 additions & 7 deletions tests/test_template_070.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
extract_concepts,
extract_prefixes,
)

from vocexcel.utils import load_workbook


TESTS_DATA_DIR_PATH = Path(__file__).parent.absolute() / "data"


Expand All @@ -27,15 +25,17 @@ def test_extract_prefixes(get_excel):
wb = get_excel
n = extract_prefixes(wb["Prefixes"])

assert n == {'ex:': 'http://example.com/'}
assert n == {"ex:": "http://example.com/"}


def test_extract_concept_scheme(get_excel):
wb = get_excel
prefixes = extract_prefixes(wb["Prefixes"])
cs, cs_iri = extract_concept_scheme(wb["Concept Scheme"], prefixes)

assert cs_iri == URIRef("https://pid.geoscience.gov.au/def/voc/ga/GeomorphologySettings")
assert cs_iri == URIRef(
"https://pid.geoscience.gov.au/def/voc/ga/GeomorphologySettings"
)


def test_extract_concepts(get_excel):
Expand All @@ -48,13 +48,16 @@ def test_extract_concepts(get_excel):
for c in cons.subjects(RDF.type, SKOS.Concept):
concepts.append(c)

assert URIRef("https://pid.geoscience.gov.au/def/voc/ga/GeomorphologySettings/Mass_Movement_Process") in concepts
assert (
URIRef(
"https://pid.geoscience.gov.au/def/voc/ga/GeomorphologySettings/Mass_Movement_Process"
)
in concepts
)

assert len(concepts) == 374




# @pytest.mark.xfail(reason="Failing since 0.6.2.")
# def test_extract_collections():
# wb = load_workbook(Path(__file__).parent / "060_simple.xlsx")
Expand Down
11 changes: 6 additions & 5 deletions tests/test_template_071.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
from rdflib.namespace import RDF, SKOS

sys.path.append(str(Path(__file__).parent.parent.absolute() / "vocexcel"))
from vocexcel.convert_071 import extract_prefixes, extract_concept_scheme, extract_concepts

from vocexcel import convert
from vocexcel.utils import ConversionError
from vocexcel.utils import load_workbook

from vocexcel.convert_071 import (
extract_concept_scheme,
extract_concepts,
extract_prefixes,
)
from vocexcel.utils import ConversionError, load_workbook

TEMPLATES_DIR_PATH = Path(__file__).parent.parent.absolute() / "templates"
TESTS_DATA_DIR_PATH = Path(__file__).parent.absolute() / "data"
Expand Down
11 changes: 6 additions & 5 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
sys.path.append(str(Path(__file__).parent.parent.absolute() / "vocexcel"))
from vocexcel.convert import excel_to_rdf


TESTS_DATA_DIR_PATH = Path(__file__).parent.absolute() / "data"


Expand All @@ -18,7 +17,9 @@ def test_validate_070_vocpub_410():

excel_to_rdf(input_exel_file_path, output_file_path=output_file_path)

c, rg, rt = validate(str(output_file_path), shacl_graph=str(validator_file_path), allow_warnings=True)
c, rg, rt = validate(
str(output_file_path), shacl_graph=str(validator_file_path), allow_warnings=True
)

os.unlink(Path(output_file_path))

Expand All @@ -32,10 +33,10 @@ def test_validate_071_vocpub_410():

excel_to_rdf(input_exel_file_path, output_file_path=output_file_path)

c, rg, rt = validate(str(output_file_path), shacl_graph=str(validator_file_path), allow_warnings=True)
c, rg, rt = validate(
str(output_file_path), shacl_graph=str(validator_file_path), allow_warnings=True
)

os.unlink(Path(output_file_path))

assert c


3 changes: 2 additions & 1 deletion tests/web/test_convert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pathlib import Path

from fastapi.testclient import TestClient
from rdflib import Graph
from pathlib import Path

TESTS_DATA_DIR_PATH = Path(__file__).parent.parent.absolute() / "data"

Expand Down
1 change: 0 additions & 1 deletion vocexcel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
__version__ = "0.7.1"

2 changes: 1 addition & 1 deletion vocexcel/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from pydantic import ValidationError

warnings.simplefilter(action='ignore', category=UserWarning)
warnings.simplefilter(action="ignore", category=UserWarning)

THIS_FILE_PATH = Path(__file__)
sys.path.append(str(THIS_FILE_PATH.parent.parent))
Expand Down
4 changes: 1 addition & 3 deletions vocexcel/convert_060.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ def extract_concept_scheme(sheet: Worksheet, prefixes) -> Graph:
g.add((iri, OWL.versionIRI, URIRef(iri + "/" + str(version))))

if custodian is not None:
ISOROLES = Namespace(
"https://linked.data.gov.au/def/data-roles/"
)
ISOROLES = Namespace("https://linked.data.gov.au/def/data-roles/")
g += make_agent(custodian, ISOROLES.custodian, prefixes, iri)
g.bind("isoroles", ISOROLES)

Expand Down
4 changes: 1 addition & 3 deletions vocexcel/convert_063.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ def extract_concept_scheme(

if custodian is not None:
for _custodian in split_and_tidy_to_strings(custodian):
ISOROLES = Namespace(
"https://linked.data.gov.au/def/data-roles/"
)
ISOROLES = Namespace("https://linked.data.gov.au/def/data-roles/")
g += make_agent(_custodian, ISOROLES.custodian, prefixes, iri)
g.bind("isoroles", ISOROLES)

Expand Down
4 changes: 1 addition & 3 deletions vocexcel/convert_070.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ def extract_concept_scheme(

if custodian is not None:
for _custodian in split_and_tidy_to_strings(custodian):
ISOROLES = Namespace(
"https://linked.data.gov.au/def/data-roles/"
)
ISOROLES = Namespace("https://linked.data.gov.au/def/data-roles/")
g += make_agent(_custodian, ISOROLES.custodian, prefixes, iri)
g.bind("isoroles", ISOROLES)

Expand Down
25 changes: 10 additions & 15 deletions vocexcel/convert_071.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@

REG = Namespace("http://purl.org/linked-data/registry#")

from vocexcel.convert_070 import excel_to_rdf as excel_to_rdf_070
from vocexcel.convert_070 import (
extract_additions_concept_properties as extract_additions_concept_properties_070,
)
from vocexcel.convert_070 import extract_collections as extract_collections_070

# from vocexcel.convert_070 import extract_concept_scheme as extract_concept_scheme_070
from vocexcel.convert_070 import extract_concepts as extract_concepts_070
from vocexcel.convert_070 import extract_prefixes as extract_prefixes_070
from vocexcel.utils import (
STATUSES,
VOCDERMODS,
Expand All @@ -18,13 +27,6 @@
make_iri,
split_and_tidy_to_strings,
)
from vocexcel.convert_070 import excel_to_rdf as excel_to_rdf_070

from vocexcel.convert_070 import extract_prefixes as extract_prefixes_070
# from vocexcel.convert_070 import extract_concept_scheme as extract_concept_scheme_070
from vocexcel.convert_070 import extract_concepts as extract_concepts_070
from vocexcel.convert_070 import extract_collections as extract_collections_070
from vocexcel.convert_070 import extract_additions_concept_properties as extract_additions_concept_properties_070


def extract_prefixes(sheet: Worksheet):
Expand Down Expand Up @@ -131,9 +133,7 @@ def extract_concept_scheme(

if custodian is not None:
for _custodian in split_and_tidy_to_strings(custodian):
DATAROLES = Namespace(
"https://linked.data.gov.au/def/data-roles/"
)
DATAROLES = Namespace("https://linked.data.gov.au/def/data-roles/")
g += make_agent(_custodian, DATAROLES.custodian, prefixes, iri)
g.bind("DATAROLES", DATAROLES)

Expand Down Expand Up @@ -215,8 +215,3 @@ def excel_to_rdf(
log_file=log_file,
template_version="0.7.1",
)





0 comments on commit c1ee841

Please sign in to comment.