fd-open-data-protocol 0.5.4__tar.gz → 0.5.5__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.
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/PKG-INFO +1 -1
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/__init__.py +1 -1
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/line_ops/wellknown.py +10 -8
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol.egg-info/PKG-INFO +1 -1
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/tests/test_line_ops.py +13 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/LICENSE +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/README.md +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/conformance_adapter.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/constants.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/line_ops/__init__.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/line_ops/assemble.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/line_ops/auth_gate.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/line_ops/client.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/line_ops/config.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/loader.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/openalex_provider.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/provider.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/registry.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/registry_cli.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/registry_store.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/schema.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/surface_report.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/surface_selfcheck.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/vocabulary/alignment/foundation.yaml +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/vocabulary/concepts.yaml +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/vocabulary/crosswalks/datacommons-worldbank.yaml +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/vocabulary/entity_types.yaml +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/vocabulary/event_types.yaml +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/vocabulary/qualifiers.yaml +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/vocabulary/relation_types.yaml +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/vocabulary/units.yaml +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/vocabulary.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol.egg-info/SOURCES.txt +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol.egg-info/dependency_links.txt +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol.egg-info/entry_points.txt +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol.egg-info/requires.txt +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol.egg-info/top_level.txt +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/pyproject.toml +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/setup.cfg +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/tests/test_drift_inventory.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/tests/test_loader.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/tests/test_openalex_provider.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/tests/test_registry_pipeline.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/tests/test_registry_schema.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/tests/test_schema_vocabulary.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/tests/test_surface_report.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/tests/test_surface_selfcheck.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/tests/test_vocabulary.py +0 -0
- {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/tests/test_vocabulary_additive.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fd-open-data-protocol
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.5
|
|
4
4
|
Summary: The open-data datasource protocol: a manifest contract a datasource exposes to be ingested by fd-open-data-mcp (or any consumer).
|
|
5
5
|
Author: FindDataOfficial
|
|
6
6
|
License: MIT
|
|
@@ -15,7 +15,7 @@ LINE_MANIFEST_ENV = "LINE_MANIFEST_PATH"
|
|
|
15
15
|
MANIFEST_CACHE_CONTROL = "public, max-age=300"
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
def manifest_candidates(anchor: Path | str | None = None) -> list[Path]:
|
|
18
|
+
def manifest_candidates(anchor: Path | str | None = None, *, up: tuple[int, ...] = (1,)) -> list[Path]:
|
|
19
19
|
"""按优先级列出可能放清单的位置(`LINE_MANIFEST_PATH` 一项即封顶)。
|
|
20
20
|
|
|
21
21
|
为什么要链而不是一条:**pip 装进去的包与源码树的 `__file__` 不同**。镜像是
|
|
@@ -33,29 +33,31 @@ def manifest_candidates(anchor: Path | str | None = None) -> list[Path]:
|
|
|
33
33
|
return [Path(override)]
|
|
34
34
|
here = Path(anchor).resolve() if anchor is not None else Path(__file__).resolve()
|
|
35
35
|
return [
|
|
36
|
-
|
|
36
|
+
# Flat layout uses parents[1]; a src/ layout (e.g. paper-trading) needs
|
|
37
|
+
# parents[2] because parents[1] is `src/`. Consumers name their depth.
|
|
38
|
+
*(here.parents[n] / "line-manifest.json" for n in up),
|
|
37
39
|
Path.cwd() / "line-manifest.json", # pip 装的包:CWD 才是仓根
|
|
38
40
|
here.parent / "line-manifest.json", # 清单与包同级(兜底)
|
|
39
41
|
]
|
|
40
42
|
|
|
41
43
|
|
|
42
|
-
def manifest_path(anchor: Path | str | None = None) -> Path:
|
|
44
|
+
def manifest_path(anchor: Path | str | None = None, *, up: tuple[int, ...] = (1,)) -> Path:
|
|
43
45
|
"""实际取用的清单路径;都不存在时返回首选位置(让 404 能点名期望路径)。"""
|
|
44
|
-
candidates = manifest_candidates(anchor)
|
|
46
|
+
candidates = manifest_candidates(anchor, up=up)
|
|
45
47
|
for candidate in candidates:
|
|
46
48
|
if candidate.exists():
|
|
47
49
|
return candidate
|
|
48
50
|
return candidates[0]
|
|
49
51
|
|
|
50
52
|
|
|
51
|
-
def manifest_response(anchor: Path | str | None = None) -> tuple[int, bytes, list[tuple[bytes, bytes]]]:
|
|
53
|
+
def manifest_response(anchor: Path | str | None = None, *, up: tuple[int, ...] = (1,)) -> tuple[int, bytes, list[tuple[bytes, bytes]]]:
|
|
52
54
|
"""(status, body, extra_headers) —— 不读网络、不建会话。
|
|
53
55
|
|
|
54
56
|
缺失=404(该线未发布清单,属配置事实);存在但不可解析=500(属缺陷,不能
|
|
55
57
|
伪装成 404 让调用方以为「本来就没有」)。
|
|
56
58
|
"""
|
|
57
59
|
json_headers = [(b"content-type", b"application/json; charset=utf-8")]
|
|
58
|
-
path = manifest_path(anchor)
|
|
60
|
+
path = manifest_path(anchor, up=up)
|
|
59
61
|
try:
|
|
60
62
|
raw = path.read_bytes()
|
|
61
63
|
except FileNotFoundError:
|
|
@@ -72,7 +74,7 @@ def manifest_response(anchor: Path | str | None = None) -> tuple[int, bytes, lis
|
|
|
72
74
|
]
|
|
73
75
|
|
|
74
76
|
|
|
75
|
-
def register(mcp, anchor: Path | str | None = None) -> None:
|
|
77
|
+
def register(mcp, anchor: Path | str | None = None, *, up: tuple[int, ...] = (1,)) -> None:
|
|
76
78
|
"""Mount the endpoint on a FastMCP instance (stdio has no HTTP face, so skip).
|
|
77
79
|
|
|
78
80
|
``custom_route`` is used rather than wrapping ASGI so the route exists in
|
|
@@ -87,7 +89,7 @@ def register(mcp, anchor: Path | str | None = None) -> None:
|
|
|
87
89
|
from starlette.responses import Response # only the HTTP branch needs it
|
|
88
90
|
|
|
89
91
|
def _response() -> "Response":
|
|
90
|
-
status, body, extra = manifest_response(anchor)
|
|
92
|
+
status, body, extra = manifest_response(anchor, up=up)
|
|
91
93
|
headers = {k.decode(): v.decode() for k, v in extra}
|
|
92
94
|
return Response(
|
|
93
95
|
content=body,
|
{fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fd-open-data-protocol
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.5
|
|
4
4
|
Summary: The open-data datasource protocol: a manifest contract a datasource exposes to be ingested by fd-open-data-mcp (or any consumer).
|
|
5
5
|
Author: FindDataOfficial
|
|
6
6
|
License: MIT
|
|
@@ -238,3 +238,16 @@ def test_register_supports_a_fastapi_style_app(tmp_path):
|
|
|
238
238
|
wellknown.register(app, anchor=anchor)
|
|
239
239
|
response = asyncio.run(app.routes[wellknown.WELL_KNOWN_PATH]())
|
|
240
240
|
assert response.status_code == 200
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def test_src_layout_uses_a_deeper_parent(tmp_path, monkeypatch):
|
|
244
|
+
"""src 布局(src/pkg/wellknown.py)的仓根是 parents[2],由消费仓显式声明。"""
|
|
245
|
+
from fd_open_data_protocol.line_ops import wellknown
|
|
246
|
+
|
|
247
|
+
monkeypatch.delenv(wellknown.LINE_MANIFEST_ENV, raising=False)
|
|
248
|
+
repo = tmp_path / "repo"
|
|
249
|
+
(repo / "src" / "pkg").mkdir(parents=True)
|
|
250
|
+
(repo / "line-manifest.json").write_text("{}")
|
|
251
|
+
anchor = repo / "src" / "pkg" / "wellknown.py"
|
|
252
|
+
anchor.write_text("")
|
|
253
|
+
assert wellknown.manifest_path(anchor, up=(2,)) == repo / "line-manifest.json"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/constants.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/line_ops/client.py
RENAMED
|
File without changes
|
{fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/line_ops/config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/provider.py
RENAMED
|
File without changes
|
{fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/registry.py
RENAMED
|
File without changes
|
{fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/registry_cli.py
RENAMED
|
File without changes
|
{fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/registry_store.py
RENAMED
|
File without changes
|
|
File without changes
|
{fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/surface_report.py
RENAMED
|
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
|
{fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/fd_open_data_protocol/vocabulary.py
RENAMED
|
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
|
|
File without changes
|
{fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.5}/tests/test_vocabulary_additive.py
RENAMED
|
File without changes
|