-
Notifications
You must be signed in to change notification settings - Fork 0
work in progress, docker, nextflow #4
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
MateoZ05
wants to merge
5
commits into
main
Choose a base branch
from
nextflow-implementation
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.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
401529d
work in progress, docker, nextflow
MateoZ05 66764b3
Potential fix for pull request finding
MateoZ05 b5450c2
Fix for false-positives in finding genes
MateoZ05 59e5258
Potential fix for pull request finding
MateoZ05 bade22a
Potential fix for pull request finding
MateoZ05 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .git/ | ||
| __pycache__/ | ||
| *.pyc | ||
| *.pyo | ||
| # Generated outputs / intermediates — recreated at runtime, no need to bake in. | ||
| data/ | ||
| results/ | ||
| work/ | ||
| .nextflow* | ||
| *.log |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Ollama runtime + the llmize Python pipeline in one image. | ||
| FROM ollama/ollama:latest | ||
|
|
||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends python3 python3-pip curl \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR /opt/llmize | ||
|
|
||
| ARG INSTALL_ENRICH=false | ||
| RUN python3 -m pip install --no-cache-dir --break-system-packages "ollama>=0.5" \ | ||
| && if [ "$INSTALL_ENRICH" = "true" ]; then \ | ||
| python3 -m pip install --no-cache-dir --break-system-packages tooluniverse "PyYAML>=6" ; \ | ||
| fi | ||
|
|
||
| # TEST_MODEL is baked in for offline runs; LLMIZE_MODEL is the runtime default. | ||
| # Set BAKE_MODEL=true to also bake LLMIZE_MODEL for air-gapped use. | ||
| ARG TEST_MODEL=smollm2:135m | ||
| ARG LLMIZE_MODEL=gemma4 | ||
| ENV LLMIZE_MODEL=${LLMIZE_MODEL} | ||
| ARG BAKE_MODEL=false | ||
| RUN if [ -n "$TEST_MODEL" ] || [ "$BAKE_MODEL" = "true" ]; then \ | ||
| ollama serve & srv=$! ; \ | ||
| until curl -sf http://127.0.0.1:11434/api/tags >/dev/null 2>&1; do sleep 1; done ; \ | ||
| if [ -n "$TEST_MODEL" ]; then ollama pull "$TEST_MODEL" ; fi ; \ | ||
| if [ "$BAKE_MODEL" = "true" ]; then ollama pull "$LLMIZE_MODEL" ; fi ; \ | ||
| kill $srv ; \ | ||
| fi | ||
|
|
||
| COPY . . | ||
| RUN mkdir -p /opt/llmize/data && chmod -R a+rwX /opt/llmize/data \ | ||
| && chmod +x docker/boot_ollama.sh docker/entrypoint.sh | ||
|
|
||
| ENTRYPOINT ["/opt/llmize/docker/entrypoint.sh"] | ||
| CMD ["python3", "pipeline.py", "--check"] | ||
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,45 @@ | ||
| #!/usr/bin/env bash | ||
| # Start the in-container Ollama server, wait for it, and pull the model. | ||
| # | ||
| # Reusable so both the image ENTRYPOINT (docker run) and the Nextflow process | ||
| # script can call it. The server is started with nohup + disown so it survives | ||
| # this script exiting and is reachable by later commands in the same task. | ||
| # | ||
| # Honours: | ||
| # LLMIZE_MODEL - model tag to pull/run (default: gemma4) | ||
| # OLLAMA_HOST - server/client endpoint (default: 127.0.0.1:11434) | ||
| set -euo pipefail | ||
|
|
||
| MODEL="${LLMIZE_MODEL:-gemma4}" | ||
| ENDPOINT="http://${OLLAMA_HOST:-127.0.0.1:11434}" | ||
|
|
||
| # Start the server only if one isn't already answering. | ||
| if ! curl -sf "${ENDPOINT}/api/tags" >/dev/null 2>&1; then | ||
| echo "[boot] starting 'ollama serve'..." | ||
| nohup ollama serve >/tmp/ollama.log 2>&1 & | ||
| disown || true | ||
| fi | ||
|
|
||
| echo "[boot] waiting for Ollama at ${ENDPOINT} ..." | ||
| for i in $(seq 1 60); do | ||
| if curl -sf "${ENDPOINT}/api/tags" >/dev/null 2>&1; then | ||
| break | ||
| fi | ||
| sleep 1 | ||
| if [ "$i" -eq 60 ]; then | ||
| echo "[boot] ERROR: Ollama did not become ready in 60s" >&2 | ||
| cat /tmp/ollama.log >&2 || true | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| # Skip the pull if the model is already present (baked into the image, or cached | ||
| # on a mounted volume). This is what makes an offline / air-gapped image work: | ||
| # 'ollama pull' would otherwise contact the registry even for an existing model. | ||
| if ollama list 2>/dev/null | grep -qF "${MODEL}"; then | ||
|
MateoZ05 marked this conversation as resolved.
|
||
| echo "[boot] model '${MODEL}' already present; skipping pull (offline-safe)." | ||
| else | ||
| echo "[boot] pulling model '${MODEL}' (runtime pull; needs network)..." | ||
| ollama pull "${MODEL}" | ||
| fi | ||
| echo "[boot] ready." | ||
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,12 @@ | ||
| #!/usr/bin/env bash | ||
| # Image ENTRYPOINT for plain `docker run`: boot Ollama, then run the given command. | ||
| # (Nextflow overrides the entrypoint, so its process script calls boot_ollama.sh itself.) | ||
| set -euo pipefail | ||
|
|
||
| source /opt/llmize/docker/boot_ollama.sh | ||
|
|
||
| # Default to the env preflight if no command was given. | ||
| if [ "$#" -eq 0 ]; then | ||
| exec python3 /opt/llmize/pipeline.py --check | ||
| fi | ||
| exec "$@" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| process INTERPRET { | ||
| tag "${report.baseName}" | ||
| container 'llmize:latest' | ||
| publishDir params.outdir, mode: 'copy' | ||
|
|
||
| input: | ||
| path report | ||
|
|
||
| output: | ||
| path "*_interpretation_*.md", emit: interpretation | ||
|
|
||
| script: | ||
| def home = workflow.containerEngine ? '/opt/llmize' : "${projectDir}" | ||
| def boot = workflow.containerEngine ? "export LLMIZE_MODEL='${params.model}'\n bash ${home}/docker/boot_ollama.sh" : '' | ||
| def think_flag = "${params.think}".toBoolean() ? '--think' : '--no-think' | ||
| def enrich_flag = "${params.enrich}".toBoolean() ? '--enrich' : '' | ||
| def review_flag = "${params.review}".toBoolean() ? "--review --review-passes ${params.review_passes}" : '' | ||
| def whole_flag = "${params.whole_report}".toBoolean() ? '--whole-report' : '' | ||
| def synth_flag = "${params.synthesis}".toBoolean() ? '' : '--no-synthesis' | ||
| def prompt_escaped = params.prompt ? params.prompt.toString().replace("'", "'\"'\"'") : '' | ||
| def prompt_flag = params.prompt ? "--prompt '${prompt_escaped}'" : '' | ||
| def temp_flag = params.temperature != null ? "--temperature ${params.temperature}" : '' | ||
| def seed_flag = params.seed != null ? "--seed ${params.seed}" : '' | ||
| def top_p_flag = params.top_p != null ? "--top_p ${params.top_p}" : '' | ||
| def top_k_flag = params.top_k != null ? "--top_k ${params.top_k}" : '' | ||
| def numpred_flag = params.num_predict != null ? "--num_predict ${params.num_predict}" : '' | ||
| """ | ||
| ${boot} | ||
| STAMP=\$(date +%Y%m%d_%H%M%S) | ||
| python3 ${home}/pipeline.py \\ | ||
| --input '${report}' \\ | ||
| --model '${params.model}' \\ | ||
| --num_ctx ${params.num_ctx} \\ | ||
| ${think_flag} ${enrich_flag} ${review_flag} ${whole_flag} ${synth_flag} \\ | ||
| ${prompt_flag} ${temp_flag} ${seed_flag} ${top_p_flag} ${top_k_flag} ${numpred_flag} \\ | ||
| --output "${report.baseName}_interpretation_\${STAMP}.md" | ||
| """ | ||
| } | ||
|
|
||
| workflow { | ||
| if( !params.input ) | ||
| error "Provide --input <multiqc_data.json>" | ||
|
|
||
| ch_input = channel.fromPath(params.input, checkIfExists: true) | ||
|
|
||
| INTERPRET(ch_input) | ||
| } |
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,48 @@ | ||
| params { | ||
| input = null | ||
| outdir = 'results' | ||
|
|
||
| model = 'gemma4' | ||
| think = true | ||
| enrich = false | ||
| review = false | ||
| review_passes = 2 | ||
| whole_report = false | ||
| synthesis = true | ||
| prompt = null | ||
| num_ctx = 32768 | ||
| temperature = null | ||
| seed = null | ||
| top_p = null | ||
| top_k = null | ||
| num_predict = null | ||
| } | ||
|
|
||
| docker { | ||
| enabled = true | ||
| } | ||
|
|
||
| profiles { | ||
| native { | ||
| docker.enabled = false | ||
| } | ||
| } | ||
|
|
||
| report { | ||
| enabled = true | ||
| file = "data/nextflow_logs/report.html" | ||
| overwrite = true | ||
| } | ||
|
|
||
| timeline { | ||
| enabled = true | ||
| file = "data/nextflow_logs/timeline.html" | ||
| overwrite = true | ||
| } | ||
|
|
||
| process { | ||
| withName: INTERPRET { | ||
| container = 'llmize:latest' | ||
| containerOptions = "-v ${System.getProperty('user.home')}/.llmize-ollama:/root/.ollama" | ||
| } | ||
| } |
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
Oops, something went wrong.
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.