From 44d111bc0bd3cf1c161ac49a33a877b379f5d7e5 Mon Sep 17 00:00:00 2001 From: Tim Van Campenhout Date: Thu, 19 Sep 2024 14:09:49 +0200 Subject: [PATCH 1/2] #92 gh actions pyrpoj --- .../workflows/skosprovider_heritagedata.yaml | 38 +++++++ .travis.yml | 15 --- pyproject.toml | 67 +++++++++++ requirements-dev.txt | 105 ++++++++++++++++-- requirements.txt | 39 ++++++- setup.py | 45 -------- tests/test_providers.py | 26 +++-- tox.ini | 22 ---- 8 files changed, 252 insertions(+), 105 deletions(-) create mode 100644 .github/workflows/skosprovider_heritagedata.yaml delete mode 100644 .travis.yml create mode 100644 pyproject.toml delete mode 100644 setup.py delete mode 100644 tox.ini diff --git a/.github/workflows/skosprovider_heritagedata.yaml b/.github/workflows/skosprovider_heritagedata.yaml new file mode 100644 index 0000000..9a53813 --- /dev/null +++ b/.github/workflows/skosprovider_heritagedata.yaml @@ -0,0 +1,38 @@ +name: skosprovider_heritagedata backend tests +on: + push: + paths: + - skosprovider_heritagedata/** + - tests/** + - skosprovider_heritagedata.yaml + - pyproject.toml + - requirements*.txt +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ "3.10", "3.11", "3.12" ] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + # You can test your matrix by printing the current Python version + - name: Display Python version + run: python -c "import sys; print(sys.version)" + + - name: Install python requirements + env: + HATCH_BUILD_NO_HOOKS: true + working-directory: ./ + run: | + pip --version + pip install pip-tools + pip-sync requirements-dev.txt + pip install -e . + + - name: Python tests + run: pytest tests --exitfirst --capture=no -vvv --full-trace diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fdf8783..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: python -os: linux -dist: focal -python: -- 3.9 -- 3.10 -- 3.11 -install: -- pip install -U setuptools -- pip install -r requirements-dev.txt #fix versions -- python setup.py develop -script: -- py.test --cov skosprovider_heritagedata --cov-report term-missing tests -after_success: -- coveralls diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b0569ee --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,67 @@ +[build-system] +requires = ["hatchling", "hatch-fancy-pypi-readme"] +build-backend = "hatchling.build" + +[project] +version = "1.2.1" +name = "skosprovider_heritagedata" +license="MIT" +dynamic = ["readme"] +authors = [ + { name = "Flanders Heritage Agency", email = "ict@onroerenderfgoed.be" }, +] +#license = "GPL-3.0-or-later" +description = "Skosprovider implementation of the heritagedata.org Vocabularies" +requires-python = ">=3.10,<3.13" +keywords = ["rdf", "skos", "skosprovider", "vocabularies", "thesauri"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python", + "Framework :: Pyramid", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +dependencies = [ + "requests==2.32.3", + "skosprovider==1.2.0", + "rdflib==6.3.2", + +] + +[project.urls] +History = "https://github.com/OnroerendErfgoed/skosprovider_heritagedata/blob/master/CHANGES.rst" +Tracker = "https://github.com/OnroerendErfgoed/skosprovider_heritagedata/issues" +Source = "https://github.com/OnroerendErfgoed/skosprovider_heritagedata" +Documentation = "https://skosprovider_heritagedata.readthedocs.io/en/latest/" + +[project.optional-dependencies] +dev = [ + "uv==0.4.1", + "pytest==8.3.3", + "pytest-cov==5.0.0", + "coveralls==4.0.1", + "sphinx==8.0.2", +] + +## +# Build tool specific +## +[tool.hatch.build.targets.wheel] +# In the wheel we want to have skosprovider_heritagedata in the root as python module. +only-include = [ + "/skosprovider_heritagedata", +] + +[tool.hatch.metadata] +# This allows us to use github links as dependencies +allow-direct-references = true + +[tool.hatch.metadata.hooks.fancy-pypi-readme] +content-type = "text/x-rst" +fragments = [ + { path = "README.rst" }, + { path = "CHANGES.rst" }, +] diff --git a/requirements-dev.txt b/requirements-dev.txt index 19d9e70..21af88d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,10 +1,95 @@ -# Runtime requirements ---requirement requirements.txt - -# Testing -pytest==6.2.5 -pytest-cov==3.0.0 -coveralls==3.3.1 - -# Documentation -Sphinx==4.3.0 \ No newline at end of file +alabaster==1.0.0 + # via sphinx +babel==2.16.0 + # via sphinx +cachetools==5.5.0 + # via pyld +certifi==2024.8.30 + # via requests +charset-normalizer==3.3.2 + # via requests +coverage==7.6.1 + # via + # coveralls + # pytest-cov +coveralls==4.0.1 + # via skosprovider-heritagedata (pyproject.toml) +docopt==0.6.2 + # via coveralls +docutils==0.21.2 + # via sphinx +frozendict==2.4.4 + # via pyld +html5lib==1.1 + # via skosprovider +idna==3.10 + # via requests +imagesize==1.4.1 + # via sphinx +iniconfig==2.0.0 + # via pytest +isodate==0.6.1 + # via rdflib +jinja2==3.1.4 + # via sphinx +language-tags==1.2.0 + # via skosprovider +lxml==5.3.0 + # via pyld +markupsafe==2.1.5 + # via jinja2 +packaging==24.1 + # via + # pytest + # sphinx +pluggy==1.5.0 + # via pytest +pygments==2.18.0 + # via sphinx +pyld==2.0.4 + # via skosprovider +pyparsing==3.1.4 + # via rdflib +pytest==8.3.3 + # via + # skosprovider-heritagedata (pyproject.toml) + # pytest-cov +pytest-cov==5.0.0 + # via skosprovider-heritagedata (pyproject.toml) +rdflib==6.3.2 + # via skosprovider-heritagedata (pyproject.toml) +requests==2.32.3 + # via + # skosprovider-heritagedata (pyproject.toml) + # coveralls + # sphinx +rfc3987==1.3.8 + # via skosprovider +six==1.16.0 + # via + # html5lib + # isodate +skosprovider==1.2.0 + # via skosprovider-heritagedata (pyproject.toml) +snowballstemmer==2.2.0 + # via sphinx +sphinx==8.0.2 + # via skosprovider-heritagedata (pyproject.toml) +sphinxcontrib-applehelp==2.0.0 + # via sphinx +sphinxcontrib-devhelp==2.0.0 + # via sphinx +sphinxcontrib-htmlhelp==2.1.0 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-qthelp==2.0.0 + # via sphinx +sphinxcontrib-serializinghtml==2.0.0 + # via sphinx +urllib3==2.2.3 + # via requests +uv==0.4.1 + # via skosprovider-heritagedata (pyproject.toml) +webencodings==0.5.1 + # via html5lib diff --git a/requirements.txt b/requirements.txt index de3d821..2800e21 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,38 @@ -requests==2.31.0 -skosprovider==1.2.0 +cachetools==5.5.0 + # via pyld +certifi==2024.8.30 + # via requests +charset-normalizer==3.3.2 + # via requests +frozendict==2.4.4 + # via pyld +html5lib==1.1 + # via skosprovider +idna==3.10 + # via requests +isodate==0.6.1 + # via rdflib +language-tags==1.2.0 + # via skosprovider +lxml==5.3.0 + # via pyld +pyld==2.0.4 + # via skosprovider +pyparsing==3.1.4 + # via rdflib rdflib==6.3.2 + # via skosprovider-heritagedata (pyproject.toml) +requests==2.32.3 + # via skosprovider-heritagedata (pyproject.toml) +rfc3987==1.3.8 + # via skosprovider +six==1.16.0 + # via + # html5lib + # isodate +skosprovider==1.2.0 + # via skosprovider-heritagedata (pyproject.toml) +urllib3==2.2.3 + # via requests +webencodings==0.5.1 + # via html5lib diff --git a/setup.py b/setup.py deleted file mode 100644 index baa07cd..0000000 --- a/setup.py +++ /dev/null @@ -1,45 +0,0 @@ -import os - -try: - from setuptools import setup, find_packages -except ImportError: - from distutils.core import setup - -here = os.path.abspath(os.path.dirname(__file__)) -README = open(os.path.join(here, 'README.rst')).read() - -packages = [ - 'skosprovider_heritagedata' -] - -requires = [ - 'skosprovider>=1.1.0', - 'requests', - 'rdflib' -] - -setup( - name='skosprovider_heritagedata', - version='1.2.1', - description='Skosprovider implementation of the heritagedata.org Vocabularies', - long_description=README, - long_description_content_type='text/x-rst', - packages=packages, - include_package_data=True, - install_requires=requires, - license='MIT', - zip_safe=False, - classifiers=[ - 'Intended Audience :: Developers', - 'Natural Language :: English', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - ], - author='Flanders Heritage Agency', - author_email='ict@onroerenderfgoed.be', - url='https://github.com/OnroerendErfgoed/skosprovider_heritagedata', - keywords='heritagedata.org skos skosprovider thesauri vocabularies', -) diff --git a/tests/test_providers.py b/tests/test_providers.py index 7a45882..97e28ff 100644 --- a/tests/test_providers.py +++ b/tests/test_providers.py @@ -62,7 +62,7 @@ def test_scheme_uri_not_available(self): def test_get_top_concepts_provider(self): provider = HeritagedataProvider({'id': 'Heritagedata'}, scheme_uri='http://purl.org/heritagedata/schemes/eh_period') - self.assertEqual(len(provider.get_top_concepts()), 8) + self.assertEqual(len(provider.get_top_concepts()), 2) def test_default_language_scottish_gaelic(self): provider_gd = HeritagedataProvider({'id': 'Heritagedata', 'default_language': 'gd'}, scheme_uri='http://purl.org/heritagedata/schemes/1') @@ -93,7 +93,7 @@ def test_get_by_id_concept(self): self.assertEqual(concept['type'], 'concept') self.assertIsInstance(concept['labels'], list) - preflabels = [{'en': 'POST MEDIEVAL'}] + preflabels = [{'en': 'Post Medieval'}] preflabels_conc = [{label.language: label.label} for label in concept['labels'] if label.type == 'prefLabel'] self.assertGreater(len(preflabels_conc), 0) @@ -103,13 +103,17 @@ def test_get_by_id_concept(self): self.assertGreater(len(concept['notes']), 0) self.assertIsNotNone(concept['notes'][0]) self.assertEqual(concept['notes'][0].language, 'en') - self.assertEqual(concept['notes'][0].note, 'Begins with the dissolution of the monasteries and' - ' ends with the death of Queen Victoria. ' - 'Use more specific period where known.') + self.assertEqual( + concept['notes'][0].note, + 'Begins with the dissolution ' + 'of the monasteries (c.1540) and ends with the ' + 'death of Queen Victoria (1901). ' + 'Use more specific period where known.' + ) self.assertEqual(concept['notes'][0].type, 'scopeNote') self.assertEqual(concept['id'], 'PM') - self.assertEqual(len(concept['broader']), 0) + self.assertEqual(len(concept['broader']), 1) self.assertEqual(len(concept['related']), 0) self.assertIn('STU', concept['narrower']) @@ -135,7 +139,7 @@ def test_get_top_display(self): keys_first_display = top_heritagedata_display[0].keys() for key in ['id', 'type', 'label', 'uri']: self.assertIn(key, keys_first_display) - self.assertIn('POST MEDIEVAL', [label['label'] for label in top_heritagedata_display]) + self.assertIn('Centuries', [label['label'] for label in top_heritagedata_display]) def test_get_top_display_sort_sort(self): prov = HeritagedataProvider( @@ -163,10 +167,10 @@ def test_get_top_concepts_sort(self): sorted_by_id = prov.get_top_concepts(sort='id') assert [c['id'] for c in not_sorted] == [c['id'] for c in sorted_by_id] sorted_by_uri = prov.get_top_concepts(sort='uri') - assert len(sorted_by_id) == 8 + assert len(sorted_by_id) == 2 assert len(sorted_by_id) == len(sorted_by_uri) assert [c['id'] for c in sorted_by_id] == [c['id'] for c in sorted_by_uri] - sorted_by_label = prov.get_top_concepts(sort='label') + sorted_by_label = prov.get_top_concepts(sort='label', sort_order='desc') assert len(sorted_by_id) == len(sorted_by_label) assert [c['id'] for c in sorted_by_id] == [c['id'] for c in sorted_by_label] @@ -178,7 +182,7 @@ def test_get_childeren_display(self): keys_first_display = childeren_Heritagedata_pm[0].keys() for key in ['id', 'type', 'label', 'uri']: self.assertIn(key, keys_first_display) - self.assertIn("TUDOR", [label['label'] for label in childeren_Heritagedata_pm]) + self.assertIn("Tudor", [label['label'] for label in childeren_Heritagedata_pm]) def test_get_children_display_sort(self): prov = HeritagedataProvider( @@ -272,7 +276,7 @@ def test_get_items(self): provider = HeritagedataProvider({'id': 'Heritagedata'},service_scheme_uri='http://heritagedata.org/live/services/') res = provider._get_items("getConceptLabelMatch", {'contains': 'VICTORIAN', 'schemeURI': 'http://purl.org/heritagedata/schemes/eh_period'}) self.assertEqual(len(res), 1) - self.assertEqual(res[0]['label'], 'VICTORIAN') + self.assertEqual(res[0]['label'], 'Victorian') self.assertEqual(res[0]['id'], 'VIC') self.assertEqual(res[0]['lang'], 'en') self.assertEqual(res[0]['type'], 'concept') diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 4cfede3..0000000 --- a/tox.ini +++ /dev/null @@ -1,22 +0,0 @@ -[tox] -envlist = py39, py310, py311, cover - -[testenv] -commands = - pip install -r requirements-dev.txt - python setup.py develop - py.test tests -deps = - pytest - -[testenv:cover] -basepython = - python3.9 -commands = - pip install -r requirements-dev.txt - python setup.py develop - py.test --cov skosprovider_heritagedata --cov-report term-missing tests - -deps = - pytest - pytest-cov From 228c3f403c4766a8af9ce7c59b30b94a486fa3a4 Mon Sep 17 00:00:00 2001 From: Tim Van Campenhout Date: Fri, 20 Sep 2024 10:26:18 +0200 Subject: [PATCH 2/2] #92 review fix --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b0569ee..05a65a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ dependencies = [ History = "https://github.com/OnroerendErfgoed/skosprovider_heritagedata/blob/master/CHANGES.rst" Tracker = "https://github.com/OnroerendErfgoed/skosprovider_heritagedata/issues" Source = "https://github.com/OnroerendErfgoed/skosprovider_heritagedata" -Documentation = "https://skosprovider_heritagedata.readthedocs.io/en/latest/" +Documentation = "https://skosprovider-heritagedata.readthedocs.io/en/latest/" [project.optional-dependencies] dev = [