cbrkit 0.12.0__tar.gz → 0.12.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cbrkit-0.12.0 → cbrkit-0.12.2}/PKG-INFO +1 -1
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/api.py +4 -4
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/cli.py +28 -8
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/loaders.py +1 -1
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/sim/_aggregator.py +1 -1
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/sim/collections.py +2 -2
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/sim/graph/_astar.py +1 -1
- {cbrkit-0.12.0 → cbrkit-0.12.2}/pyproject.toml +1 -1
- {cbrkit-0.12.0 → cbrkit-0.12.2}/LICENSE +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/README.md +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/__init__.py +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/__main__.py +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/helpers.py +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/py.typed +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/retrieval.py +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/sim/__init__.py +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/sim/_attribute_value.py +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/sim/generic.py +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/sim/graph/__init__.py +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/sim/graph/_model.py +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/sim/numbers.py +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/sim/strings/__init__.py +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/sim/strings/taxonomy.py +0 -0
- {cbrkit-0.12.0 → cbrkit-0.12.2}/cbrkit/typing.py +0 -0
|
@@ -23,13 +23,13 @@ retriever = []
|
|
|
23
23
|
retriever_map = {}
|
|
24
24
|
|
|
25
25
|
if settings.retriever is not None and settings.retriever_map is not None:
|
|
26
|
-
retriever = cbrkit.retrieval.load(settings.retriever)
|
|
27
|
-
retriever_map = cbrkit.retrieval.load_map(settings.retriever_map)
|
|
26
|
+
retriever = cbrkit.retrieval.load(settings.retriever.split(","))
|
|
27
|
+
retriever_map = cbrkit.retrieval.load_map(settings.retriever_map.split(","))
|
|
28
28
|
elif settings.retriever is not None:
|
|
29
|
-
retriever = cbrkit.retrieval.load(settings.retriever)
|
|
29
|
+
retriever = cbrkit.retrieval.load(settings.retriever.split(","))
|
|
30
30
|
retriever_map = {str(idx): retriever for idx, retriever in enumerate(retriever)}
|
|
31
31
|
elif settings.retriever_map is not None:
|
|
32
|
-
retriever_map = cbrkit.retrieval.load_map(settings.retriever_map)
|
|
32
|
+
retriever_map = cbrkit.retrieval.load_map(settings.retriever_map.split(","))
|
|
33
33
|
retriever = list(retriever_map.values())
|
|
34
34
|
|
|
35
35
|
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
import os
|
|
6
|
+
import sys
|
|
6
7
|
from pathlib import Path
|
|
8
|
+
from typing import Annotated
|
|
7
9
|
|
|
8
10
|
try:
|
|
11
|
+
import typer
|
|
9
12
|
from rich import print
|
|
10
|
-
from typer import Typer
|
|
11
13
|
except ModuleNotFoundError:
|
|
12
14
|
print(
|
|
13
15
|
"Please install cbrkit with the [cli] extra to use the command line interface."
|
|
@@ -16,7 +18,7 @@ except ModuleNotFoundError:
|
|
|
16
18
|
|
|
17
19
|
import cbrkit
|
|
18
20
|
|
|
19
|
-
app = Typer()
|
|
21
|
+
app = typer.Typer()
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
@app.callback()
|
|
@@ -25,27 +27,45 @@ def app_callback():
|
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
@app.command()
|
|
28
|
-
def retrieve(
|
|
30
|
+
def retrieve(
|
|
31
|
+
casebase_path: Path,
|
|
32
|
+
queries_path: Path,
|
|
33
|
+
retriever: str,
|
|
34
|
+
print_ranking: bool = True,
|
|
35
|
+
) -> None:
|
|
29
36
|
casebase = cbrkit.loaders.path(casebase_path)
|
|
30
37
|
queries = cbrkit.loaders.path(queries_path)
|
|
31
38
|
retrievers = cbrkit.retrieval.load(retriever)
|
|
32
39
|
|
|
33
40
|
for query_name, query in queries.items():
|
|
34
41
|
result = cbrkit.retrieval.apply(casebase, query, retrievers)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
|
|
43
|
+
if print_ranking:
|
|
44
|
+
print(f"Query: {query_name}")
|
|
45
|
+
print(result.ranking)
|
|
46
|
+
print()
|
|
38
47
|
|
|
39
48
|
|
|
40
49
|
@app.command()
|
|
41
|
-
def serve(
|
|
50
|
+
def serve(
|
|
51
|
+
retriever: list[str],
|
|
52
|
+
search_path: Annotated[list[Path], typer.Option(default_factory=list)],
|
|
53
|
+
host: str = "0.0.0.0",
|
|
54
|
+
port: int = 8080,
|
|
55
|
+
reload: bool = False,
|
|
56
|
+
root_path: str = "",
|
|
57
|
+
) -> None:
|
|
42
58
|
import uvicorn
|
|
43
59
|
|
|
44
|
-
|
|
60
|
+
sys.path.extend(str(x) for x in search_path)
|
|
61
|
+
os.environ["CBRKIT_RETRIEVER"] = ",".join(retriever)
|
|
45
62
|
|
|
46
63
|
uvicorn.run(
|
|
47
64
|
"cbrkit.api:app",
|
|
65
|
+
host=host,
|
|
66
|
+
port=port,
|
|
48
67
|
reload=reload,
|
|
68
|
+
root_path=root_path,
|
|
49
69
|
)
|
|
50
70
|
|
|
51
71
|
|
|
@@ -68,7 +68,7 @@ def aggregator(
|
|
|
68
68
|
pooling_func = _pooling_funcs[pooling] if isinstance(pooling, str) else pooling
|
|
69
69
|
|
|
70
70
|
def wrapped_func(similarities: SimSeqOrMap[KeyType, AnyFloat]) -> float:
|
|
71
|
-
assert pooling_weights is None or type(similarities)
|
|
71
|
+
assert pooling_weights is None or type(similarities) is type(pooling_weights)
|
|
72
72
|
|
|
73
73
|
sims: Sequence[float] # noqa: F821
|
|
74
74
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from collections.abc import Callable, Collection, Sequence, Set
|
|
2
2
|
from dataclasses import dataclass, field
|
|
3
3
|
from itertools import product
|
|
4
|
-
from typing import Any, Generic
|
|
4
|
+
from typing import Any, Generic, cast
|
|
5
5
|
|
|
6
6
|
from cbrkit.helpers import dist2sim, unpack_sim
|
|
7
7
|
from cbrkit.typing import FloatProtocol, SimPairFunc, SimType, ValueType
|
|
@@ -52,7 +52,7 @@ def smith_waterman(
|
|
|
52
52
|
|
|
53
53
|
def wrapped_func(x: Sequence[ValueType], y: Sequence[ValueType]) -> float:
|
|
54
54
|
try:
|
|
55
|
-
alignment = smith.SmithWaterman(x, y)
|
|
55
|
+
alignment = smith.SmithWaterman(cast(Sequence, x), cast(Sequence, y))
|
|
56
56
|
alignment.change_matrix(
|
|
57
57
|
core.ScoreMatrix(
|
|
58
58
|
match=match_score, miss=mismatch_penalty, gap=gap_penalty
|
|
@@ -72,7 +72,7 @@ class GraphMapping(Generic[GraphData, NodeKey, NodeData, EdgeKey, EdgeData]):
|
|
|
72
72
|
def is_legal_node_mapping(self, x: NodeKey, y: NodeKey) -> bool:
|
|
73
73
|
"""Check if mapping is legal"""
|
|
74
74
|
|
|
75
|
-
return not (self._is_node_mapped(x) or type(x)
|
|
75
|
+
return not (self._is_node_mapped(x) or type(x) is not type(y))
|
|
76
76
|
|
|
77
77
|
def is_legal_edge_mapping(self, x: EdgeKey, y: EdgeKey) -> bool:
|
|
78
78
|
"""Check if mapping is legal"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|