-
Notifications
You must be signed in to change notification settings - Fork 0
python-3.12.10-atls model files #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mzueva
wants to merge
2
commits into
main
Choose a base branch
from
mzueva/immune-builder-model
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+101
−1
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
python-3.12.10-atls/scripts/download-immunebuilder-weights.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // Pre-fetch ImmuneBuilder model weights into shared/immunebuilder-weights/ | ||
| // so the runenv build can stage them via copyFiles into share/immunebuilder-weights/ | ||
| // of the published environment. Avoids the unstable on-first-use download from | ||
| // Zenodo when the 3d-structure-prediction block runs against a package-deployed | ||
| // runtime. | ||
| // | ||
| // Idempotent: re-runs skip files whose on-disk size already matches the | ||
| // expected Zenodo blob size. Partial downloads land in a .part sidecar and | ||
| // are atomically renamed on success. | ||
|
|
||
| import { createWriteStream } from 'node:fs'; | ||
| import { mkdir, rename, stat, unlink } from 'node:fs/promises'; | ||
| import { dirname, join, resolve } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { pipeline } from 'node:stream/promises'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
| const targetDir = resolve(__dirname, '..', 'shared', 'immunebuilder-weights'); | ||
|
|
||
| // Sizes are the byte length of the Zenodo blobs (record 7258553). They double | ||
| // as an integrity check + early-fail signal for truncated downloads; ImmuneBuilder | ||
| // itself only checks that the file is non-empty and doesn't start with "EMPTY", | ||
| // which is too loose to catch partial downloads. | ||
| const FILES = [ | ||
| { name: 'antibody_model_1', size: 61050011 }, | ||
| { name: 'antibody_model_2', size: 214267291 }, | ||
| { name: 'antibody_model_3', size: 214267291 }, | ||
| { name: 'antibody_model_4', size: 214267291 }, | ||
| { name: 'nanobody_model_1', size: 61050011 }, | ||
| { name: 'nanobody_model_2', size: 214267291 }, | ||
| { name: 'nanobody_model_3', size: 214267291 }, | ||
| { name: 'nanobody_model_4', size: 214267291 }, | ||
| ]; | ||
|
|
||
| const BASE = 'https://zenodo.org/record/7258553/files'; | ||
|
|
||
| // Zenodo can stall mid-transfer. One AbortController covers both the fetch | ||
| // (headers) and the pipeline (streamed body) — clearing the timer right after | ||
| // fetch() resolves would still leave a mid-body stall hanging indefinitely. | ||
| const DOWNLOAD_TIMEOUT_MS = 15 * 60 * 1000; | ||
|
|
||
| async function statOrNull(path) { | ||
| try { | ||
| return await stat(path); | ||
| } catch (err) { | ||
| if (err.code === 'ENOENT') return null; | ||
| throw err; | ||
| } | ||
| } | ||
|
|
||
| async function downloadOne({ name, size }) { | ||
| const dest = join(targetDir, name); | ||
| const existing = await statOrNull(dest); | ||
| if (existing && existing.size === size) { | ||
| console.log(` ✓ ${name} (cached)`); | ||
| return; | ||
| } | ||
| const url = `${BASE}/${name}?download=1`; | ||
| console.log(` ↓ ${name} from ${url}`); | ||
| const controller = new AbortController(); | ||
| const timer = setTimeout(() => controller.abort(), DOWNLOAD_TIMEOUT_MS); | ||
| const tmp = `${dest}.part`; | ||
| try { | ||
| const res = await fetch(url, { redirect: 'follow', signal: controller.signal }); | ||
| if (!res.ok) throw new Error(`HTTP ${res.status} for ${url}`); | ||
| await pipeline(res.body, createWriteStream(tmp)); | ||
| const got = (await stat(tmp)).size; | ||
| if (got !== size) { | ||
| throw new Error(`${name}: expected ${size} bytes, got ${got}`); | ||
| } | ||
| await rename(tmp, dest); | ||
| console.log(` ✓ ${name} (${got} bytes)`); | ||
| } catch (err) { | ||
| // Best-effort cleanup; ENOENT is fine if the .part was never created. | ||
| await unlink(tmp).catch(() => {}); | ||
| throw err; | ||
| } finally { | ||
| clearTimeout(timer); | ||
| } | ||
|
mzueva marked this conversation as resolved.
|
||
| } | ||
|
|
||
| await mkdir(targetDir, { recursive: true }); | ||
| console.log(`Fetching ImmuneBuilder weights into ${targetDir}`); | ||
| for (const f of FILES) { | ||
| await downloadOne(f); | ||
| } | ||
| console.log('ImmuneBuilder weights ready'); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.