tablassert 16.6.1__tar.gz → 16.7.0__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.
Files changed (38) hide show
  1. {tablassert-16.6.1 → tablassert-16.7.0}/PKG-INFO +1 -1
  2. {tablassert-16.6.1 → tablassert-16.7.0}/pyproject.toml +1 -1
  3. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/cli.py +30 -3
  4. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/lib.py +25 -15
  5. {tablassert-16.6.1 → tablassert-16.7.0}/LICENSE +0 -0
  6. {tablassert-16.6.1 → tablassert-16.7.0}/README.md +0 -0
  7. {tablassert-16.6.1 → tablassert-16.7.0}/rust/Cargo.lock +0 -0
  8. {tablassert-16.6.1 → tablassert-16.7.0}/rust/Cargo.toml +0 -0
  9. {tablassert-16.6.1 → tablassert-16.7.0}/rust/examples/count_tables.rs +0 -0
  10. {tablassert-16.6.1 → tablassert-16.7.0}/rust/src/fullmap.rs +0 -0
  11. {tablassert-16.6.1 → tablassert-16.7.0}/rust/src/json.rs +0 -0
  12. {tablassert-16.6.1 → tablassert-16.7.0}/rust/src/lib.rs +0 -0
  13. {tablassert-16.6.1 → tablassert-16.7.0}/rust/src/ndjson.rs +0 -0
  14. {tablassert-16.6.1 → tablassert-16.7.0}/rust/src/uuid.rs +0 -0
  15. {tablassert-16.6.1 → tablassert-16.7.0}/rust/tests/build_golden.rs +0 -0
  16. {tablassert-16.6.1 → tablassert-16.7.0}/rust/tests/common/mod.rs +0 -0
  17. {tablassert-16.6.1 → tablassert-16.7.0}/rust/tests/extract_prebuilt.rs +0 -0
  18. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/__init__.py +0 -0
  19. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/_lazy.py +0 -0
  20. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/agent.py +0 -0
  21. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/biolink.py +0 -0
  22. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/coerce.py +0 -0
  23. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/distill.py +0 -0
  24. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/enums.py +0 -0
  25. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/errors.py +0 -0
  26. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/extras.py +0 -0
  27. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/fullmap.py +0 -0
  28. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/graph_target.py +0 -0
  29. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/ingests.py +0 -0
  30. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/log.py +0 -0
  31. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/models.py +0 -0
  32. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/nlp.py +0 -0
  33. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/progress.py +0 -0
  34. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/qc.py +0 -0
  35. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/rig.py +0 -0
  36. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/rs.pyi +0 -0
  37. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/study.py +0 -0
  38. {tablassert-16.6.1 → tablassert-16.7.0}/src/tablassert/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tablassert
3
- Version: 16.6.1
3
+ Version: 16.7.0
4
4
  Classifier: License :: OSI Approved :: Apache Software License
5
5
  Classifier: Development Status :: 5 - Production/Stable
6
6
  Classifier: Intended Audience :: Science/Research
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tablassert"
3
- version = "16.6.1"
3
+ version = "16.7.0"
4
4
  description = "Extract knowledge assertions from tabular data into NCATS Translator-compliant KGX NDJSON — declaratively, with entity resolution and quality control built in."
