OpenIslet

scripts/study_artifact_exports.py

Canonical study/effect JSONL materialization at the producer boundary.

script Release v0.8.0 gen-eb955f8266035aba 13 KB · 2 sections

Use this file in any AI chat (paste-only or attachment-capable):

Download as text (.txt) Download section (.txt)

Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/study_artifact_exports.py · SHA-256: e542d31c1b1317e7…

               'source_text_type':meta.get('source_text_type'),
               'superseded_by_pmid':meta.get('superseded_by_pmid')}
        for effect in atomic_effects:
            if any(key in effect and effect[key] != value for key,value in bound.items()):
                raise ValueError('Atomic effect may not replace its enclosing study identity')
            effects.append({**bound,**effect})
    studies_path=root/'data/extracted/ring1_study_dossiers_v0.5.jsonl'
    effects_path=root/'data/extracted/ring1_atomic_effects_v0.5.jsonl'
    payloads={path:''.join(json.dumps(row,ensure_ascii=False,allow_nan=False)+'\n' for row in rows).encode('utf-8')
              for path,rows in [(studies_path,studies),(effects_path,effects)]}
    publish_byte_artifacts(payloads,lock_path=studies_path.parent/'.study-exports.lock',rollback_journal=rollback_journal)
    return studies_path,effects_path,len(effects)