@melaya/runner 1.0.39 → 1.0.41

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.
@@ -37,6 +37,35 @@ except ImportError as exc:
37
37
  print(f"ImportError: agentscope.rag not reachable on PYTHONPATH={os.environ.get('PYTHONPATH')!r}: {exc}", file=sys.stderr)
38
38
  sys.exit(2)
39
39
 
40
+ # Ensure NLTK's sentence tokenizer data is on disk. agentscope's readers
41
+ # do `nltk.download(..., quiet=True)` inside the chunking call but with
42
+ # quiet=True a network failure surfaces only as "Resource 'punkt_tab' not
43
+ # found" at sent_tokenize time. We force the download once up-front,
44
+ # loudly, so the user sees a clear network-error if it fails — beats
45
+ # 240 per-file failures with the same opaque message.
46
+ def _ensure_nltk_data() -> None:
47
+ try:
48
+ import nltk # type: ignore
49
+ except ImportError:
50
+ print("nltk missing — runner venv needs `pip install nltk`", file=sys.stderr)
51
+ return
52
+ needed = ["punkt", "punkt_tab"]
53
+ for pkg in needed:
54
+ try:
55
+ nltk.data.find(f"tokenizers/{pkg}")
56
+ except LookupError:
57
+ try:
58
+ ok = nltk.download(pkg, quiet=True)
59
+ if not ok:
60
+ print(f"nltk.download({pkg!r}) returned False — likely offline. "
61
+ f"Run `python -m nltk.downloader {pkg}` once with network.",
62
+ file=sys.stderr)
63
+ except Exception as exc: # noqa: BLE001
64
+ print(f"nltk.download({pkg!r}) failed: {type(exc).__name__}: {exc}",
65
+ file=sys.stderr)
66
+
67
+ _ensure_nltk_data()
68
+
40
69
 
41
70
  def _emit(kind: str, **fields):
42
71
  """Stream a progress event to the runner subprocess parent which
package/dist/pythonEnv.js CHANGED
@@ -108,6 +108,17 @@ const PIP_DEPS = [
108
108
  // ships Windows wheels, MilvusLite does not — using Qdrant for OS
109
109
  // parity across runners.)
110
110
  "ollama",
111
+ // nltk — used by agentscope.rag readers' default split_by="sentence"
112
+ // chunker. Without it, every reader raises ImportError at chunk time
113
+ // (the lazy import happens INSIDE the chunking call, not at module load,
114
+ // so the error surfaces per-file as "nltk is not installed"). The
115
+ // readers also lazily `nltk.download("punkt", quiet=True)` on first use.
116
+ "nltk",
117
+ // pandas — agentscope.rag.ExcelReader uses pandas.read_excel for sheet
118
+ // iteration. Without it, .xlsx files in a Mode B folder fail with
119
+ // "pandas is not installed". Numpy is already in PIP_DEPS (line 57) so
120
+ // the wheel install is fast.
121
+ "pandas",
111
122
  ];
112
123
  export function venvPython() {
113
124
  return platform() === "win32"
package/localRagIngest.py CHANGED
@@ -37,6 +37,35 @@ except ImportError as exc:
37
37
  print(f"ImportError: agentscope.rag not reachable on PYTHONPATH={os.environ.get('PYTHONPATH')!r}: {exc}", file=sys.stderr)
38
38
  sys.exit(2)
39
39
 
40
+ # Ensure NLTK's sentence tokenizer data is on disk. agentscope's readers
41
+ # do `nltk.download(..., quiet=True)` inside the chunking call but with
42
+ # quiet=True a network failure surfaces only as "Resource 'punkt_tab' not
43
+ # found" at sent_tokenize time. We force the download once up-front,
44
+ # loudly, so the user sees a clear network-error if it fails — beats
45
+ # 240 per-file failures with the same opaque message.
46
+ def _ensure_nltk_data() -> None:
47
+ try:
48
+ import nltk # type: ignore
49
+ except ImportError:
50
+ print("nltk missing — runner venv needs `pip install nltk`", file=sys.stderr)
51
+ return
52
+ needed = ["punkt", "punkt_tab"]
53
+ for pkg in needed:
54
+ try:
55
+ nltk.data.find(f"tokenizers/{pkg}")
56
+ except LookupError:
57
+ try:
58
+ ok = nltk.download(pkg, quiet=True)
59
+ if not ok:
60
+ print(f"nltk.download({pkg!r}) returned False — likely offline. "
61
+ f"Run `python -m nltk.downloader {pkg}` once with network.",
62
+ file=sys.stderr)
63
+ except Exception as exc: # noqa: BLE001
64
+ print(f"nltk.download({pkg!r}) failed: {type(exc).__name__}: {exc}",
65
+ file=sys.stderr)
66
+
67
+ _ensure_nltk_data()
68
+
40
69
 
41
70
  def _emit(kind: str, **fields):
42
71
  """Stream a progress event to the runner subprocess parent which
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melaya/runner",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "Run Melaya AI pipelines locally with your own LM Studio or Ollama models",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,