Skip to content

Commit 876315a

Browse files
Merge pull request #229 from OpenTOPAS/main
update from main
2 parents c0e1a5e + 97c23d4 commit 876315a

13 files changed

Lines changed: 381 additions & 25 deletions

.github/DISCUSSION_TEMPLATE/feature-request.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ body:
3030
default: 0
3131
validations:
3232
required: true
33+
- type: checkboxes
34+
id: TOPAS-assistant-bot
35+
attributes:
36+
label: TOPAS-assistant-bot
37+
description: Please mark this checkbox if you are willing to receive a single response from the TOPAS-assistant-bot (beta version).
38+
options:
39+
- label: I would like to receive an immediate response from the TOPAS-assistant-bot.
40+
required: false
3341
- type: checkboxes
3442
id: terms
3543
attributes:
@@ -46,4 +54,3 @@ body:
4654
options:
4755
- label: I testify that I have fully read the bug reporting guideline beforehand.
4856
required: true
49-

.github/DISCUSSION_TEMPLATE/run-problem.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ body:
4949
- 3.8
5050
- 3.9
5151
- 4.0
52-
default: 0
52+
- 4.1
53+
- 4.2
54+
default: 5
5355
validations:
5456
required: true
5557
- type: dropdown
@@ -67,20 +69,27 @@ body:
6769
label: Relevant log output
6870
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
6971
render: shell
72+
- type: checkboxes
73+
id: TOPAS-assistant-bot
74+
attributes:
75+
label: TOPAS-assistant-bot
76+
description: Please mark this checkbox if you are willing to receive a single response from the TOPAS-assistant-bot (beta version).
77+
options:
78+
- label: I would like to receive an immediate response from the TOPAS-assistant-bot.
79+
required: false
7080
- type: checkboxes
7181
id: terms
7282
attributes:
7383
label: Code of Conduct
74-
description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com)
84+
description: By submitting this discussion, you agree to follow our [Code of Conduct](https://example.com)
7585
options:
7686
- label: I agree to follow this project's Code of Conduct
7787
required: true
7888
- type: checkboxes
7989
id: attestation
8090
attributes:
8191
label: Attestation
82-
description: By submitting this issue, you testify of having read the code of conduct.
92+
description: By submitting this discussion, you testify of having read the code of conduct.
8393
options:
8494
- label: I testify that I have fully read the bug reporting guideline beforehand.
8595
required: true
86-

.github/DISCUSSION_TEMPLATE/validation.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,32 @@ body:
3434
- 3.8
3535
- 3.9
3636
- 4.0
37-
default: 0
37+
- 4.1
38+
- 4.2
39+
default: 5
3840
validations:
3941
required: true
42+
- type: checkboxes
43+
id: TOPAS-assistant-bot
44+
attributes:
45+
label: TOPAS-assistant-bot
46+
description: Please mark this checkbox if you are willing to receive a single response from the TOPAS-assistant-bot (beta version).
47+
options:
48+
- label: I would like to receive an immediate response from the TOPAS-assistant-bot.
49+
required: false
4050
- type: checkboxes
4151
id: terms
4252
attributes:
4353
label: Code of Conduct
44-
description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com)
54+
description: By submitting this discussion, you agree to follow our [Code of Conduct](https://example.com)
4555
options:
4656
- label: I agree to follow this project's Code of Conduct
4757
required: true
4858
- type: checkboxes
4959
id: attestation
5060
attributes:
5161
label: Attestation
52-
description: By submitting this issue, you testify of having read the code of conduct.
62+
description: By submitting this discussion, you testify of having read the code of conduct.
5363
options:
5464
- label: I testify that I have fully read the bug reporting guideline beforehand.
5565
required: true
56-

.github/workflows/Dockerfile.topas.workflow

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
FROM debian:12
55

66
LABEL maintainer="Jose Ramos-Mendez <Jose.RamosMendez@ucsf.edu>" \
7-
description="Docker image for TOPAS v4.2.0 (Geant4 11.3.2, GDCM 2.6.8)"
7+
description="Docker image for TOPAS v4.2.1 (Geant4 11.3.2, GDCM 2.6.8)"
88

99
# -----------------------------
1010
# Base dependencies
@@ -21,7 +21,7 @@ RUN apt-get update && \
2121
# -----------------------------
2222
# Environment paths
2323
# -----------------------------
24-
ARG TOPAS_VERSION=v4.2.0
24+
ARG TOPAS_VERSION=v4.2.1
2525
ENV TOPAS_VERSION=${TOPAS_VERSION} \
2626
APP_HOME=/Applications
2727
RUN mkdir -p $APP_HOME
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: Discussion Bot
2+
3+
on:
4+
discussion:
5+
types: [created]
6+
7+
env:
8+
# Must match the model used when building the index.json embeddings.
9+
OPENAI_EMBEDDING_MODEL: "text-embedding-3-small"
10+
BOT_REPO: OpenTOPAS/TOPAS-assistant-bot
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
gpt-response:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Check user opted in to bot response
21+
id: optin
22+
env:
23+
BODY: ${{ github.event.discussion.body }}
24+
run: |
25+
set -euo pipefail
26+
# Match the exact checked checkbox line produced by the discussion form.
27+
# Use "--" so grep does not treat leading "-" in the pattern as an option.
28+
opt_in="- [x] I would like to receive an immediate response from the TOPAS-BOT."
29+
if printf "%s" "$BODY" | tr -d '\r' | grep -Fqi -- "$opt_in"; then
30+
echo "opted_in=true" >> "$GITHUB_OUTPUT"
31+
echo "Opt-in checkbox checked."
32+
else
33+
echo "opted_in=false" >> "$GITHUB_OUTPUT"
34+
echo "Opt-in checkbox not checked; skipping bot response."
35+
fi
36+
37+
- name: Checkout OpenTOPAS
38+
if: steps.optin.outputs.opted_in == 'true'
39+
uses: actions/checkout@v4
40+
41+
- name: Validate required secrets
42+
if: steps.optin.outputs.opted_in == 'true'
43+
env:
44+
BOT_APP_ID: ${{ secrets.BOT_APP_ID }}
45+
BOT_APP_PRIVATE_KEY: ${{ secrets.BOT_APP_PRIVATE_KEY }}
46+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
47+
run: |
48+
set -euo pipefail
49+
if [ -z "${BOT_APP_ID:-}" ]; then
50+
echo "Missing required secret: BOT_APP_ID (must be the GitHub App ID)."
51+
exit 1
52+
fi
53+
if [ -z "${BOT_APP_PRIVATE_KEY:-}" ]; then
54+
echo "Missing required secret: BOT_APP_PRIVATE_KEY (paste the full .pem contents)."
55+
exit 1
56+
fi
57+
if [ -z "${OPENAI_API_KEY:-}" ]; then
58+
echo "Missing required secret: OPENAI_API_KEY."
59+
exit 1
60+
fi
61+
62+
# Solution using the GitHub App avoids problems with private/public bot/source code repos. It works for both.
63+
- name: Create GitHub App token
64+
if: steps.optin.outputs.opted_in == 'true'
65+
id: app-token
66+
uses: actions/create-github-app-token@v1
67+
with:
68+
app-id: ${{ secrets.BOT_APP_ID }}
69+
private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}
70+
owner: OpenTOPAS
71+
# Explicitly scope the token to the repos we need to access.
72+
# This avoids cases where the token only has access to the current repo.
73+
repositories: OpenTOPAS,TOPAS-assistant-bot
74+
75+
- name: Debug App token repository access
76+
if: steps.optin.outputs.opted_in == 'true'
77+
env:
78+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
79+
run: |
80+
set -euo pipefail
81+
echo "Token can access these repos:"
82+
gh api installation/repositories -q '.repositories[].full_name'
83+
84+
- name: Verify App token can access bot repo
85+
if: steps.optin.outputs.opted_in == 'true'
86+
env:
87+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
88+
run: |
89+
set -euo pipefail
90+
# For private repos, GitHub returns 404 when the token lacks access.
91+
if ! gh api "repos/${BOT_REPO}" >/dev/null; then
92+
echo "GitHub App token cannot access ${BOT_REPO}."
93+
echo "Fix: ensure the GitHub App installation includes ${BOT_REPO} and has Contents: read, then re-run."
94+
exit 1
95+
fi
96+
97+
- name: Verify App token has Contents read on bot repo
98+
if: steps.optin.outputs.opted_in == 'true'
99+
env:
100+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
101+
run: |
102+
set -euo pipefail
103+
# Cloning requires Contents: read. Metadata-only access can still list repos but cannot read files.
104+
# This call should succeed if Contents permission has been granted AND re-approved on the installation.
105+
if ! gh api "repos/${BOT_REPO}/contents/" >/dev/null; then
106+
echo "GitHub App token can see ${BOT_REPO} but cannot read repository contents."
107+
echo "Fix: in the GitHub App settings, set Repository permissions -> Contents: Read-only,"
108+
echo "then re-install (or re-configure) the app installation on ${BOT_REPO} to approve new permissions."
109+
exit 1
110+
fi
111+
112+
- name: Checkout bot repo
113+
if: steps.optin.outputs.opted_in == 'true'
114+
id: bot-repo
115+
uses: actions/checkout@v4
116+
with:
117+
repository: ${{ env.BOT_REPO }}
118+
token: ${{ steps.app-token.outputs.token }}
119+
path: topas-bot
120+
121+
- name: Set up Python
122+
uses: actions/setup-python@v5
123+
with:
124+
python-version: "3.11"
125+
126+
- name: Install bot dependencies
127+
if: steps.optin.outputs.opted_in == 'true'
128+
run: pip install -r topas-bot/requirements.txt
129+
130+
- name: Download latest index.json from bot repo releases
131+
if: steps.optin.outputs.opted_in == 'true'
132+
env:
133+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
134+
run: |
135+
mkdir -p topas-bot/.bot
136+
137+
# Since index.json is a release asset we need to first find the API URL.
138+
# gh api returns an array of releases where [0] is the latest.
139+
# .assets loops over assets of that release then we select index.json
140+
asset_api_url="$(gh api repos/${{ env.BOT_REPO }}/releases -q '.[0].assets[] | select(.name=="index.json") | .url')"
141+
if [ -z "${asset_api_url}" ]; then
142+
echo "Could not find index.json asset on latest release in ${{ env.BOT_REPO }}"
143+
exit 1
144+
fi
145+
146+
curl -fsSL \
147+
-H "Authorization: Bearer ${GH_TOKEN}" \
148+
-H "Accept: application/octet-stream" \
149+
"${asset_api_url}" \
150+
-o topas-bot/.bot/index.json
151+
152+
test -s topas-bot/.bot/index.json
153+
154+
- name: Run GPT Response Script
155+
if: steps.optin.outputs.opted_in == 'true'
156+
working-directory: topas-bot
157+
env:
158+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
159+
OPENAI_EMBEDDING_MODEL: ${{ env.OPENAI_EMBEDDING_MODEL }}
160+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
161+
run: python .github/actions/get_gpt_response.py

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ enable_testing()
1010

