Builds PaperTrail from the base skeleton into a full evidence-verification platform for the "Built with Claude: Life Sciences" hackathon (Builder Track). New named-user features (Build Beyond the Bench): - Lab Notebook Companion — rough bench notes -> structured, searchable, grounded experiment records (lib/labNotebook, /console/lab-notebook, migration 0059) - Clinical Trial Matcher — de-identified patient notes -> ranked eligible ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning (lib/trialMatcher, /console/trial-matcher, migrations 0060) Platform: - Deterministic verification moat (biostats recompute, exact-span grounding) - 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar, PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier) - Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise governance (RBAC, /api/v1 gateway, metering, audit chain, retention) - 17 OSS projects assimilated into native TypeScript on our stack (backend/engines retained + credited in NOTICE) - Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site - Next.js 16 upgrade, benchmark harness (honest smoke-test caveat) Licensing: Apache-2.0 (LICENSE + NOTICE).
70 lines
2.2 KiB
Python
70 lines
2.2 KiB
Python
"""Mocks for tests."""
|
|
|
|
from collections.abc import Iterable
|
|
|
|
import torch
|
|
from torch import nn
|
|
|
|
from pykeen.evaluation import Evaluator, MetricResults, RankBasedMetricResults
|
|
from pykeen.nn import Representation
|
|
from pykeen.typing import ExtendedTarget, MappedTriples, RankType, Target
|
|
|
|
__all__ = [
|
|
"CustomRepresentation",
|
|
]
|
|
|
|
|
|
class CustomRepresentation(Representation):
|
|
"""A custom representation module with minimal implementation."""
|
|
|
|
def __init__(self, num_entities: int, shape: tuple[int, ...] = (2,)): # noqa:D107
|
|
super().__init__(max_id=num_entities, shape=shape)
|
|
self.x = nn.Parameter(torch.rand(*shape))
|
|
|
|
def _plain_forward(self, indices: torch.LongTensor | None = None) -> torch.FloatTensor: # noqa: D102
|
|
n = self.max_id if indices is None else indices.shape[0]
|
|
return self.x.unsqueeze(dim=0).repeat(n, *(1 for _ in self.shape))
|
|
|
|
|
|
class MockEvaluator(Evaluator):
|
|
"""A mock evaluator for testing early stopping."""
|
|
|
|
def __init__(
|
|
self,
|
|
key: tuple[str, ExtendedTarget, RankType] | None = None,
|
|
values: Iterable[float] | None = None,
|
|
random_state: int | None = None,
|
|
) -> None:
|
|
super().__init__()
|
|
self.key = RankBasedMetricResults.key_from_string(s=None if key is None else ".".join((*key[1:], key[0])))
|
|
self.random_state = random_state
|
|
if values is None:
|
|
self.values = self.values_iter = None
|
|
else:
|
|
self.values = tuple(values)
|
|
self.values_iter = iter(self.values)
|
|
|
|
def process_scores_(
|
|
self,
|
|
hrt_batch: MappedTriples,
|
|
target: Target,
|
|
true_scores: torch.FloatTensor,
|
|
scores: torch.FloatTensor,
|
|
dense_positive_mask: torch.FloatTensor | None = None,
|
|
) -> None: # noqa: D102
|
|
pass
|
|
|
|
def clear(self): # noqa: D102
|
|
pass
|
|
|
|
def finalize(self) -> MetricResults: # noqa: D102
|
|
result = RankBasedMetricResults.create_random(self.random_state)
|
|
assert self.values_iter is not None
|
|
if self.key not in result.data:
|
|
raise KeyError(self.key)
|
|
result.data[self.key] = next(self.values_iter)
|
|
return result
|
|
|
|
def __repr__(self): # noqa: D105
|
|
return f"{self.__class__.__name__}(values={self.values})"
|