Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
8 changes: 4 additions & 4 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
build
**/__pycache__/
**/*.egg-info/
**/.pytest_cache
**/.pytest_cache
7 changes: 0 additions & 7 deletions .isort.cfg

This file was deleted.

29 changes: 8 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
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
- id: check-json
- 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:
Expand All @@ -41,29 +33,24 @@ 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:
- id: codespell
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
Expand Down
6 changes: 3 additions & 3 deletions knowledge_graph/querying.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
22 changes: 11 additions & 11 deletions knowledge_graph/querying_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 2 additions & 6 deletions knowledge_graph/triplets_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
),
)

Expand All @@ -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),
Expand Down
37 changes: 37 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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",
]
26 changes: 0 additions & 26 deletions setup.py

This file was deleted.