1111
set (TOPAS_VERSION_MAJOR 4)
1212
set (TOPAS_VERSION_MINOR 2)
13-
set (TOPAS_VERSION_PATCH 0)
13+
set (TOPAS_VERSION_PATCH 1)
1414

1515
# Print compiler information
1616
message (STATUS "CMAKE_CXX_COMPILER_ID: " ${CMAKE_CXX_COMPILER_ID})

OpenTOPAS_quickStart_Debian.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# QuickStart Guide for OpenTOPAS: TOol for PArticle Simulation
22
This file details the steps to be followed by <ins>Debian 10, 11 or 12</ins> in order to install OpenTOPAS and launch your first simulation.
33

4-
These instructions target TOPAS version **v4.2.0** built against Geant4 **v11.3.2**.
4+
These instructions target **v4.2.1** built against Geant4 **v11.3.2**.
55

66
> [!TIP]
77
> The directory path setting proposed in this quickStart guide sets a local installation at the home directory (path defined by `$HOME` environment variable).
@@ -139,7 +139,7 @@ Downloading and installing OpenTOPAS and GDCM.
139139
cd $HOME/Applications/TOPAS
140140
git clone https://github.com/OpenTOPAS/OpenTOPAS.git
141141
cd OpenTOPAS
142-
git checkout v4.2.0
142+
git checkout v4.2.1
143143

