Bundle metadata files in repo to skip download on startup
Browse files- Add data/*.csv and data/metadata/ to repo
- Update .gitignore to allow metadata files while ignoring model files
- Update Dockerfile to copy metadata files into image
- Update download_metadata() to use local files if available
- Falls back to HuggingFace download if local files not found
- Reduces startup time by ~2 seconds (no network call needed)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Files changed (8)
10 unmodified lines1112131415161710 unmodified lines*.swp.idea/.vscode/data/.pytest_cache/.coveragehtmlcov/10 unmodified lines1112131415161718192010 unmodified lines*.swp.idea/.vscode/data/*# But include metadata files!data/*.csv!data/metadata/.pytest_cache/.coveragehtmlcov/
14 unmodified lines15161718192014 unmodified lines# Copy project filesCOPY pyproject.toml README.md app.py ./COPY src/ ./src/# Create venv and install with dependencies using GH_TOKEN secret# Use BuildKit secret mount to securely pass GH_TOKEN14 unmodified lines1516171819202114 unmodified lines# Copy project filesCOPY pyproject.toml README.md app.py ./COPY src/ ./src/COPY data/*.csv data/metadata/ ./data/# Create venv and install with dependencies using GH_TOKEN secret# Use BuildKit secret mount to securely pass GH_TOKEN
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591600 ACC1 ACRM2 ACYC3 ALUCA4 ANGS5 ANSC6 ARMM7 ARMS8 ASTR9 ATM10 BA11 BCC12 BLAD13 BLCA14 BMGCT15 CCOV16 CCRCC17 CESC18 CHDM19 CHRCC20 CHS21 COAD22 CSCC23 DA24 DASTR25 DDLS26 DES27 DSRCT28 ECAD29 EGC30 EHAE31 EHCH32 EMPD33 EOV34 EPIS35 EPM36 ERMS37 ES38 ESCA39 ESCC40 GBAD41 GBM42 GCCAP43 GEJ44 GIST45 GRCT46 HCC47 HGNEC48 HGSOC49 HNMUCM50 HNSC51 IDC52 IHCH53 ILC54 LGSOC55 LMS56 LUAD57 LUCA58 LUNE59 LUPC60 LUSC61 MAAP62 MACR63 MBC64 MCC65 MFH66 MFS67 MNG68 MOV69 MPNST70 MRLS71 NBL72 NPC73 NSGCT74 OCS75 ODG76 OPHSC77 OS78 PAAC79 PAAD80 PAMPCA81 PANET82 PAST83 PECOMA84 PEMESO85 PHC86 PLMESO87 PRAD88 PRCC89 PTAD90 RBL91 READ92 SBOV93 SBWDNET94 SCBC95 SCHW96 SCLC97 SDCA98 SEM99 SFT100 SKCM101 SSRCC102 STAD103 SYNS104 TAC105 THAP106 THHC107 THME108 THPA109 THPD110 THYC111 THYM112 UCCC113 UCP114 UCS115 UEC116 ULMS117 UM118 USC119 UTUC120 VMM121 VSC122 WDLS123 WT124 RCC125 ADNOS126 CUPNOS127 NOT128 MDLC129 URCC130 NVRINT131 PAASC132 MEL133 GBC134 BRCNOS135 LUAS136 UDMN137 UMEC138 NETNOS139 COADREAD140 CHOL141 PDC142 GNOS143 GINET144 NSCLC145 CSCLC146 SBC147 NECNOS148 BRCA149 SCCNOS150 AMPCA151 CUP152 SARCNOS153 BRCANOS154 APAD155 NSCLCPD156 DIFG157 MXOV158 UCEC159 MUP12000011601321{'histologies': ['ACC', 'ACRM', 'ACYC', 'ALUCA', 'ANGS', 'ANSC', 'ARMM', 'ARMS', 'ASTR', 'ATM', 'BA', 'BCC', 'BLAD', 'BLCA', 'BMGCT', 'CCOV', 'CCRCC', 'CESC', 'CHDM', 'CHRCC', 'CHS', 'COAD', 'CSCC', 'DA', 'DASTR', 'DDLS', 'DES', 'DSRCT', 'ECAD', 'EGC', 'EHAE', 'EHCH', 'EMPD', 'EOV', 'EPIS', 'EPM', 'ERMS', 'ES', 'ESCA', 'ESCC', 'GBAD', 'GBM', 'GCCAP', 'GEJ', 'GIST', 'GRCT', 'HCC', 'HGNEC', 'HGSOC', 'HNMUCM', 'HNSC', 'IDC', 'IHCH', 'ILC', 'LGSOC', 'LMS', 'LUAD', 'LUCA', 'LUNE', 'LUPC', 'LUSC', 'MAAP', 'MACR', 'MBC', 'MCC', 'MFH', 'MFS', 'MNG', 'MOV', 'MPNST', 'MRLS', 'NBL', 'NPC', 'NSGCT', 'OCS', 'ODG', 'OPHSC', 'OS', 'PAAC', 'PAAD', 'PAMPCA', 'PANET', 'PAST', 'PECOMA', 'PEMESO', 'PHC', 'PLMESO', 'PRAD', 'PRCC', 'PTAD', 'RBL', 'READ', 'SBOV', 'SBWDNET', 'SCBC', 'SCHW', 'SCLC', 'SDCA', 'SEM', 'SFT', 'SKCM', 'SSRCC', 'STAD', 'SYNS', 'TAC', 'THAP', 'THHC', 'THME', 'THPA', 'THPD', 'THYC', 'THYM', 'UCCC', 'UCP', 'UCS', 'UEC', 'ULMS', 'UM', 'USC', 'UTUC', 'VMM', 'VSC', 'WDLS', 'WT', 'RCC', 'ADNOS', 'CUPNOS', 'NOT', 'MDLC', 'URCC', 'NVRINT', 'PAASC', 'MEL', 'GBC', 'BRCNOS', 'LUAS', 'UDMN', 'UMEC', 'NETNOS', 'COADREAD', 'CHOL', 'PDC', 'GNOS', 'GINET', 'NSCLC', 'CSCLC', 'SBC', 'NECNOS', 'BRCA', 'SCCNOS', 'AMPCA', 'CUP', 'SARCNOS', 'BRCANOS', 'APAD', 'NSCLCPD', 'DIFG', 'MXOV', 'UCEC', 'MUP'], 'oncotree_mapping': {'MGCT': 'NSGCT', 'PLBMESO': 'PLMESO', 'PLEMESO': 'PLMESO', 'DSTAD': 'SSRCC', 'HGSFT': 'HGSOC', 'PSEC': 'HGSOC', 'GB': 'GBM', 'AODG': 'ODG', 'AASTR': 'ASTR', 'LXSC': 'HNSC', 'OCSC': 'HNSC'}, 'sites': ['Primary', 'Metastasis'], 'target': ['oncotree_code_aeon'], 'target_type': ['other'], 'task': ['multiclass-classification'], 'class_weights': [3.685110294117647, 2.9138081395348836, 1.606330128205128, 6.111890243902439, 3.13234375, 1.8700559701492536, 4.818990384615384, 6.425320512820512, 0.9564408396946565, 7.830859375, 8.352916666666667, 5.966369047619048, 7.830859375, 0.1324458245243129, 8.949553571428572, 1.7772163120567377, 0.4427340989399293, 1.8562037037037038, 6.425320512820512, 3.5798214285714285, 3.9154296875, 0.08294852697782192, 2.5311868686868686, 3.977579365079365, 6.425320512820512, 1.1287725225225225, 4.3204741379310345, 2.088229166666667, 2.880316091954023, 1.3768543956043957, 7.593560606060606, 2.694489247311828, 3.0559451219512197, 2.7537087912087914, 8.949553571428572, 8.352916666666667, 4.3204741379310345, 2.298967889908257, 0.5556263858093127, 2.053995901639344, 2.8155898876404493, 0.2762816979051819, 4.640509259259259, 0.8325166112956811, 0.44351769911504424, 5.447554347826087, 0.9456132075471698, 5.695170454545455, 0.15545130272952853, 5.966369047619048, 0.7391961651917404, 0.07947589597209008, 0.5264443277310924, 0.46491187384044524, 2.198135964912281, 0.9943948412698412, 0.049318539657547726, 2.1236228813559324, 2.409495192307692, 5.01175, 0.31881361323155216, 1.912881679389313, 2.3640330188679246, 6.772635135135135, 2.386547619047619, 1.2592336683417085, 2.557015306122449, 3.796780303030303, 5.331648936170213, 3.5798214285714285, 3.432705479452055, 0.5708143507972665, 7.593560606060606, 1.5187121212121213, 3.13234375, 1.6817953020134229, 2.637763157894737, 1.3329122340425532, 6.425320512820512, 0.09549828506097562, 7.370220588235294, 0.8981630824372759, 5.966369047619048, 10.0235, 3.5798214285714285, 10.0235, 1.0397821576763486, 0.081998527486911, 3.432705479452055, 4.041733870967742, 3.855192307692308, 0.19041603343465047, 7.830859375, 2.983184523809524, 8.352916666666667, 6.960763888888889, 0.6846653005464481, 3.855192307692308, 3.0191265060240964, 3.796780303030303, 0.33590817694369973, 3.5294014084507044, 0.4197445561139028, 2.5833762886597937, 6.960763888888889, 2.6102864583333334, 5.966369047619048, 3.0559451219512197, 0.7639862804878049, 1.6705833333333333, 9.281018518518518, 5.447554347826087, 3.4803819444444444, 10.0235, 0.9179029304029304, 0.18027877697841727, 1.5468364197530864, 2.5833762886597937, 0.6327967171717171, 0.6629298941798942, 6.594407894736842, 5.01175, 3.171993670886076, 3.4803819444444444, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}28 unmodified lines293031323334353637383940414243444546474849505152535428 unmodified linesdef download_metadata():"""Download only metadata files (CSV, tissue site mappings).Fast synchronous download of small files needed for UI initialization.Returns:tuple: (cancer_subtype_name_map, reversed_cancer_subtype_name_map, cancer_subtypes)"""logger.info("Downloading metadata from HuggingFace Hub...")cache_dir = snapshot_download(repo_id="PDM-Group/paladin-aeon-models",allow_patterns=["*.csv", # Model maps and metadata"tissue_site_*", # Tissue site mappings"metadata/*", # Metadata files (including target_dict.tsv)],)logger.info(f"Metadata downloaded to: {cache_dir}")# Set the data directory for other modules to useset_data_directory(cache_dir)model_map = pd.read_csv(Path(cache_dir) / "paladin_model_map.csv")cancer_subtypes = model_map["cancer_subtype"].unique().tolist()28 unmodified lines29303132333435363738394041424344454647484950515253545556575859606162636428 unmodified linesdef download_metadata():"""Load metadata files from local data/ directory or download from HuggingFace.Fast loading of small files needed for UI initialization.Prioritizes local files in data/ directory (bundled with Docker image).Returns:tuple: (cancer_subtype_name_map, reversed_cancer_subtype_name_map, cancer_subtypes)"""# Check if metadata exists in local data/ directory (Docker deployment)local_data_dir = Path(__file__).parent.parent.parent / "data"local_model_map = local_data_dir / "paladin_model_map.csv"if local_model_map.exists():logger.info(f"Using local metadata from: {local_data_dir}")cache_dir = local_data_direlse:# Fall back to downloading from HuggingFace Hublogger.info("Downloading metadata from HuggingFace Hub...")cache_dir = Path(snapshot_download(repo_id="PDM-Group/paladin-aeon-models",allow_patterns=["*.csv", # Model maps and metadata"tissue_site_*", # Tissue site mappings"metadata/*", # Metadata files (including target_dict.tsv)],))logger.info(f"Metadata downloaded to: {cache_dir}")# Set the data directory for other modules to useset_data_directory(str(cache_dir))model_map = pd.read_csv(Path(cache_dir) / "paladin_model_map.csv")cancer_subtypes = model_map["cancer_subtype"].unique().tolist()
.gitignore+4-1
Dockerfile+1
data/metadata/int_to_name_class_mapping.tsvAdded+160
data/metadata/longest_sequence.txtAdded+1
data/metadata/n_classes.txtAdded+1
data/metadata/ontology_embedding_dim.txtAdded+1
data/metadata/target_dict.tsvAdded+1
src/mosaic/gradio_app.py+23-13