Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

Merge pull request #587 from aashish254/feat-docs-export-coverage

Nandakishor188aa9fae976
diff --cc docs/reference/helpers.md
index dcedd204,77f12e21..972c520b
--- a/docs/reference/helpers.md
+++ b/docs/reference/helpers.md
@@@ -36,6 -36,8 +36,14 @@@
::: laya.shortlist.embed_fn_from_agent
+ ::: laya.shortlist.cached_embed_fn
+
++## Abstention
++
++::: laya.confidence.check_min_confidence
++
++::: laya.confidence.flag_low_confidence
++
## Calibration and training
::: laya.common.confidence_from_probs
diff --cc tests/test_packaging.py
index 3f8416d0,ff57baac..6402683c
--- a/tests/test_packaging.py
+++ b/tests/test_packaging.py
@@@ -231,45 -231,41 +232,80 @@@ for _dirpath, _dirnames, _filenames in
check("extras/every referenced extra is declared",
sorted(set(_referenced_extras) - _declared_extras), [])
+# ------------------------------------------------------- push concurrency (#399)
+# github.ref is refs/heads/main for every push, so a group of <workflow>-${{ github.ref }}
+# is one group for the whole branch. Rapid merges then cancel each other. Pull requests
+# stay on github.ref (a new commit still cancels the obsolete run); pushes use github.sha.
+# docs.yml has a concurrency group and is included once that group uses this expression.
+# It still deploys GitHub Pages on github.ref so an older build cannot publish over a
+# newer one (#493 left that group ref-scoped on purpose).
+_PER_COMMIT = "github.event_name == 'pull_request' && github.ref || github.sha"
+_BARE_REF_GROUP = re.compile(
+ r"(?m)^[ \t]*group:\s+\S+-\$\{\{\s*github\.ref\s*\}\}(?:\s+#.*)?\s*$"
+)
+
+
+def _concurrency_block(text):
+ match = re.search(r"(?m)^concurrency:\n(?:[ \t]+[^\n]*\n)*", text)
+ return match.group(0) if match else ""
+
+
+_concurrency_workflows = ["ci.yml", "docker.yml", "security.yml"]
+_docs_workflow = read(os.path.join(".github", "workflows", "docs.yml"))
+_docs_concurrency = _concurrency_block(_docs_workflow)
+if _docs_concurrency and _PER_COMMIT in _docs_concurrency:
+ _concurrency_workflows.append("docs.yml")
+
+for _wf in _concurrency_workflows:
+ _text = _docs_workflow if _wf == "docs.yml" else read(os.path.join(".github", "workflows", _wf))
+ _block = _docs_concurrency if _wf == "docs.yml" else _concurrency_block(_text)
+ _stem = _wf[:-4]
+ check_true(
+ "%s/per-commit concurrency for pushes to main" % _wf,
+ ("group: %s-${{ %s }}" % (_stem, _PER_COMMIT)) in _block,
+ "want group: %s-${{ %s }}" % (_stem, _PER_COMMIT),
+ )
+ check_true(
+ "%s/concurrency group is not github.ref alone" % _wf,
+ _block != "" and _BARE_REF_GROUP.search(_block) is None,
+ "a ref-only group collapses every push to main into one run",
+ )
+
+ # --------------------------------------------------------------- the API reference
+ # `laya.__all__` is what `from laya import *` ships and what the README tells people to call, so
+ # an export no page under docs/ names cannot be looked up at all. `cached_embed_fn` was one: the
+ # README documents wrapping an embedder in it, each of its three shortlisting siblings has a
+ # `:::` directive in reference/helpers.md, and it appeared on no docs page.
+ #
+ # Like every other check in this file, this one reads source under the directory it walks and
+ # imports nothing: no `laya.__getattr__` name resolves, torch never loads, and a computed `__all__`
+ # returns [] for the guard below to report instead of an import quietly yielding whatever the
+ # environment happens to have installed.
+ def _exported_names():
+ tree = ast.parse(read(os.path.join("laya", "__init__.py")))
+ for node in tree.body:
+ targets = getattr(node, "targets", [])
+ if isinstance(node, ast.Assign) and any(getattr(t, "id", None) == "__all__" for t in targets):
+ value = node.value
+ if isinstance(value, (ast.List, ast.Tuple, ast.Set)):
+ return [e.value for e in value.elts if isinstance(e, ast.Constant)]
+ return [] # computed `__all__`: the guard below reports it rather than passing
+ return []
+
+
+ _docs_pages = [p for p in _md if p.split(os.sep)[0] == "docs"]
+ _docs_text = "".join(read(p) for p in _docs_pages)
+ _export_list = _exported_names()
+ # Guards, not formalities: an empty page list or an unreadable `__all__` would let the sweep below
+ # pass without checking anything.
+ check_true("docs/reference pages found under docs/", len(_docs_pages) >= 8, _docs_pages[:3])
+ check_true("docs/__all__ read as a literal from laya/__init__.py",
+ len(_export_list) >= 20, len(_export_list))
+
+ _unreferenced = [n for n in _export_list if not re.search(r"\b%s\b" % re.escape(n), _docs_text)]
+ check_true("docs/every exported name appears on a docs page",
+ not _unreferenced, "named nowhere in docs/: %s" % _unreferenced)
+
print("\n%d passed, %d failed" % (len(PASS), len(FAIL)))
for f in FAIL:
print(" FAIL", f)