144144
8.1.b Alternatively, you can download OpenTOPAS manually. For a manual download, go to the OpenTOPAS GitHub [website](https://github.com/OpenTOPAS/OpenTOPAS/tree/master), click on the green tab named `<> Code` and `Download ZIP`. Create a directory called `TOPAS` in your `$HOME/Applications` directory, move the compressed folder into this directory, and decompress the file. To follow the following commands, rename the decompressed folder `OpenTOPAS-main` as `OpenTOPAS`. You should have the directory `$HOME/Applications/TOPAS/Open-TOPAS`
145145

@@ -235,9 +235,9 @@ The OpenTOPAS tests are located [here](https://github.com/OpenTOPAS/qi-opentopas
235235
pip3 install nrtest
236236
pip3 install git+https://github.com/davidchall/nrtest-topas.git
237237

238-
Modify the `apps/topas-v4.2.0.json` metadata file according to your directories and configuration (remember to set your environment variables) and execute the entire test suite as follows:
238+
Modify the `apps/topas-v4.2.1.json` metadata file according to your directories and configuration (remember to set your environment variables) and execute the entire test suite as follows:
239239

240-
nrtest execute apps/topas-v4.2.0.json tests/ -o benchmarks/todayDate
240+
nrtest execute apps/topas-v4.2.1.json tests/ -o benchmarks/todayDate
241241

242242
Comparisons can also be made with the following command:
243243

OpenTOPAS_quickStart_MacOS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# QuickStart Guide for OpenTOPAS: TOol for PArticle Simulation
22
This file details the steps to be followed by <ins>Mac users</ins> in order to install OpenTOPAS and launch your first simulation.
33

4-
These instructions target TOPAS version **v4.2.0** built against Geant4 **v11.3.2**.
4+
These instructions target **v4.2.1** built against Geant4 **v11.3.2**.
55

66
> [!WARNING]
77
> We recommend macOS version 14.0 (Sonoma) or higher. Furthermore following these instructions are solely responsability of the end user.
@@ -155,7 +155,7 @@ Downloading and installing OpenTOPAS and GDCM.
155155
cd /Applications/TOPAS
156156
git clone https://github.com/OpenTOPAS/OpenTOPAS.git
157157
cd OpenTOPAS
158-
git checkout v4.2.0
158+
git checkout v4.2.1
159159

160160
7.2. Next, check if the /Applications/GDCM already exists (GDCM is already installed). If so, rename the directory to GDCM-OLD (or another name) using the following command.
161161

@@ -256,9 +256,9 @@ The OpenTOPAS tests are located [here](https://github.com/OpenTOPAS/qi-opentopas
256256
pip3 install nrtest
257257
pip3 install git+https://github.com/davidchall/nrtest-topas.git
258258

259-
Modify the `apps/topas-v4.2.0.json` metadata file according to your directories and configuration (remember to set your environment variables) and execute the entire test suite as follows:
259+
Modify the `apps/topas-v4.2.1.json` metadata file according to your directories and configuration (remember to set your environment variables) and execute the entire test suite as follows:
260260

261-
nrtest execute apps/topas-v4.2.0.json tests/ -o benchmarks/todayDate
261+
nrtest execute apps/topas-v4.2.1.json tests/ -o benchmarks/todayDate
262262

263263
Comparisons can also be made with the following command:
264264

OpenTOPAS_quickStart_WSL.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# QuickStart Guide for WSL
22
This page details the steps to be followed by <ins>Windows users</ins> in order to install OpenTOPAS in <ins>WSL</ins> and launch your first simulation.
33

4-
These instructions target TOPAS version **v4.2.0** built against Geant4 **v11.3.2**.
4+
These instructions target **v4.2.1** built against Geant4 **v11.3.2**.
55

66
> [!WARNING]
77
> We recommend Windows 11 or higher since it includes all the visualization libraries built in. We take no responsibility if users encounter an issue with their PCs while following this guide.
@@ -176,7 +176,7 @@ Then, download OpenTOPAS from the GitHub repository using:
176176
cd ~/Applications/TOPAS
177177
git clone https://github.com/OpenTOPAS/OpenTOPAS.git
178178
cd OpenTOPAS
179-
git checkout v4.2.0
179+
git checkout v4.2.1
180180

181181
Compile GDCM as follows:
182182

@@ -264,9 +264,9 @@ The OpenTOPAS tests are located [here](https://github.com/OpenTOPAS/qi-opentopas
264264
pip3 install nrtest
265265
pip3 install git+https://github.com/davidchall/nrtest-topas.git
266266

267-
Modify the `apps/topas-v4.2.0.json` metadata file according to your directories and configuration (remember to set your environment variables) and execute the entire test suite as follows:
267+
Modify the `apps/topas-v4.2.1.json` metadata file according to your directories and configuration (remember to set your environment variables) and execute the entire test suite as follows:
268268

269-
nrtest execute apps/topas-v4.2.0.json tests/ -o benchmarks/todayDate
269+
nrtest execute apps/topas-v4.2.1.json tests/ -o benchmarks/todayDate
270270

271271
Comparisons can also be made with the following command:
272272

docker/README.Docker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TOPAS Docker
22

3-
This repository provides Docker recipes and helper scripts for (re)building and running TOPAS (OpenTOPAS v4.1.1, Geant4 11.1.3, GDCM 2.6.8) on macOS or Linux. Use it to keep Geant4 data outside the container while iterating on parameter files, extensions, or visualization workflows.
3+
This repository provides Docker recipes and helper scripts for (re)building and running TOPAS (OpenTOPAS v4.2.1, Geant4 11.1.3, GDCM 2.6.8) on macOS or Linux. Use it to keep Geant4 data outside the container while iterating on parameter files, extensions, or visualization workflows.
44

55
## Run Simulations
66
Mount your Geant4 data and simulation files from the host:

0 commit comments

Comments
 (0)