Skip to content

Commit c3e293e

Browse files
committed
Mounting models folder as volume
1 parent 2e14de9 commit c3e293e

4 files changed

Lines changed: 10 additions & 12 deletions

File tree

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ services:
55
build:
66
dockerfile: ./docker/article-relevance/Dockerfile
77
context: .
8-
args:
9-
- MODEL_PATH=models/article-relevance/logistic_regression_model.joblib
108
environment:
119
- N_RECENT=10
1210
- MIN_DATE=
@@ -21,6 +19,7 @@ services:
2119
- ./data/article-relevance/outputs:/output
2220
- ./data/article-relevance/processed/prediction_parquet:/parquet
2321
- ./data/article-relevance/raw:/raw
22+
- ./models/article-relevance:/models
2423

2524
data-review-tool:
2625
image: metaextractor-data-review-tool:v0.0.1
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
# Use the official Python 3.10 image as the base image
22
FROM python:3.10
33

4-
ARG MODEL_PATH
5-
ARG DOI_FILE_PATH
6-
74
ENV DOI_PATH="/raw"
85
ENV PARQUET_PATH="/parquet"
9-
ENV ENV_DOI_FILE_PATH=$DOI_FILE_PATH
106
# Set the working directory inside the container
117
WORKDIR /app/
128

@@ -19,9 +15,6 @@ RUN pip install --no-cache-dir -r requirements.txt
1915
# Copy the entire repository folder into the container
2016
COPY src ./src
2117

22-
# Copy the model folder into the container
23-
COPY $MODEL_PATH ./models/article-relevance
24-
2518
# Copy the shell script to the container
2619
COPY docker/article-relevance/run-prediction.sh .
2720

@@ -32,7 +25,8 @@ RUN chmod +x run-prediction.sh
3225
RUN mkdir -p /output
3326
RUN mkdir -p /raw
3427
RUN mkdir -p /parquet
35-
VOLUME ["/output", "/parquet", "/raw"]
28+
RUN mkdir -p /models
29+
VOLUME ["/output", "/parquet", "/raw", "/models"]
3630

3731
# Set the entry point for the Docker container
3832
ENTRYPOINT ["./run-prediction.sh"]

docker/article-relevance/run-prediction.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ python src/article_relevance/gdd_api_query.py \
1212

1313
python src/article_relevance/relevance_prediction_parquet.py \
1414
--doi_file_path="$DOI_FILE_PATH" \
15-
--model_path="$MODEL_PATH" \
1615
--output_path="$OUTPUT_PATH" \
1716
--send_xdd="$SEND_XDD"

src/article_relevance/relevance_prediction_parquet.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,15 @@ def main():
422422
opt = docopt(__doc__)
423423

424424
doi_list_file_path = opt["--doi_file_path"]
425-
model_path = opt['--model_path']
426425
output_path = opt['--output_path']
427426
send_xdd = opt['--send_xdd']
427+
428+
# /models directory is a mounted volume, containing the model object
429+
models = os.lsitdir("/models")
430+
if models:
431+
model_path = os.path.join("/models", models[0])
432+
else:
433+
model_path = ""
428434

429435
metadata_df = crossref_extract(doi_list_file_path)
430436

0 commit comments

Comments
 (0)