Skip to content

Commit bf00e83

Browse files
authored
Merge pull request #577 from Steinbeck-Lab/development
fix: update clear InChI logs to frontend
2 parents 877394b + e220c09 commit bf00e83

File tree

9 files changed

+183
-82
lines changed

9 files changed

+183
-82
lines changed

.github/workflows/deploy-doc.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
# GitHub Actions workflow to deploy documentation to GitHub Pages
2+
13
name: Docs Deployment - GitHub Pages
4+
5+
# Trigger on manual dispatch or push to main branch
26
on:
37
workflow_dispatch: {}
48
push:
@@ -7,6 +11,7 @@ on:
711

812
jobs:
913
deploy:
14+
# Job to build and deploy docs
1015
runs-on: ubuntu-latest
1116
permissions:
1217
pages: write
@@ -15,22 +20,38 @@ jobs:
1520
name: github-pages
1621
url: ${{ steps.deployment.outputs.page_url }}
1722
steps:
23+
# Checkout repository
1824
- uses: actions/checkout@v4
1925
with:
2026
fetch-depth: 0
27+
28+
# Setup Node.js environment
2129
- uses: actions/setup-node@v4
2230
with:
2331
node-version: 18
2432
cache: npm
33+
34+
# Install dependencies
2535
- run: npm ci
36+
37+
# Build documentation
2638
- name: Build
2739
run: npm run docs:build
40+
41+
# Debug build output
2842
- name: Debug - Check build output
2943
run: ls -l docs/.vitepress/dist
44+
45+
# Configure GitHub Pages
3046
- uses: actions/configure-pages@v3
47+
48+
# Upload static site artifact
3149
- uses: actions/upload-pages-artifact@v3
3250
with:
3351
path: docs/.vitepress/dist
52+
53+
# Deploy to GitHub Pages
3454
- name: Deploy
3555
id: deployment
3656
uses: actions/deploy-pages@v4
57+

.github/workflows/dev-build.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This worklflow will perform following actions when the code is pushed to development branch:
1+
# This workflow will perform following actions when the code is pushed to development branch:
22
# - Test linting with pylint.
33
# - Fetch Latest release.
44
# - Build the latest docker image in development which needs test to pass first.
@@ -34,6 +34,7 @@ jobs:
3434
username: ${{ env.DOCKER_HUB_USERNAME }}
3535
password: ${{ env.DOCKER_HUB_PASSWORD }}
3636

37+
# Build and push main API Docker image
3738
- name: Build and push Docker image
3839
uses: docker/[email protected]
3940
with:
@@ -44,8 +45,19 @@ jobs:
4445
RELEASE_VERSION=dev-latest
4546
tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:api-dev
4647

48+
# Check if frontend files have changed to optimize build process
49+
- name: Check for frontend changes
50+
uses: dorny/paths-filter@v2
51+
id: frontend-changes
52+
with:
53+
filters: |
54+
frontend:
55+
- 'frontend/**'
56+
57+
# Build frontend Docker image only if frontend files changed
4758
- name: Build and push frontend Docker image
4859
uses: docker/[email protected]
60+
if: steps.frontend-changes.outputs.frontend == 'true'
4961
with:
5062
context: ./frontend
5163
file: ./frontend/Dockerfile

.github/workflows/prod-build.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ on:
1313
release:
1414
types: [published]
1515

16+
17+
# Set global environment variables
1618
env:
1719
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
1820
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
@@ -21,30 +23,31 @@ env:
2123

2224
jobs:
2325
push_to_registry:
26+
# Job to build and push Docker images
2427
name: Push Docker images to Docker Hub
2528
runs-on: ubuntu-latest
2629
steps:
30+
# Checkout code
2731
- name: Check out the repo
2832
uses: actions/checkout@v4
29-
33+
34+
# Fetch latest GitHub release
3035
- name: Fetch latest release
3136
id: fetch-latest-release
3237
uses: InsonusK/[email protected]
3338
with:
3439
myToken: ${{ github.token }}
3540
exclude_types: "draft"
3641
view_top: 10
37-
38-
- name: Print release name
39-
run: |
40-
echo "tag_name: ${{ steps.fetch-latest-release.outputs.tag_name }}"
41-
42+
43+
# Docker Hub login
4244
- name: Log in to Docker Hub
4345
uses: docker/login-action@v4
4446
with:
4547
username: ${{ env.DOCKER_HUB_USERNAME }}
4648
password: ${{ env.DOCKER_HUB_PASSWORD }}
4749