5
5
  authors = [
6
6
  { name = "Skye Lane Goetz", email = "sgoetz@isbscience.org" }
@@ -49,6 +49,32 @@ BABEL_CLASS_RE: re.Pattern[str] = re.compile(r'<a href="([^"]*_nodes[^"]*\.gz)"'
49
49
  BABEL_SYNONYM_RE: re.Pattern[str] = re.compile(r'<a href="([^"]+\.gz)"')
50
50
 
51
51
 
52
+ def _section_store_path(h: str, head: bool = False, release: bool = False, qc: bool = False) -> Path:
53
+ """Name a section's cached subgraph parquet so build-mode flags never share a cache file.
54
+
55
+ The cached parquet's content depends on the build mode: ``--head`` samples
56
+ rows, ``--release`` applies the release-mode significance filters, and
57
+ ``--qc`` drops fullmap-audit rejects. ``Tcode.collect`` quick-exits on any
58
+ existing store file, skipping the whole op chain, so each mode combination
59
+ must cache under its own suffix or one mode's build is silently reused as
60
+ another's.
61
+
62
+ Args:
63
+ h: Section config hash (``mkhash`` of the section dict).
64
+ head: ``--head`` preview build flag.
65
+ release: ``--release`` build flag.
66
+ qc: ``--qc`` build flag.
67
+
68
+ Returns:
69
+ Store path like ``<h>.parquet`` with ``.head`` / ``.release`` / ``.qc``
70
+ inserted before the extension for each set flag.
71
+ """
72
+ from tablassert.utils import STORE
73
+
74
+ suffix: str = (".head" if head else "") + (".release" if release else "") + (".qc" if qc else "")
75
+ return STORE / f"{h}{suffix}.parquet"
76
+
77
+
52
78
  def _load_table_indexed(args: tuple[int, Path]) -> tuple[int, object]:
53
79
  """Load one table, tagged with its input index (multiprocessing worker).
54
80
 
@@ -162,7 +188,7 @@ def build_graph_pipeline(
162
188
  from tablassert.fullmap import fullmap_db_path
163
189
  from tablassert.lib import Tcode, compile_graph, compile_subgraph
164
190
  from tablassert.progress import flatten_pydantic_error, format_section_compact
165
- from tablassert.utils import STORE, mkhash
191
+ from tablassert.utils import mkhash
166
192
 
167
193
  # Stage 1/6: load tables.
168
194
  progress.stage("Loading Tables")
@@ -204,8 +230,9 @@ def build_graph_pipeline(
204
230
  for s in sections:
205
231
  h: str = mkhash(s)
206
232
  start(f"{Path(str(s['config'])).stem} · {h[:8]}")
207
- # --head preview builds cache to a distinct .head.parquet so they never clobber full builds.
208
- store: Path = STORE / (f"{h}.head.parquet" if head else f"{h}.parquet")
233
+ # Mode flags change the cached parquet's content, so each combination caches
234
+ # to a distinct file and can never quick-exit another mode's build.
235
+ store: Path = _section_store_path(h, head=head, release=release, qc=qc)
209
236
  try:
210
237
  tcode.append(
211
238
  Tcode.model_validate(
@@ -698,11 +698,11 @@ def math_op(lf: pl.LazyFrame, col: str, func: Functions, args: list[Literal[Toke
698
698
  def numeric_columns(names: list[str]) -> list[str]:
699
699
  """Return column names that should be coerced and formatted as numbers.
700
700
 
701
- P-value columns by substring plus the exact ``effect_size`` and
702
- ``study_size`` fields. The old ``sample_size`` / ``relationship_strength`` /
703
- ``supporting_study_size`` names are absent on purpose: the column coercions
704
- rename them to ``study_size`` / ``effect_size`` before ``clean_numeric`` /
705
- ``format_numeric`` run.
701
+ P-value columns by substring plus the exact ``effect_size``,
702
+ ``number_of_cases`` and ``study_size`` fields. The old ``sample_size`` /
703
+ ``relationship_strength`` / ``supporting_study_size`` names are absent on
704
+ purpose: the column coercions rename them to ``study_size`` / ``effect_size``
705
+ before ``clean_numeric`` / ``format_numeric`` run.
706
706
 
707
707
  Args:
708
708
  names: Schema column names to filter.
@@ -710,15 +710,15 @@ def numeric_columns(names: list[str]) -> list[str]:
710
710
  Returns:
711
711
  Subset of ``names`` destined for numeric coercion/formatting.
712
712
  """
713
- # P-value columns by substring plus exact effect-size and study-size fields.
714
- exact: set[str] = {"effect_size", "study_size"}
713
+ # P-value columns by substring plus exact effect-size, case-count and study-size fields.
714
+ exact: set[str] = {"effect_size", "number_of_cases", "study_size"}
715
715
  return [c for c in names if ("p_value" in c.lower()) or (c in exact)]
716
716
 
717
717
 
718
718
  def clean_numeric(lf: pl.LazyFrame) -> pl.LazyFrame:
719
719
  """Coerce numeric annotation columns to Float64, dropping non-numeric values to null.
720
720
 
721
- Only touches p-value, effect-size and study-size columns.
721
+ Only touches p-value, effect-size, number-of-cases and study-size columns.
722
722
 
723
723
  Args:
724
724
  lf: Source LazyFrame.
@@ -746,7 +746,8 @@ def format_numeric(lf: pl.LazyFrame) -> pl.LazyFrame:
746
746
 
747
747
  Remaining numeric columns are emitted as real JSON numbers when the installed
748
748
  biolink model types them ``int`` / ``float`` -- ``effect_size`` (``float``,
749
- biolink-model#1774) and ``study_size`` (``int`` on the inlined ``Study``,
749
+ biolink-model#1774), ``number_of_cases`` (``int`` on the disease/phenotype
750
+ ``Association`` classes) and ``study_size`` (``int`` on the inlined ``Study``,
750
751
  biolink-model#1770) -- and keep the controlled decimal general string notation
751
752
  (``{:.4g}``) only while a slot stays untyped, since such values end up in
752
753
  human-readable text. Null values stay null.
@@ -1045,15 +1046,19 @@ def drop_zero_effect_size(lf: pl.LazyFrame, col: str = "effect_size") -> pl.Lazy
1045
1046
  Notes:
1046
1047
  Only filters when the effect-size column exists; no-op for sections
1047
1048
  without an ``effect_size`` column. Null effect sizes are kept (no
1048
- score was detected for that row).
1049
+ score was detected for that row). The cast is non-strict (like
1050
+ ``clean_numeric``) and paired with ``ne_missing``: a non-numeric cell --
1051
+ e.g. a header row flowing through as data because the ``csv`` op reads
1052
+ with ``has_header=False`` -- becomes null and is kept, dying later at
1053
+ entity resolution instead of crashing the build with a strict-cast error.
1049
1054
  """
1050
1055
  names: list[str] = lf.collect_schema().names()
1051
1056
  if col not in names:
1052
1057
  return lf
1053
- return lf.filter(pl.col(col).is_null() | (pl.col(col).cast(pl.Float64) != 0.0))
1058
+ return lf.filter(pl.col(col).cast(pl.Float64, strict=False).ne_missing(0.0))
1054
1059
 
1055
1060
 
1056
- def drop_low_number_of_cases(lf: pl.LazyFrame, col: str = "number_of_cases", threshold: float = 25.0) -> pl.LazyFrame:
1061
+ def drop_low_number_of_cases(lf: pl.LazyFrame, col: str = "number_of_cases", threshold: float = 10.0) -> pl.LazyFrame:
1057
1062
  """Drop release-mode ``applied_to_treat`` edges whose number of cases is below the threshold.
1058
1063
 
1059
1064
  Args:
@@ -1067,13 +1072,18 @@ def drop_low_number_of_cases(lf: pl.LazyFrame, col: str = "number_of_cases", thr
1067
1072
  Notes:
1068
1073
  Only filters when the number-of-cases column exists; no-op for sections
1069
1074
  without a ``number_of_cases`` column. Null case counts are kept (no count
1070
- was detected for that row). Only wired in for ``applied_to_treat``
1071
- sections at op-construction time, so it never touches other predicates.
1075
+ was detected for that row). The cast is non-strict (like ``clean_numeric``)
1076
+ with ``fill_null(True)``: a non-numeric cell -- e.g. a header row flowing
1077
+ through as data because the ``csv`` op reads with ``has_header=False`` --
1078
+ becomes null and is kept, dying later at entity resolution instead of
1079
+ crashing the build with a strict-cast error. Only wired in for
1080
+ ``applied_to_treat`` sections at op-construction time, so it never
1081
+ touches other predicates.
1072
1082
  """
1073
1083
  names: list[str] = lf.collect_schema().names()
1074
1084
  if col not in names:
1075
1085
  return lf
1076
- return lf.filter(pl.col(col).is_null() | (pl.col(col).cast(pl.Float64) >= threshold))
1086
+ return lf.filter(pl.col(col).cast(pl.Float64, strict=False).ge(threshold).fill_null(True))
1077
1087
 
1078
1088
 
1079
1089
  def idxname(col: Any) -> str:
File without changes
File without changes
File without changes
File without changes
File without changes