diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 0bedfb0..afd8c68 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -13,20 +13,20 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: - python-version: '3.x' + python-version: "3.14" - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install build twine pip install cloud-utils@https://github.com/hyroai/cloud-utils/tarball/master - name: Build and publish env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist bdist_wheel + python -m build twine upload dist/* \ No newline at end of file diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 21c9aa0..19e14b3 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -13,12 +13,12 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.11"] + python-version: ["3.14"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -27,7 +27,7 @@ jobs: pip install -e . pip install cloud-utils@https://github.com/hyroai/cloud-utils/tarball/master - name: pre-commit - uses: pre-commit/action@v2.0.3 + uses: pre-commit/action@v3.0.1 - name: Test with pytest run: | pytest \ No newline at end of file diff --git a/.gitignore b/.gitignore index 21c6a37..914ad04 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ build **/__pycache__/ **/*.egg-info/ -**/.pytest_cache \ No newline at end of file +**/.pytest_cache diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index 8970a97..0000000 --- a/.isort.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[settings] -float_to_top = true -atomic = true -line_length = 88 -multi_line_output = 3 -include_trailing_comma = true -known_third_party = cloud_utils,dataclasses_json,gamla,phonenumbers,pytest,setuptools diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f3e653c..96e6aa4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,6 @@ -default_language_version: - python: python3.11 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.1.0 hooks: - id: check-added-large-files - id: debug-statements @@ -10,24 +8,18 @@ repos: - id: pretty-format-json args: ["--autofix", "--no-ensure-ascii", "--no-sort-keys"] - - repo: https://github.com/asottile/seed-isort-config - rev: v2.2.0 - hooks: - - id: seed-isort-config - - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: - id: isort - - repo: https://github.com/ambv/black - rev: 21.6b0 + - repo: https://github.com/psf/black + rev: 24.10.0 hooks: - id: black - additional_dependencies: ['click==8.0.4'] - repo: https://github.com/pycqa/flake8 - rev: 3.9.2 + rev: 7.0.0 hooks: - id: flake8 additional_dependencies: @@ -41,17 +33,12 @@ repos: ] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.991 + rev: v1.5.1 hooks: - id: mypy additional_dependencies: - types-PyYAML - - repo: https://github.com/hyroai/lint - rev: 4373c9c07f94b3549b7a8521c5bb62b6698e383d - hooks: - - id: static-analysis - - repo: https://github.com/codespell-project/codespell rev: v2.1.0 hooks: @@ -59,11 +46,11 @@ repos: entry: codespell --ignore-words=.codespell_ignore --quiet-level=4 --check-filenames exclude: \.(csv|json|txt)$ - - repo: https://github.com/myint/autoflake - rev: v1.4 + - repo: https://github.com/PyCQA/autoflake + rev: v2.3.1 hooks: - id: autoflake - entry: autoflake -i --remove-all-unused-imports + args: [--in-place, --remove-all-unused-imports] - repo: https://github.com/pre-commit/mirrors-prettier rev: v2.3.2 diff --git a/knowledge_graph/querying.py b/knowledge_graph/querying.py index a17b6b1..65b061e 100644 --- a/knowledge_graph/querying.py +++ b/knowledge_graph/querying.py @@ -22,9 +22,9 @@ class NodeTitleMissing(Exception): # noqa pass -node_to_graph: Callable[ - [storage.Node], triplets_index.TripletsWithIndex -] = gamla.compose_left(gamla.attrgetter("graph_id"), storage.get_graph) +node_to_graph: Callable[[storage.Node], triplets_index.TripletsWithIndex] = ( + gamla.compose_left(gamla.attrgetter("graph_id"), storage.get_graph) +) get_nodes_by_relations: Callable[ [Iterable[triplet.Element]], Callable[[storage.Node], storage.Nodes] diff --git a/knowledge_graph/querying_raw.py b/knowledge_graph/querying_raw.py index 2aaee69..61e3bb1 100644 --- a/knowledge_graph/querying_raw.py +++ b/knowledge_graph/querying_raw.py @@ -102,17 +102,17 @@ def triplets_with_relation( ) -triggers_and_names_from_kg: Callable[ - [triplets_index.TripletsWithIndex], frozenset -] = gamla.compose_left( - _get_all_trigger_primitives, - gamla.filter( - gamla.anyjuxt( - primitives.kind_equals(primitives.TEXTUAL), - primitives.kind_equals(primitives.NAME), - ) - ), - gamla.map(primitives.text), +triggers_and_names_from_kg: Callable[[triplets_index.TripletsWithIndex], frozenset] = ( + gamla.compose_left( + _get_all_trigger_primitives, + gamla.filter( + gamla.anyjuxt( + primitives.kind_equals(primitives.TEXTUAL), + primitives.kind_equals(primitives.NAME), + ) + ), + gamla.map(primitives.text), + ) ) nodes_with_triggers = gamla.compose_left( diff --git a/knowledge_graph/triplets_index.py b/knowledge_graph/triplets_index.py index 79de3f2..e07d2ca 100644 --- a/knowledge_graph/triplets_index.py +++ b/knowledge_graph/triplets_index.py @@ -85,9 +85,7 @@ def object_relation_index(self) -> _TwoLevelIndex: self, triplets, gamla.timeit_with_label("building object_relation_index")( - gamla.make_index( - map(gamla.groupby, [triplet.object, triplet.relation]) - ) + gamla.make_index(map(gamla.groupby, [triplet.object, triplet.relation])) ), ) @@ -104,9 +102,7 @@ def subject_relation_and_object_type_index(self) -> _ThreeLevelIndex: return gamla.pipe( self, triplets, - gamla.timeit_with_label( - "building subject_relation_and_object_type_index" - )( + gamla.timeit_with_label("building subject_relation_and_object_type_index")( gamla.make_index( [ gamla.groupby(triplet.subject), diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f7e1863 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,37 @@ +[build-system] +requires = ["setuptools>=80", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "knowledge-graph" +version = "0.0.33" +description = "A library to store data in a knowledge graph" +readme = "README.md" +requires-python = ">=3.14" +authors = [{ name = "Hyro AI", email = "contact@hyro.ai" }] +keywords = ["tag1", "tag2"] +dependencies = [ + "dataclasses_json==0.5.7", + "immutables", + "phonenumbers", + "pytest", +] + +[tool.setuptools.packages.find] +where = ["."] +include = ["knowledge_graph*"] + +[tool.isort] +float_to_top = true +atomic = true +line_length = 88 +multi_line_output = 3 +include_trailing_comma = true +known_third_party = [ + "cloud_utils", + "dataclasses_json", + "gamla", + "phonenumbers", + "pytest", + "setuptools", +] diff --git a/setup.py b/setup.py deleted file mode 100644 index cc26d49..0000000 --- a/setup.py +++ /dev/null @@ -1,26 +0,0 @@ -import setuptools - -with open("README.md", "r") as fh: - _LONG_DESCRIPTION = fh.read() - - -setuptools.setup( - name="knowledge-graph", - version="0.0.33", - python_requires=">=3.11", - description="A library to store data in a knowledge graph", - long_description=_LONG_DESCRIPTION, - long_description_content_type="text/markdown", - author="Hyro AI", - author_email="contact@hyro.ai", - url="https://github.com/hyroai/knowledge-graph/", - keywords=["tag1", "tag2"], - classifiers=[], - packages=setuptools.find_namespace_packages(), - install_requires=[ - "dataclasses_json==0.5.7", - "immutables", - "pytest", - "phonenumbers", - ], -)