Files
stack/tests/cli/test_cli_import_without_optional_deps.py
kert f7c31346bb
Some checks failed
CI / lint (push) Successful in 33s
CI / notebooks-smoke (push) Successful in 1m26s
Deploy / notebooks (push) Has been skipped
Deploy / zotero (push) Has been skipped
Deploy / docs (push) Has been skipped
Deploy / api (push) Has been skipped
Deploy / llm (push) Has been skipped
Deploy / mc (push) Has been skipped
Infra CI / notebooks (push) Successful in 51s
Infra CI / zotero (push) Successful in 13s
Infra CI / docs (push) Successful in 20s
Infra CI / api (push) Successful in 1m13s
Infra CI / llm (push) Successful in 45s
Infra CI / mc (push) Failing after 13s
Deploy / report (push) Successful in 14s
CI / test (push) Successful in 14m20s
fix(pfs,cli): the CPT parser imports rex lazily so the stack CLI starts in the api image (no fsspec there) — the nightly Zotero sync and mail poller run inside it (refs #718)
2026-09-11 16:20:23 -04:00

33 lines
1.0 KiB
Python

"""The api image installs the ``cli`` extra only (no fsspec/s3fs/obstore —
those belong to the lake/rex extras). ``stack`` must still start there:
the nightly Zotero sync and the mail poller run inside that image. On
2026-09-11 a module-level ``pfs.cpt_load → pfs.cpt_epub → rex`` import
chain made every ``stack`` invocation in the api image die with
``ModuleNotFoundError: fsspec``."""
from __future__ import annotations
import subprocess
import sys
_PROBE = """
import builtins
_real = builtins.__import__
def _fake(name, *a, **k):
if name.split('.')[0] in {'fsspec', 's3fs', 'obstore'}:
raise ModuleNotFoundError(name)
return _real(name, *a, **k)
builtins.__import__ = _fake
import cli # the `stack` entry point package
import cli.pfs, cli.bib, cli.llm
print('cli ok')
"""
def test_stack_cli_imports_without_lake_extras():
r = subprocess.run(
[sys.executable, "-c", _PROBE], capture_output=True, text=True, check=False
)
assert r.returncode == 0, r.stderr[-1200:]
assert "cli ok" in r.stdout