refactor: api key as input password
Browse files- Dockerfile +0 -2
- Makefile +1 -1
- app.py +12 -5
Dockerfile
CHANGED
@@ -30,9 +30,7 @@ COPY molecule.py /app/molecule.py
|
|
30 |
|
31 |
EXPOSE 7860
|
32 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
33 |
-
ARG FOLDING_API_KEY
|
34 |
ARG FOLDING_PROJECT_CODE
|
35 |
-
ENV FOLDING_API_KEY=$FOLDING_API_KEY
|
36 |
ENV FOLDING_PROJECT_CODE=$FOLDING_PROJECT_CODE
|
37 |
|
38 |
# Create directory for HTML output
|
|
|
30 |
|
31 |
EXPOSE 7860
|
32 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
|
|
33 |
ARG FOLDING_PROJECT_CODE
|
|
|
34 |
ENV FOLDING_PROJECT_CODE=$FOLDING_PROJECT_CODE
|
35 |
|
36 |
# Create directory for HTML output
|
Makefile
CHANGED
@@ -5,7 +5,7 @@ PORT = 7860
|
|
5 |
OUTPUT_DIR = ./output
|
6 |
|
7 |
# Docker build arguments
|
8 |
-
DOCKER_BUILD_ARGS = --build-arg
|
9 |
|
10 |
# Docker run arguments
|
11 |
DOCKER_RUN_ARGS = -p $(PORT):$(PORT) -v $(OUTPUT_DIR):/app/output/html
|
|
|
5 |
OUTPUT_DIR = ./output
|
6 |
|
7 |
# Docker build arguments
|
8 |
+
DOCKER_BUILD_ARGS = --build-arg FOLDING_PROJECT_CODE=${FOLDING_PROJECT_CODE}
|
9 |
|
10 |
# Docker run arguments
|
11 |
DOCKER_RUN_ARGS = -p $(PORT):$(PORT) -v $(OUTPUT_DIR):/app/output/html
|
app.py
CHANGED
@@ -2,10 +2,8 @@ import hashlib
|
|
2 |
import gradio as gr
|
3 |
from pathlib import Path
|
4 |
from Bio.PDB import MMCIFParser, PDBIO
|
5 |
-
from folding_studio.commands.predict import af2 as af2_predict
|
6 |
-
from folding_studio.commands.predict import boltz as boltz_predict
|
7 |
-
from folding_studio.config import FOLDING_PROJECT_CODE
|
8 |
import logging
|
|
|
9 |
|
10 |
from molecule import molecule
|
11 |
|
@@ -38,15 +36,23 @@ def convert_cif_to_pdb(cif_path, pdb_path):
|
|
38 |
|
39 |
|
40 |
|
41 |
-
def predict(sequence: str) -> str:
|
42 |
"""Predict protein structure from amino acid sequence using Boltz model.
|
43 |
|
44 |
Args:
|
45 |
sequence (str): Amino acid sequence to predict structure for
|
|
|
46 |
|
47 |
Returns:
|
48 |
str: HTML iframe containing 3D molecular visualization
|
49 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
# Create FASTA file with sequence
|
51 |
seq_file = Path("sequence.fasta")
|
52 |
_write_fasta_file(seq_file, sequence)
|
@@ -136,6 +142,7 @@ with demo:
|
|
136 |
with gr.Row():
|
137 |
with gr.Column():
|
138 |
sequence = gr.Textbox(label="Sequence", value="")
|
|
|
139 |
gr.Markdown("# Output")
|
140 |
with gr.Row():
|
141 |
predict_btn = gr.Button("Predict")
|
@@ -144,7 +151,7 @@ with demo:
|
|
144 |
|
145 |
predict_btn.click(
|
146 |
fn=predict,
|
147 |
-
inputs=[sequence],
|
148 |
outputs=[mol_output]
|
149 |
)
|
150 |
|
|
|
2 |
import gradio as gr
|
3 |
from pathlib import Path
|
4 |
from Bio.PDB import MMCIFParser, PDBIO
|
|
|
|
|
|
|
5 |
import logging
|
6 |
+
import os
|
7 |
|
8 |
from molecule import molecule
|
9 |
|
|
|
36 |
|
37 |
|
38 |
|
39 |
+
def predict(sequence: str, api_key: str) -> str:
|
40 |
"""Predict protein structure from amino acid sequence using Boltz model.
|
41 |
|
42 |
Args:
|
43 |
sequence (str): Amino acid sequence to predict structure for
|
44 |
+
api_key (str): Folding API key
|
45 |
|
46 |
Returns:
|
47 |
str: HTML iframe containing 3D molecular visualization
|
48 |
"""
|
49 |
+
# Set API key in environment
|
50 |
+
os.environ["FOLDING_API_KEY"] = api_key
|
51 |
+
logger.info("API key has been set in environment")
|
52 |
+
# Import FS now so that the API key is read properly
|
53 |
+
from folding_studio.commands.predict import boltz as boltz_predict
|
54 |
+
from folding_studio.config import FOLDING_PROJECT_CODE
|
55 |
+
|
56 |
# Create FASTA file with sequence
|
57 |
seq_file = Path("sequence.fasta")
|
58 |
_write_fasta_file(seq_file, sequence)
|
|
|
142 |
with gr.Row():
|
143 |
with gr.Column():
|
144 |
sequence = gr.Textbox(label="Sequence", value="")
|
145 |
+
api_key = gr.Textbox(label="Folding API Key", type="password")
|
146 |
gr.Markdown("# Output")
|
147 |
with gr.Row():
|
148 |
predict_btn = gr.Button("Predict")
|
|
|
151 |
|
152 |
predict_btn.click(
|
153 |
fn=predict,
|
154 |
+
inputs=[sequence, api_key],
|
155 |
outputs=[mol_output]
|
156 |
)
|
157 |
|