50+
# Build and push backend image
4851
- name: Build and push full Docker image
4952
uses: docker/build-push-action@v4
5053
with:
@@ -57,6 +60,16 @@ jobs:
5760
${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:${{ steps.fetch-latest-release.outputs.tag_name }}
5861
${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:latest
5962
63+
# Check if frontend files have changed to optimize build process
64+
- name: Check for frontend changes
65+
uses: dorny/paths-filter@v2
66+
id: frontend-changes
67+
with:
68+
filters: |
69+
frontend:
70+
- 'frontend/**'
71+
72+
# Build and push lite version of backend image
6073
- name: Build and push lite Docker image
6174
uses: docker/build-push-action@v4
6275
with:
@@ -69,8 +82,10 @@ jobs:
6982
${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:${{ steps.fetch-latest-release.outputs.tag_name }}-lite
7083
${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:latest-lite
7184
85+
# Build frontend Docker image only if frontend files changed
7286
- name: Build and push frontend Docker image
7387
uses: docker/build-push-action@v4
88+
if: steps.frontend-changes.outputs.frontend == 'true'
7489
with:
7590
context: ./frontend
7691
file: ./frontend/Dockerfile

.github/workflows/release-please.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
release-please:
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: google-github-actions/release-please-action@v3
22+
- uses: google-github-actions/release-please-action@v4
2323
with:
2424
release-type: python
2525
package-name: release-please-action

frontend/src/components/tools/InChIView.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ const InChIOptions = ({ onChange, inchiVersion, setInchiVersion }) => {
4747
const [t15, setT15] = useState(false);
4848
const [polymers, setPolymers] = useState(false);
4949
const [NPZz, setNPZz] = useState(false);
50-
const [molecularInorganics, setMolecularInorganics] = useState(inchiVersion === "1.07.3-orgmet");
50+
const [molecularInorganics, setMolecularInorganics] = useState(
51+
inchiVersion === "1.07.3-orgmet"
52+
);
5153
const [showTautomerism, setShowTautomerism] = useState(true); // Add state for tautomerism visibility
5254

5355
// Additional stereo options
@@ -112,7 +114,8 @@ const InChIOptions = ({ onChange, inchiVersion, setInchiVersion }) => {
112114
if (NPZz) options.push("NPZz");
113115

114116
// molecularInorganics is only available in the 1.07.3-orgmet version
115-
if (molecularInorganics && inchiVersion === "1.07.3-orgmet") options.push("MolecularInorganics");
117+
if (molecularInorganics && inchiVersion === "1.07.3-orgmet")
118+
options.push("MolecularInorganics");
116119

117120
// Format the options string as required by the API
118121
const optionsString = options.map((opt) => `-${opt}`).join(" ");
@@ -948,6 +951,7 @@ const InChIView = () => {
948951
return result;
949952
} catch (err) {
950953
console.error("Failed to generate InChI from molfile:", err);
954+
setLogMessage(`Failed to generate InChI: ${err.message}`);
951955
setError(`Failed to generate InChI: ${err.message}`);
952956
throw err;
953957
} finally {
@@ -1000,6 +1004,7 @@ const InChIView = () => {
10001004
await generateInChIFromMolfile(molfile);
10011005
} catch (err) {
10021006
console.error("Failed to generate InChI:", err);
1007+
setLogMessage(`Error: ${err.message}`);
10031008
setError(`Failed to generate InChI: ${err.message}`);
10041009
setIsLoading(false);
10051010
}

frontend/src/components/tools/RInChIView.jsx

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,17 @@ const RInChIView = () => {
573573
// Generate RInChI from Ketcher
574574
const generateRInChI = async () => {
575575
if (!isEditorReady) {
576-
setError("Editor not ready. Please try again in a moment.");
576+
const errorMsg = "Editor not ready. Please try again in a moment.";
577+
setError(errorMsg);
578+
setLogMessage(errorMsg);
577579
return;
578580
}
579581

580582
if (!rinchiModuleLoaded) {
581-
setError("RInChI module not loaded. Please wait or refresh the page.");
583+
const errorMsg =
584+
"RInChI module not loaded. Please wait or refresh the page.";
585+
setError(errorMsg);
586+
setLogMessage(errorMsg);
582587
return;
583588
}
584589

@@ -595,9 +600,10 @@ const RInChIView = () => {
595600
// Check if there's a reaction
596601
const hasReaction = await checkForReaction();
597602
if (!hasReaction) {
598-
setError(
599-
"No reaction found. Please draw a reaction with reactants and products."
600-
);
603+
const errorMsg =
604+
"No reaction found. Please draw a reaction with reactants and products.";
605+
setError(errorMsg);
606+
setLogMessage(errorMsg);
601607
setIsLoading(false);
602608
return;
603609
}
@@ -606,9 +612,10 @@ const RInChIView = () => {
606612
const rxnFile = await executeKetcherCommand("getRxn");
607613

608614
if (!rxnFile || rxnFile.trim() === "") {
609-
setError(
610-
"Failed to get reaction data. Please ensure you've drawn a valid reaction."
611-
);
615+
const errorMsg =
616+
"Failed to get reaction data. Please ensure you've drawn a valid reaction.";
617+
setError(errorMsg);
618+
setLogMessage(errorMsg);
612619
setIsLoading(false);
613620
return;
614621
}
@@ -626,6 +633,7 @@ const RInChIView = () => {
626633
await convertReactionToRinchiAndWriteResults(rxnFile, isEquilibrium);
627634
} catch (err) {
628635
console.error("Failed to generate RInChI:", err);
636+
setLogMessage(`Failed to generate RInChI: ${err.message}`);
629637
setError(`Failed to generate RInChI: ${err.message}`);
630638
setIsLoading(false);
631639
}
@@ -685,7 +693,9 @@ const RInChIView = () => {
685693
return result;
686694
} catch (err) {
687695
console.error("Failed to generate RInChI from reaction:", err);
688-
setError(`Failed to generate RInChI: ${err.message}`);
696+
const errorMsg = `Failed to generate RInChI: ${err.message}`;
697+
setError(errorMsg);
698+
setLogMessage(errorMsg);
689699
throw err;
690700
} finally {
691701
setIsLoading(false);
@@ -707,12 +717,17 @@ const RInChIView = () => {
707717
// Process RXN/RD file
708718
const processRxnFile = async () => {
709719
if (!rxnfileContent.trim()) {
710-
setError("Please enter or upload a RXN/RD file");
720+
const errorMsg = "Please enter or upload a RXN/RD file";
721+
setError(errorMsg);
722+
setLogMessage(errorMsg);
711723
return;
712724
}
713725

714726
if (!rinchiModuleLoaded) {
715-
setError("RInChI module not loaded. Please wait or refresh the page.");
727+
const errorMsg =
728+
"RInChI module not loaded. Please wait or refresh the page.";
729+
setError(errorMsg);
730+
setLogMessage(errorMsg);
716731
return;
717732
}
718733

@@ -731,7 +746,9 @@ const RInChIView = () => {
731746
!rxnfileContent.includes("$RXN") &&
732747
!rxnfileContent.includes("$RDFILE")
733748
) {
734-
setError("Invalid RXN/RD file format. Please check your input.");
749+
const errorMsg = "Invalid RXN/RD file format. Please check your input.";
750+
setError(errorMsg);
751+
setLogMessage(errorMsg);
735752
setIsLoading(false);
736753
return;
737754
}
@@ -754,6 +771,7 @@ const RInChIView = () => {
754771
}
755772
} catch (err) {
756773
console.error("Failed to process RXN/RD file:", err);
774+
setLogMessage(`Failed to process RXN/RD file: ${err.message}`);
757775
setError(`Failed to process RXN/RD file: ${err.message}`);
758776
} finally {
759777
setIsLoading(false);
@@ -882,6 +900,7 @@ const RInChIView = () => {
882900
}
883901
} catch (err) {
884902
console.error("Failed to load RInChI:", err);
903+
setLogMessage(`Failed to convert RInChI to reaction: ${err.message}`);
885904
setError(`Failed to convert RInChI to reaction: ${err.message}`);
886905
} finally {
887906
setIsLoading(false);
@@ -938,6 +957,9 @@ const RInChIView = () => {
938957
);
939958
} catch (err) {
940959
console.error("Failed to convert RInChI to file:", err);
960+
setLogMessage(
961+
`Failed to convert RInChI to ${outputFormat} file: ${err.message}`
962+
);
941963
setError(
942964
`Failed to convert RInChI to ${outputFormat} file: ${err.message}`
943965
);

ops/docker-compose-dev.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ services:
4646
- "traefik.http.routers.web.rule=Host(`dev.api.naturalproducts.net`)"
4747
- "traefik.http.routers.web.entrypoints=web"
4848
- "traefik.http.services.web.loadbalancer.server.port=80"
49+
healthcheck:
50+
test: ["CMD", "curl", "-f", "http://localhost:80/"]
51+
interval: 1m
52+
timeout: 10s
53+
retries: 5
54+
start_period: 30s
4955
depends_on:
5056
- api
5157
restart: unless-stopped
@@ -66,7 +72,6 @@ services:
6672
restart: unless-stopped
6773
networks:
6874
- cm_network_dev
69-
7075
grafana:
7176
image: grafana/grafana:latest
7277
container_name: grafana-dev

ops/docker-compose-prod.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ services:
5353
- "traefik.http.routers.web.rule=Host(`app.naturalproducts.net`) || Host(`api.naturalproducts.net`)" # Catches all other traffic
5454
- "traefik.http.routers.web.entrypoints=web"
5555
- "traefik.http.services.web.loadbalancer.server.port=80" # Internal port of the frontend container
56+
healthcheck:
57+
test: ["CMD", "curl", "-f", "http://localhost:80/"]
58+
interval: 1m
59+
timeout: 10s
60+
retries: 5
61+
start_period: 30s
5662
depends_on:
5763
- api
5864
restart: unless-stopped

0 commit comments

Comments
 (0)