Skip to content

Commit 9f662ed

Browse files
authored
feat: talk2scholars docker update (#118)
* fix: updated same as README * fix: date time error while diplaying papers from zotero * chores: updated index for talk2scholars dockerfile * chores: updated readme for talk2scholars dockerfile * feat: added dockerfile for talk2scholars * fix: updated docker file for better support * feat: matrix strategy for parallel deployement * chores: updated readme for talk2scholars dockerfile * chores: updated readme for talk2scholars dockerfile * chores: updated readme for talk2scholars dockerfile * chores: updated readme for talk2scholars dockerfile * feat: Detects changes and runs only the necessary build jobs * feat: Detects changes and runs only the necessary build jobs * fix: Fix Docker login: Use vars for DOCKERHUB_USERNAME * fix: Debug Git Tag * fix: git tags * fix: Auto-increments version * fix: retry with with method * fix: Now uses the latest tag directly from semantic-release * fix: If no tag is found, it provides a meaningful fallback version * fix: Moved version generation directly into each build job * fix: Using a hardcoded v0.1.0-test version for both modules * fix: tags error fix * feat: Make CI workflow run after a RELEASE workflow * fix: A step that gets the latest git tag using git describe --tags --abbrev=0 * fix: Removed the invalid condition from the workflow trigger * fix: I've simplified the workflow to just use the basic workflow_run trigger without any additional conditions. * feat: Uses the dorny/paths-filter@v2 action to detect file changes in specific directories * feat: adding automatic version incrementing
1 parent 3282e55 commit 9f662ed

6 files changed

Lines changed: 274 additions & 42 deletions

File tree

.github/workflows/ci.yml

Lines changed: 118 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,132 @@
1-
name: Docker hub deployment
2-
1+
name: Docker Build and Push
32
on:
3+
# Trigger after RELEASE workflow completes
4+
workflow_run:
5+
workflows: ["RELEASE"]
6+
types:
7+
- completed
8+
branches:
9+
- main
10+
# Keep existing triggers for flexibility
11+
push:
12+
branches:
13+
- main
14+
pull_request:
15+
branches:
16+
- main
417
workflow_dispatch:
518

619
jobs:
7-
docker:
20+
# Detect which modules have changed
21+
changes:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
talk2biomodels: ${{ steps.filter.outputs.talk2biomodels }}
25+
talk2scholars: ${{ steps.filter.outputs.talk2scholars }}
26+
steps:
27+
- name: Checkout Repository
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Check for changes
33+
uses: dorny/paths-filter@v2
34+
id: filter
35+
with:
36+
filters: |
37+
talk2biomodels:
38+
- 'aiagents4pharma/talk2biomodels/**'
39+
talk2scholars:
40+
- 'aiagents4pharma/talk2scholars/**'
41+
42+
# Generate version for the build
43+
version:
44+
runs-on: ubuntu-latest
45+
outputs:
46+
version: ${{ steps.get_version.outputs.version }}
47+
short_sha: ${{ steps.get_short_sha.outputs.short_sha }}
48+
steps:
49+
- name: Checkout Repository
50+
uses: actions/checkout@v4
51+
with:
52+
fetch-depth: 0
53+
54+
# Get the latest version from git tags
55+
- name: Get latest version tag
56+
id: get_version
57+
run: |
58+
# Get the latest tag from git
59+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
60+
61+
# For workflow_run triggered from RELEASE workflow, use the tag as is
62+
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
63+
VERSION=$LATEST_TAG
64+
else
65+
# For other triggers (PR, push, etc.), create a development version
66+
# Strip the 'v' prefix
67+
VERSION=${LATEST_TAG#v}
68+
# Get count of commits since latest tag
69+
COMMIT_COUNT=$(git rev-list ${LATEST_TAG}..HEAD --count)
70+
# Create dev version: latest tag + dev + commit count
71+
VERSION="v${VERSION}-dev.${COMMIT_COUNT}"
72+
fi
73+
74+
echo "Using version: $VERSION"
75+
echo "version=$VERSION" >> $GITHUB_OUTPUT
76+
77+
# Get short SHA for tagging
78+
- name: Get short SHA
79+
id: get_short_sha
80+
run: |
81+
SHORT_SHA=$(git rev-parse --short HEAD)
82+
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
83+
84+
# Separate job for talk2biomodels
85+
build-talk2biomodels:
86+
needs: [changes, version]
87+
if: ${{ needs.changes.outputs.talk2biomodels == 'true' }}
888
runs-on: ubuntu-latest
989
steps:
10-
-
11-
name: Login to Docker Hub
90+
- name: Checkout Repository
91+
uses: actions/checkout@v4
92+
93+
- name: Login to Docker Hub
1294
uses: docker/login-action@v3
1395
with:
1496
username: ${{ vars.DOCKERHUB_USERNAME }}
1597
password: ${{ secrets.DOCKERHUB_TOKEN }}
16-
-
17-
name: Build and push
98+
99+
- name: Build and Push Docker Image
18100
uses: docker/build-push-action@v6
19101
with:
20102
file: aiagents4pharma/talk2biomodels/Dockerfile
21103
push: true
22-
tags: virtualpatientengine/talk2biomodels:v1
104+
tags: |
105+
virtualpatientengine/talk2biomodels:${{ needs.version.outputs.version }}
106+
virtualpatientengine/talk2biomodels:${{ needs.version.outputs.short_sha }}
107+
virtualpatientengine/talk2biomodels:latest
108+
109+
# Separate job for talk2scholars
110+
build-talk2scholars:
111+
needs: [changes, version]
112+
if: ${{ needs.changes.outputs.talk2scholars == 'true' }}
113+
runs-on: ubuntu-latest
114+
steps:
115+
- name: Checkout Repository
116+
uses: actions/checkout@v4
117+
118+
- name: Login to Docker Hub
119+
uses: docker/login-action@v3
120+
with:
121+
username: ${{ vars.DOCKERHUB_USERNAME }}
122+
password: ${{ secrets.DOCKERHUB_TOKEN }}
123+
124+
- name: Build and Push Docker Image
125+
uses: docker/build-push-action@v6
126+
with:
127+
file: aiagents4pharma/talk2scholars/Dockerfile
128+
push: true
129+
tags: |
130+
virtualpatientengine/talk2scholars:${{ needs.version.outputs.version }}
131+
virtualpatientengine/talk2scholars:${{ needs.version.outputs.short_sha }}
132+
virtualpatientengine/talk2scholars:latest

README.md

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,62 @@ pip install aiagents4pharma
3333

3434
Check out the tutorials on each agent for detailed instrcutions.
3535

36-
#### Option 2: docker hub
36+
#### Option 2: Docker Hub
3737

38-
_Please note that this option is currently available only for Talk2Biomodels._
38+
_Both `Talk2Biomodels` and `Talk2Scholars` are now available on Docker Hub._
3939

40-
1. **Pull the image**
41-
```
40+
#### **Running Talk2Biomodels**
41+
42+
1. **Pull the Docker image**
43+
```bash
4244
docker pull virtualpatientengine/talk2biomodels
4345
```
44-
2. **Run a container**
46+
2. **Run the container**
47+
```bash
48+
docker run -d \
49+
-e OPENAI_API_KEY=<your_openai_api_key> \
50+
-e NVIDIA_API_KEY=<your_nvidia_api_key> \
51+
-p 8501:8501 \
52+
virtualpatientengine/talk2biomodels
53+
```
54+
3. **Access the Web App**
55+
Open your browser and go to:
4556
```
46-
docker run -e OPENAI_API_KEY=<openai_api_key> -e NVIDIA_API_KEY=<nvidia_api_key> -p 8501:8501 virtualpatientengine/talk2biomodels
57+
http://localhost:8501
4758
```
4859
_You can create a free account at NVIDIA and apply for their
4960
free credits [here](https://build.nvidia.com/explore/discover)._
5061

62+
#### **Running Talk2Scholars**
63+
64+
1. **Pull the Docker image**
65+
```bash
66+
docker pull virtualpatientengine/talk2scholars
67+
```
68+
2. **Run the container**
69+
```bash
70+
docker run -d \
71+
-e OPENAI_API_KEY=<your_openai_api_key> \
72+
-e ZOTERO_API_KEY=<your_zotero_api_key> \
73+
-e ZOTERO_USER_ID=<your_zotero_user_id> \
74+
-p 8501:8501 \
75+
virtualpatientengine/talk2scholars
76+
```
77+
3. **Access the Web App**
78+
Open your browser and go to:
79+
```
80+
http://localhost:8501
81+
```
82+
83+
#### **Notes**
84+
85+
- Ensure you **replace `<your_openai_api_key>`, `<your_nvidia_api_key>`, `<your_zotero_api_key>`, and `<your_zotero_user_id>`** with your actual credentials.
86+
- Both applications use **port `8501`**, so run them on different ports if needed:
87+
```bash
88+
docker run -d -e OPENAI_API_KEY=<your_openai_api_key> -p 8501:8501 virtualpatientengine/talk2scholars
89+
```
90+
Then, access it via `http://localhost:8501`.
91+
5192
#### Option 3: git
5293

5394
1. **Clone the repository:**
@@ -63,9 +104,6 @@ _Please note that this option is currently available only for Talk2Biomodels._
63104

64105
```bash
65106
export OPENAI_API_KEY=....
66-
```
67-
68-
```bash
69107
export NVIDIA_API_KEY=....
70108
```
71109

aiagents4pharma/talk2biomodels/Dockerfile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@ FROM python:3.12-slim
22

33
WORKDIR /app
44

5-
# Copy the current directory contents into the container at /app
5+
# Install system dependencies required for compiling packages
6+
RUN apt-get update && apt-get install -y \
7+
g++ \
8+
build-essential \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
# Copy necessary files
612
COPY aiagents4pharma/talk2biomodels /app/aiagents4pharma/talk2biomodels
713
COPY docs /app/docs
814
COPY app /app/app
9-
1015
COPY requirements.txt /app
1116

17+
# Install Python dependencies
18+
RUN pip install --upgrade pip setuptools wheel
1219
RUN pip install --no-cache-dir -r requirements.txt
1320

14-
# COPY T2B /app/T2B
21+
# Expose the default Streamlit port
22+
EXPOSE 8501
23+
24+
# Run the Streamlit application
25+
CMD ["streamlit", "run", "app/frontend/streamlit_app_talk2biomodels.py", "--server.port=8501", "--server.address=0.0.0.0"]
1526

16-
CMD ["streamlit", "run", "app/frontend/streamlit_app_talk2biomodels.py"]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM python:3.12-slim
2+
3+
WORKDIR /app
4+
5+
# Install system dependencies required for compiling packages
6+
RUN apt-get update && apt-get install -y \
7+
g++ \
8+
build-essential \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
# Copy necessary files
12+
COPY aiagents4pharma/talk2scholars /app/aiagents4pharma/talk2scholars
13+
COPY docs /app/docs
14+
COPY app /app/app
15+
COPY requirements.txt /app
16+
17+
# Install Python dependencies
18+
RUN pip install --upgrade pip setuptools wheel
19+
RUN pip install --no-cache-dir -r requirements.txt
20+
21+
# Expose the default Streamlit port
22+
EXPOSE 8501
23+
24+
# Run the Streamlit application
25+
CMD ["streamlit", "run", "app/frontend/streamlit_app_talk2scholars.py", "--server.port=8501", "--server.address=0.0.0.0"]

app/frontend/streamlit_app_talk2scholars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def _submit_feedback(user_response):
338338
pd.to_datetime(x, errors="coerce").strftime(
339339
"%Y-%m-%d"
340340
)
341-
if pd.notna(x)
341+
if pd.notna(pd.to_datetime(x, errors="coerce"))
342342
else None
343343
)
344344
)

0 commit comments

Comments
 (0)