OpenMed 集成能力矩阵:46 个适配器面的机器可读支持清单与离线校验机制 OpenMed 集成能力矩阵46 个适配器面的机器可读支持清单与离线校验机制【免费下载链接】openmedLocal-first healthcare AI: clinical NER HIPAA PII de-identification that runs 100% on-device. 2,200 medical models, 21 languages, Apple MLX Python, no cloud, no patient data leaving your network. Apache-2.0项目地址: https://gitcode.com/GitHub_Trending/ope/openmedOpenMed 是一套本地优先local-first的医疗 AI 工具链围绕临床 NER 与 HIPAA PII 脱敏提供大量生态集成。本文围绕仓库中的 docs/integrations/matrix.md 展开系统讲解 OpenMed 集成能力矩阵Integration Capability Matrix的设计与使用它如何以机器可读的声明式元数据记录每一个集成面Airflow、Beam、Spark、FHIR、HL7 v2、LangChain、spaCy 等 46 项、每种集成的可选依赖、网络/资源策略与离线测试证据以及背后的安全边界与一致性校验机制。读完本文你将掌握如何在不安装任何可选依赖的前提下查询能力矩阵、如何用源码级的校验入口验证矩阵完整性以及如何在接入新生态时快速判断对应的政策类型与证据等级。一、为什么需要一张“能力矩阵”OpenMed 的集成面横跨批处理框架、数据帧库、医疗标准格式与 LLM 生态数据处理Airflow、Dagster、Prefect、Beam/Dataflow、Dask、Ray、Spark、pandas/polars 与各种数据库适配器医疗互操作FHIR、HL7 v2、CDA/C-CDA、OMOP/CDM、OpenMRS、QuickUMLS、scispaCy生成式 AI 生态Haystack、LangChain、LangGraph、LlamaIndex、spaCy、GLiNER-BioMed。面对如此多的接入面docs/integrations/matrix.md承担了“人类可读视图”的角色其底层数据源是openmed.interop.capabilities.INTEGRATION_CAPABILITY_MATRIX——一份声明式、仅依赖标准库、可以被程序直接读取的机器可读元数据。每一行记录一个集成模块的可选依赖、网络或资源策略、以及提供当前支持证据的离线测试文件。该模块的设计目标在源码 docstring 中写得很明确openmed/interop/capabilities.py矩阵是纯声明式且只用标准库的——读取或序列化它不会导入任何集成依赖、不会检查已安装包、也不会访问任何文档或服务 URL。可选依赖从pyproject.toml的 extras 复制而来属于“安装时元数据”矩阵本身不会执行这些依赖的运行时导入。二、三条策略语义local-only / configured-network / user-supplied-resource矩阵中每一行都带有一个policy字段取值只有三种且由源码中的_ALLOWED_POLICIES常量强制约束openmed/interop/capabilities.py策略含义local-only适配器在本地执行转换前提是其依赖与调用方提供的工件artifacts已就绪。不发起任何网络请求。configured-network该集成面可以调用用户配置的端点但“导入或检视能力矩阵”这个动作本身永远不会发起该调用。user-supplied-resource调用方负责提供任何受许可licensed的资源OpenMed 不会下载或捆绑它。矩阵中三条configured-network记录为arrow_flight调用方自托管 Flight 上的认证记录批脱敏、openmrs设施配置的 REST/FHIR2 适配器、remote_function仓库远程函数批量处理器、search_ingest搜索文档信封的脱敏 sidecar——共四条。两条user-supplied-resource记录为quickumls与scispacy二者都需要调用方自行提供受许可的 UMLS 匹配资源。三、完整矩阵46 个能力记录一览下表完整继承了docs/integrations/matrix.md的全部记录。测试文件与文档链接均已转换为仓库根目录相对路径CapabilitySurfaceOptional requirementsPolicyOffline evidenceTest filesDocumentationairflowApache Airflowapache-airflow3.2.2,4local-onlyoffline-unit(1 test file)tests/unit/interop/test_airflow.pyAirflow Redaction Operatorarrow_flightArrow Flightpyarrow16configured-networkoffline-unit(1 test file)tests/unit/integrations/test_arrow_flight.pyArrow Flight De-identificationbeamApache Beamapache-beam2.73,3local-onlyoffline-unit(1 test file)tests/unit/interop/test_beam_transform.pyFeature MapcdaCDA/C-CDAcorelocal-onlyoffline-unit(1 test file)tests/unit/interop/test_cda.pyFHIR Interop HelperscolumnarColumnar redactionpyarrow16local-onlyoffline-unit(1 test file)tests/unit/integrations/test_columnar_redactor.pyColumnar RedactordagsterDagsterdagster1.8,2local-onlyoffline-unit(1 test file)tests/unit/integrations/test_dagster_assets.pyFeature MapdaskDask DataFramedask[dataframe]2024.8local-onlyoffline-unit(1 test file)tests/unit/integrations/test_dask_accessor.pyDask DataFrame De-identificationdataflowApache Beam Dataflowapache-beam2.73,3local-onlyoffline-unit(1 test file)tests/unit/integrations/test_dataflow_processor.pyFeature Mapdataflow_toolEmbedded dataflow toolscorelocal-onlyoffline-unit(1 test file)tests/unit/integrations/test_dataflow_tool_processor.pyFeature Mapdistributed_sqlDistributed SQL UDFcorelocal-onlyoffline-unit(1 test file)tests/unit/integrations/test_distributed_sql_udf.pyDistributed SQL De-identification UDFduckdbDuckDB UDFsduckdb1.0,2,numpy1.26local-onlyoffline-unit(1 test file)tests/unit/interop/test_duckdb_udf.pyDuckDB De-identification UDFsexecutable_udfExecutable UDFcorelocal-onlyoffline-unit(1 test file)tests/unit/integrations/test_executable_udf.pyFeature MapfhirFHIR operations and bulk NDJSONcorelocal-onlyoffline-unit(2 test files)tests/unit/interop/test_fhir_bulk_ndjson.py,tests/unit/interop/test_fhir_deidentify_operation.pyFHIR Interop Helpersgliner_biomedGLiNER-BioMedgliner[tokenizers]0.2.0,torch2.0local-onlyoffline-unit(1 test file)tests/unit/interop/test_gliner_biomed_adapter.pyZero-shot NERhaystackHaystack document redactionhaystack-ai2,3local-onlyoffline-unit(1 test file)tests/unit/interop/test_haystack_redaction.pyHaystack Redaction Componenthl7v2HL7 v2corelocal-onlyoffline-unit(1 test file)tests/unit/interop/test_hl7v2.pyHL7 v2 De-identificationindicIndic language helpersindic-nlp-library0.92local-onlyoffline-unit(1 test file)tests/unit/interop/test_language_adapters.pyFeature MaplakehouseLakehouse table redactionpyarrow16local-onlyoffline-unit(1 test file)tests/unit/integrations/test_lakehouse_redact.pyLakehouse Table RedactionlangchainLangChainlangchain-core0.2,2local-onlyoffline-unit(1 test file)tests/unit/interop/test_langchain_redaction.pyLangChain Redaction NodelanggraphLangGraphlanggraph0.2,2local-onlyoffline-unit(1 test file)tests/unit/interop/test_graph_orchestration.pyFeature MapllamaindexLlamaIndexllama-index-core0.10,1local-onlyoffline-unit(1 test file)tests/unit/interop/test_llamaindex_redaction.pyLlamaIndex Redaction Transformlog_redactorStructured log redactioncorelocal-onlyoffline-unit(1 test file)tests/unit/integrations/test_log_redactor.pyFeature MapomopOMOP/CDMcorelocal-onlyoffline-unit(1 test file)tests/unit/interop/test_omop_cdm_loader.pyFeature MapopenmrsOpenMRS REST and FHIR2httpx0.27configured-networkoffline-unit(1 test file)tests/unit/interop/test_openmrs_adapter.pyOpenMRS Adapterpandaspandas DataFramepandas2.0local-onlyoffline-unit(1 test file)tests/unit/interop/test_dataframe_accessor.pyFeature Mappandas_on_sparkPandas API on Sparkpyspark3.5,4,pandas2.0,pyarrow16local-onlyoffline-unit(1 test file)tests/unit/integrations/test_pandas_on_spark.pyPandas-on-Spark De-identificationphilterPHILTERphilter-ucsf1.0.3,2local-onlyoffline-unit(1 test file)tests/unit/interop/test_philter_adapter.pyFeature MappolarsPolars DataFramepolars0.20local-onlyoffline-unit(1 test file)tests/unit/interop/test_dataframe_accessor.pyFeature MappostgresPostgreSQL transaction adaptercorelocal-onlyoffline-unit(1 test file)tests/unit/interop/test_postgres.pyPostgreSQL Redaction Adapterpostgres_plpythonPostgreSQL PL/Pythoncorelocal-onlyoffline-unit(1 test file)tests/unit/integrations/test_postgres_plpython.pyPostgreSQL Redaction AdapterprefectPrefectprefect3.7,4local-onlyoffline-unit(1 test file)tests/unit/interop/test_prefect_tasks.pyPrefect Batch De-identificationpresidioMicrosoft Presidiopresidio-analyzer2.2.354,3local-onlyoffline-unit(1 test file)tests/unit/interop/test_presidio_adapter.pyFeature MappydeidpyDeidpyDeid0.0.1local-onlyoffline-unit(1 test file)tests/unit/interop/test_pydeid_adapter.pyFeature MapquickumlsQuickUMLSquickumls1.4,2user-supplied-resourceoffline-unit(1 test file)tests/unit/interop/test_scispacy_linker_adapter.pyFeature MaprayRay Dataray[data]2.30,3local-onlyoffline-unit(1 test file)tests/unit/interop/test_ray_data.pyFeature Mapray_map_batchesRay Data map_batchesray[data]2.30,3local-onlyoffline-unit(1 test file)tests/unit/integrations/test_ray_map_batches.pyRay Data map-batchesremote_functionWarehouse remote functionfastapi0.110configured-networkoffline-unit(1 test file)tests/unit/integrations/test_remote_function.pyWarehouse Remote-Function HandlerscispacyscispaCy UMLS linkerscispacy0.5.4,1user-supplied-resourceoffline-unit(1 test file)tests/unit/interop/test_scispacy_linker_adapter.pyFeature Mapscrubadubscrubadubscrubadub2.0,3local-onlyoffline-unit(1 test file)tests/unit/interop/test_scrubadub_adapter.pyFeature Mapsearch_ingestSearch ingest sidecarfastapi0.110configured-networkoffline-unit(1 test file)tests/unit/integrations/test_search_ingest_processor.pyFeature Mapsearch_pipelineSearch pipeline redactionhaystack-ai2,3local-onlyoffline-unit(1 test file)tests/unit/interop/test_search_pipeline.pyHaystack Redaction ComponentspacyspaCyclick8.0,spacy3.8.9local-onlyoffline-unit(1 test file)tests/unit/interop/test_spacy_component.pyspaCy Pipeline ComponentsparkPySparkpyspark3.5,4,pandas2.0,pyarrow16local-onlyoffline-unit(2 test files)tests/unit/interop/test_spark_udf.py,tests/unit/integrations/test_spark_streaming.pyPySpark De-identification UDFssqlalchemySQLAlchemysqlalchemy2.0,3local-onlyoffline-unit(1 test file)tests/unit/integrations/test_sqlalchemy_redact.pySQLAlchemy Write-time Redactionstream_processorStream processorcorelocal-onlyoffline-unit(1 test file)tests/unit/integrations/test_stream_processor.pyFeature MapzhChinese language helpersjieba0.42,opencc1.4.1,2,pypinyin0.51local-onlyoffline-unit(1 test file)tests/unit/interop/test_language_adapters.pyChinese Segmentation Operations从表上可以提炼出几个规律core意味着零额外依赖如cda、fhir、hl7v2、postgres、stream_processor、dataflow_tool等能力只依赖 OpenMed 的基础依赖无需安装任何 optional extra 即可使用多个面共享同一 extra例如beam/dataflow共享apache-beam2.73,3beamextraarrow_flight/columnar/lakehouse共享pyarrow16columnarextrahaystack/search_pipeline共享haystack-ai2,3haystackextraspark/pandas_on_spark共享pyspark3.5,4sparkextra部分能力共用测试文件如pandas/polars共用tests/unit/interop/test_dataframe_accessor.pyindic/zh共用tests/unit/interop/test_language_adapters.pyquickumls/scispacy共用tests/unit/interop/test_scispacy_linker_adapter.py。上述每个 extra 都能在 pyproject.toml 的[project.optional-dependencies]中找到对应声明如columnar [pyarrow16]、airflow [apache-airflow3.2.2,4]、haystack [haystack-ai2,3]这也正是矩阵校验器检查的对象——每个矩阵中出现的 optional requirement 名称必须由同名 extra 声明。四、数据模型IntegrationCapability 记录与边界约束矩阵的机器可读视图由IntegrationCapability冻结数据类构成openmed/interop/capabilities.py每个记录包含 12 个字段字段含义name稳定的机器可读能力键小写下划线命名如pandas_on_sparksurface人类可读的集成面名称module实现该面的懒加载适配器/集成模块如openmed.interop.spark_udfextra提供该集成的可选 OpenMed extracore-only 面为Noneoptional_dependencies由extra声明的 PEP 508 需求字符串core-only 面为空元组documentation仓库相对路径的 Markdown 文档页本地路径从不被拉取tests覆盖该面的仓库相对路径离线测试文件policy集成自身的网络或资源策略test_guarantee记录的支持证据类型offline-unit或offline-contractdescription适合状态页或报告的 PHI-free 摘要supported_python支持的 Python 版本约束默认3.10schema_version矩阵级矩阵 schema 版本当前为1为保证安全与可预测性源码定义了一组硬边界常量openmed/interop/capabilities.pyMAX_CAPABILITIES 256自定义矩阵最多 256 条能力记录_MAX_SEQUENCE_ITEMS 64依赖、文档或测试路径序列每个最多 64 个元素_MAX_TEXT_LENGTH 4_096单字段文本长度上限_MAX_LOCAL_METADATA_BYTES 4 * 1024 * 1024仓库一致性读取时每个元数据文件最多 4 MiB_MAX_SCHEMA_VERSION (1 31) - 1schema 版本整数上界。这些约束通过_bounded_tuple与_bounded_text_tuple在构造阶段强制生效openmed/interop/capabilities.py任何迭代器只要在到达上限后仍能产出元素就会抛出ValueError从而杜绝“无界物化”与字符串钩子string hook泄漏。五、失败闭合fail-closed设计被篡改的元数据无法“溜”进公开报告矩阵最值得注意的设计是“报告前重新校验”revalidate-before-report。公开的 JSON 与 Markdown 渲染器在输出任何内容之前都会对冻结记录重新执行一遍安全断言openmed/interop/capabilities.py包括name必须匹配^[a-z][a-z0-9_]*$稳定小写键surface、description必须是非空可打印文本且不得包含|或反引号防止 Markdown 表格与代码块注入module必须是openmed.前缀的合法模块名extra存在时必须非空且extra is None时不得携带optional_dependenciespolicy必须属于三种允许值test_guarantee必须属于offline-unit/offline-contract文档路径必须落在docs/下且以.md结尾测试路径必须落在tests/下且以.py结尾依赖字符串必须通过 PEP 508 风格正则且同一序列内不得有重复项。一旦断言失败to_dict()/to_json()/to_markdown()以及迭代、查找、版本属性访问都会抛出ValueError(capability cannot be serialized safely)或ValueError(capability matrix cannot be reported safely)并且不会在错误信息中保留调用方传入的值——这是防注入的关键点。__repr__也刻意只渲染IntegrationCapability(validated metadata)而不是回显字段openmed/interop/capabilities.py。迭代、查找与版本属性共用同一个“分离快照边界”detached snapshot boundary_validated_matrix_report会先重建一份校验过的矩阵副本再对外暴露数据同时校验名称必须排序、无重复、schema 版本必须等于1openmed/interop/capabilities.py。测试test_capabilities_returns_detached_canonical_records证实即使调用方篡改返回记录下一次capabilities()调用依然返回干净数据。六、机器可读 API无需安装任何可选依赖即可查询矩阵的入口是openmed.interop.capabilities模块公开别名CAPABILITY_MATRIX同INTEGRATION_CAPABILITY_MATRIX。原文档给出的最小用法from openmed.interop.capabilities import CAPABILITY_MATRIX print(CAPABILITY_MATRIX.to_json())to_json()会以ensure_asciiFalse、sort_keysTrue、缩进 0–8默认 2的方式确定性序列化输出包含schema_version: 1与按名称排序的能力数组openmed/interop/capabilities.py。测试test_matrix_serialization_is_deterministic_and_phi_free验证了两次调用结果完全一致且序列化输出中不含任何 PHI 标记如Jane Roe、555-0100、示例邮箱等。除to_json()外矩阵还提供以下编程接口from openmed.interop.capabilities import ( CAPABILITY_MATRIX, capabilities, capability, validate_capability_matrix, ) # 1. 按名称查询单条记录大小写与连字符容错 entry capability(Lang-Chain) # - name langchain entry CAPABILITY_MATRIX.get(openmrs) # policy configured-network print(entry.surface) # OpenMRS REST and FHIR2 print(entry.supported_versions) # (httpx0.27,) print(entry.dependency_names) # (httpx,) # 2. 获取全部记录稳定顺序分离快照 all_records capabilities() print(len(CAPABILITY_MATRIX)) # 46 # 3. 渲染 Markdown 视图与 docs/integrations/matrix.md 同源同格式 markdown_view CAPABILITY_MATRIX.to_markdown() # 4. 离线一致性校验默认针对当前仓库 checkout validate_capability_matrix(CAPABILITY_MATRIX, repository_rootNone)值得注意的细节capability()与get()的名称规范化会把输入转小写、-换成_并额外支持“紧凑名匹配”replace(_, )所以capability(Lang-Chain)能命中langchain未知名称抛出KeyError(unknown integration capability)且该异常信息不会回显调用方输入测试test_unknown_capability_errors_do_not_echo_caller_inputdependency_names从需求串中提取并规范化发行版名称-_.统一归一为-并转小写supported_versions返回原始的版本钉住需求串导入矩阵绝不触发可选依赖导入测试test_matrix_import_is_lazy_for_optional_adapters在子进程中导入CAPABILITY_MATRIX后断言apache_beam、dask、haystack、langchain_core、pandas、polars均未进入sys.modules校验绝不打开网络连接测试test_validation_does_not_open_network_connections用 monkeypatch 把socket.socket替换成必然抛错的函数确认validate_capability_matrix全程离线。七、离线一致性校验矩阵、文档与测试三位一体validate_capability_matrix()是矩阵的完整校验入口openmed/interop/capabilities.py。在repository_root参数缺省时它会自动使用包含本模块的源码 checkout若该 checkout 存在pyproject.toml若只是安装了 wheel则只执行 schema 级检查。校验内容包括结构校验schema 版本必须为1矩阵非空名称必须小写稳定、排序、唯一module必须属于openmed包extra为空串报错extra is None时不得有依赖策略与证据类型必须合法supported_python必须等于3.10。仓库内路径解析module必须能在openmed/下解析到.py文件或包__init__.py每条documentation必须存在于docs/下每条tests必须存在于tests/下openmed/interop/capabilities.py。extra 一致性每个extra必须在 pyproject.toml 的optional-dependencies中有声明且矩阵中的每条依赖需求名必须出现在对应 extra 的声明列表中规范化发行版名后比对。文档页覆盖docs/integrations/matrix.md必须包含每个能力的名称、每条依赖串与每个测试路径的反引号包裹文本同时矩阵文档内的所有 Markdown 链接必须能解析到docs/下的真实文件openmed/interop/capabilities.py。这意味着“文档、矩阵、测试、pyproject extras”四者必须保持同步任何一侧漂移都会让校验失败。以上全部断言由 tests/unit/interop/test_capabilities.py 覆盖核心测试包括test_matrix_is_sorted_and_validates_against_local_repository排序、去重、离线证据前缀、test_matrix_covers_documented_optional_and_data_surfaces关键面覆盖与策略断言、test_invalid_matrix_reports_structural_errors重复名称报错、test_report_surfaces_revalidate_tampered_metadata_and_indent篡改字段与非法缩进报错、test_capability_properties_revalidate_tampered_requirements篡改依赖后所有访问器失败且不泄漏输入、test_validation_rejects_report_injection_without_repository_checks报告注入拒绝等。八、实战建议与边界说明查询支持边界前无需装任何东西from openmed.interop.capabilities import CAPABILITY_MATRIX只依赖标准库先to_json()或capability(name)判断目标集成的 extra 与策略再决定是否安装对应 extra是最稳妥的接入顺序。core 面开箱即用fhir、hl7v2、cda、postgres、stream_processor、distributed_sql、log_redactor等能力不需要额外安装适合作为零依赖起步的集成面。policy 决定部署形态configured-network面arrow_flight、openmrs、remote_function、search_ingest虽可调用用户配置的端点但矩阵本身永不发起调用user-supplied-resource面quickumls、scispacy需要调用方自带受许可资源OpenMed 不负责下载或捆绑。证据均来自离线单元/契约测试矩阵只记录模块名、路径、版本约束与 PHI-free 描述测试夹具均为合成数据若需要查看某条能力的具体实现与文档可从表中对应module字段如openmed.interop.spark_udf与文档链接继续深入。自定义矩阵有硬上限新增能力记录前先对照MAX_CAPABILITIES256、单序列64项、单文本4096字符等约束同时必须保持pyproject.tomlextras、文档页与测试文件三方同步否则validate_capability_matrix会拒绝通过。一句话总结docs/integrations/matrix.md及其底层INTEGRATION_CAPABILITY_MATRIX把 OpenMed 全部 46 个集成面浓缩成一份“可程序读取、可离线校验、失败即闭合”的能力清单——它既是工程师查询支持边界的入口也是保证文档、依赖与测试证据始终一致的质量闸门。【免费下载链接】openmedLocal-first healthcare AI: clinical NER HIPAA PII de-identification that runs 100% on-device. 2,200 medical models, 21 languages, Apple MLX Python, no cloud, no patient data leaving your network. Apache-2.0项目地址: https://gitcode.com/GitHub_Trending/ope/openmed创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考