Skip to content

Commit 1284bda

Browse files
committed
Slim package assets and enable URL sidecar fallback
1 parent b7052a9 commit 1284bda

10 files changed

Lines changed: 122 additions & 21 deletions
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:2e722187d76b37a11030a2862d0aceea4d4ee1f3ac78e6fd70d2cc3f3357eb1d
3-
size 522
2+
oid sha256:334d3b5456b405bbd86ba819396bf1735c9b3299c9a217f708d48937b67ebb02
3+
size 523

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ target/
174174
*.db
175175
*.pkl
176176
*.pickle
177+
/.cache/*.pkl
178+
/teadata/.cache/*.pkl
177179
!/.cache/boundaries_*.sqlite
178180
!/teadata/.cache/boundaries_*.sqlite
179181
!/.cache/map_payloads_*.sqlite

MANIFEST.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
recursive-include teadata/.cache *.pkl
21
recursive-include teadata/.cache *.pkl.gz
3-
recursive-include teadata/.cache *.sqlite
2+
recursive-include teadata/.cache boundaries_*.sqlite
3+
recursive-include teadata/.cache entities_*.sqlite
44
recursive-include data/private_schools *.csv
5+
global-exclude *.pkl
6+
exclude teadata/.cache/map_payloads_*.sqlite

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,22 @@ PyPI defaults currently documented at:
184184

185185
Reference: <https://docs.pypi.org/project-management/storage-limits/>
186186

187-
Current `teadata` release artifacts for `0.0.118` are above the per-file limit:
187+
Before packaging trim, `0.0.118` artifacts were above the per-file limit:
188188

189-
- wheel: `dist/teadata-0.0.118-py3-none-any.whl` about `448 MB`
190-
- sdist: `dist/teadata-0.0.118.tar.gz` about `446 MB`
189+
- wheel: about `448 MB`
190+
- sdist: about `446 MB`
191191

192-
These exceed the default 100 MB file cap because large `.cache` snapshot/store artifacts are packaged into both distributions.
192+
Current slimmed artifacts are below the limit:
193+
194+
- wheel: `dist/teadata-0.0.118-py3-none-any.whl` about `74 MB`
195+
- sdist: `dist/teadata-0.0.118.tar.gz` about `72 MB`
196+
197+
To stay under PyPI file limits while preserving runtime behavior:
198+
199+
- PyPI package data now includes compressed snapshots (`.pkl.gz`) and selected sidecars (`boundaries_*.sqlite`, `entities_*.sqlite`).
200+
- Uncompressed `.pkl` files are excluded from distributions.
201+
- `map_payloads_*.sqlite` is excluded from distributions; provide it at runtime via `TEADATA_MAP_STORE` or `TEADATA_MAP_STORE_URL`.
202+
- URL-based store discovery supports snapshot-derived sidecar paths, so `TEADATA_*_URL` can hydrate missing local sidecars automatically.
193203

194204
## Release Policy
195205

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ include = ["teadata*"]
9898
exclude = ["tests*", "docs*", "examples*"]
9999

100100
[tool.setuptools.package-data]
101-
teadata = [".cache/*.pkl", ".cache/*.pkl.gz", ".cache/*.sqlite"]
101+
teadata = [".cache/*.pkl.gz", ".cache/boundaries_*.sqlite", ".cache/entities_*.sqlite"]
102102

103103
[tool.setuptools]
104-
include-package-data = true
104+
include-package-data = false
105105

106106
[project.urls]
107107
"Homepage" = "https://github.com/adpena/teadata"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:2e722187d76b37a11030a2862d0aceea4d4ee1f3ac78e6fd70d2cc3f3357eb1d
3-
size 522
2+
oid sha256:334d3b5456b405bbd86ba819396bf1735c9b3299c9a217f708d48937b67ebb02
3+
size 523

teadata/boundary_store.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,24 @@ def _resolve_boundary_store(path: Path, source: str) -> Optional[Path]:
7777
return resolved
7878

7979

80+
def _should_attempt_boundary_resolution(path: Path) -> bool:
81+
if path.exists() and path.is_file():
82+
return True
83+
return bool(os.environ.get("TEADATA_BOUNDARY_STORE_URL"))
84+
85+
8086
def discover_boundary_store(explicit: str | Path | None = None) -> Optional[Path]:
8187
if explicit:
8288
p = Path(explicit)
83-
if p.exists() and p.is_file():
89+
if _should_attempt_boundary_resolution(p):
8490
resolved = _resolve_boundary_store(p, "explicit")
8591
if resolved:
8692
return resolved
8793

8894
env = os.environ.get("TEADATA_BOUNDARY_STORE")
8995
if env:
9096
p = Path(env)
91-
if p.exists() and p.is_file():
97+
if _should_attempt_boundary_resolution(p):
9298
resolved = _resolve_boundary_store(p, "env")
9399
if resolved:
94100
return resolved
@@ -98,7 +104,7 @@ def discover_boundary_store(explicit: str | Path | None = None) -> Optional[Path
98104
snap = _discover_snapshot()
99105
if snap:
100106
candidate = boundary_store_path_for_snapshot(Path(snap))
101-
if candidate and candidate.exists():
107+
if candidate and _should_attempt_boundary_resolution(candidate):
102108
resolved = _resolve_boundary_store(candidate, "snapshot")
103109
if resolved:
104110
return resolved

teadata/entity_store.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,24 @@ def _resolve_entity_store(path: Path, source: str) -> Optional[Path]:
7272
return resolved
7373

7474

75+
def _should_attempt_entity_resolution(path: Path) -> bool:
76+
if path.exists() and path.is_file():
77+
return True
78+
return bool(os.environ.get("TEADATA_ENTITY_STORE_URL"))
79+
80+
7581
def discover_entity_store(explicit: str | Path | None = None) -> Optional[Path]:
7682
if explicit:
7783
p = Path(explicit)
78-
if p.exists() and p.is_file():
84+
if _should_attempt_entity_resolution(p):
7985
resolved = _resolve_entity_store(p, "explicit")
8086
if resolved:
8187
return resolved
8288

8389
env = os.environ.get("TEADATA_ENTITY_STORE")
8490
if env:
8591
p = Path(env)
86-
if p.exists() and p.is_file():
92+
if _should_attempt_entity_resolution(p):
8793
resolved = _resolve_entity_store(p, "env")
8894
if resolved:
8995
return resolved
@@ -93,7 +99,7 @@ def discover_entity_store(explicit: str | Path | None = None) -> Optional[Path]:
9399
snap = _discover_snapshot()
94100
if snap:
95101
candidate = entity_store_path_for_snapshot(Path(snap))
96-
if candidate and candidate.exists():
102+
if candidate and _should_attempt_entity_resolution(candidate):
97103
resolved = _resolve_entity_store(candidate, "snapshot")
98104
if resolved:
99105
return resolved

teadata/map_store.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,24 @@ def _resolve_map_store(path: Path, source: str) -> Optional[Path]:
6565
return resolved
6666

6767

68+
def _should_attempt_map_resolution(path: Path) -> bool:
69+
if path.exists() and path.is_file():
70+
return True
71+
return bool(os.environ.get("TEADATA_MAP_STORE_URL"))
72+
73+
6874
def discover_map_store(explicit: str | Path | None = None) -> Optional[Path]:
6975
if explicit:
7076
p = Path(explicit)
71-
if p.exists() and p.is_file():
77+
if _should_attempt_map_resolution(p):
7278
resolved = _resolve_map_store(p, "explicit")
7379
if resolved:
7480
return resolved
7581

7682
env = os.environ.get("TEADATA_MAP_STORE")
7783
if env:
7884
p = Path(env)
79-
if p.exists() and p.is_file():
85+
if _should_attempt_map_resolution(p):
8086
resolved = _resolve_map_store(p, "env")
8187
if resolved:
8288
return resolved
@@ -86,7 +92,7 @@ def discover_map_store(explicit: str | Path | None = None) -> Optional[Path]:
8692
snap = _discover_snapshot()
8793
if snap:
8894
candidate = map_store_path_for_snapshot(Path(snap))
89-
if candidate and candidate.exists():
95+
if candidate and _should_attempt_map_resolution(candidate):
9096
resolved = _resolve_map_store(candidate, "snapshot")
9197
if resolved:
9298
return resolved

tests/test_store_discovery.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,72 @@ def fake_resolve(path: Path, source: str):
5050

5151
assert found == candidate
5252
assert seen_sources == ["cwd-cache"]
53+
54+
55+
@pytest.mark.parametrize(
56+
(
57+
"module",
58+
"discover_name",
59+
"resolve_name",
60+
"env_name",
61+
"url_env_name",
62+
"snapshot_path_name",
63+
),
64+
[
65+
(
66+
map_store,
67+
"discover_map_store",
68+
"_resolve_map_store",
69+
"TEADATA_MAP_STORE",
70+
"TEADATA_MAP_STORE_URL",
71+
"map_store_path_for_snapshot",
72+
),
73+
(
74+
boundary_store,
75+
"discover_boundary_store",
76+
"_resolve_boundary_store",
77+
"TEADATA_BOUNDARY_STORE",
78+
"TEADATA_BOUNDARY_STORE_URL",
79+
"boundary_store_path_for_snapshot",
80+
),
81+
(
82+
entity_store,
83+
"discover_entity_store",
84+
"_resolve_entity_store",
85+
"TEADATA_ENTITY_STORE",
86+
"TEADATA_ENTITY_STORE_URL",
87+
"entity_store_path_for_snapshot",
88+
),
89+
],
90+
)
91+
def test_discover_store_uses_snapshot_candidate_when_url_is_configured(
92+
monkeypatch,
93+
tmp_path: Path,
94+
module,
95+
discover_name: str,
96+
resolve_name: str,
97+
env_name: str,
98+
url_env_name: str,
99+
snapshot_path_name: str,
100+
):
101+
monkeypatch.delenv(env_name, raising=False)
102+
monkeypatch.setenv(url_env_name, "https://example.com/store.sqlite")
103+
104+
snapshot = tmp_path / "repo_test.pkl.gz"
105+
expected = getattr(module, snapshot_path_name)(snapshot)
106+
assert expected is not None
107+
108+
seen_sources: list[str] = []
109+
110+
def fake_resolve(path: Path, source: str):
111+
seen_sources.append(source)
112+
return path
113+
114+
monkeypatch.setattr(module, "_discover_snapshot", lambda: snapshot)
115+
monkeypatch.setattr(module, resolve_name, fake_resolve)
116+
117+
discover = getattr(module, discover_name)
118+
found = discover()
119+
120+
assert found == expected
121+
assert seen_sources == ["snapshot"]

0 commit comments

Comments
 (0)