Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,35 @@ jobs:
steps:
# Clone repository code to runner
- name: Check out the repo
uses: actions/checkout@v4
uses: actions/checkout@v7

# Enable multi-architecture builds via QEMU emulation
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v4

# Enable advanced Docker build features (required for caching)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4

# Authenticate with Docker Hub for image push access
- name: Log in to Docker Hub
uses: docker/login-action@v3
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Detect changes in nmr-cli folder to skip unnecessary builds
- name: Check for file changes
id: changes
uses: dorny/paths-filter@v3
uses: dorny/paths-filter@v4
with:
filters: |
nmr-cli:
- 'app/scripts/nmr-cli/**'

# Build main nmrKit image with registry caching for faster builds
- name: Build and push nmrKit Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
Expand All @@ -77,7 +77,7 @@ jobs:
# Build nmr-cli image only if files in app/scripts/nmr-cli/ changed
- name: Build and push nmr-cli Docker image
if: steps.changes.outputs.nmr-cli == 'true'
uses: docker/build-push-action@v6
uses: docker/build-push-action@v7
with:
context: ./app/scripts/nmr-cli/
file: ./app/scripts/nmr-cli/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doc-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
fetch-depth: 0 # Not needed if lastUpdated is not enabled
# - uses: pnpm/action-setup@v2 # Uncomment this if you're using pnpm
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,27 @@ jobs:
steps:
# Clone repository code to runner
- name: Check out the repo
uses: actions/checkout@v4
uses: actions/checkout@v7

# Enable multi-architecture builds via QEMU emulation
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v4

# Enable advanced Docker build features (required for caching)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4

# Authenticate with Docker Hub for image push access
- name: Log in to Docker Hub
uses: docker/login-action@v3
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Detect changes in nmr-cli folder to skip unnecessary builds
- name: Check for file changes
id: changes
uses: dorny/paths-filter@v3
uses: dorny/paths-filter@v4
with:
filters: |
nmr-cli:
Expand All @@ -107,7 +107,7 @@ jobs:

# Build main nmrKit image with registry caching for faster builds
- name: Build and push nmrKit Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
Expand All @@ -123,7 +123,7 @@ jobs:
# Build nmr-cli image only if files in app/scripts/nmr-cli/ changed
- name: Build and push nmr-cli Docker image
if: steps.changes.outputs.nmr-cli == 'true'
uses: docker/build-push-action@v6
uses: docker/build-push-action@v7
with:
context: ./app/scripts/nmr-cli/
file: ./app/scripts/nmr-cli/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
Expand Down
18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM continuumio/miniconda3:24.1.2-0 AS nmrkit-ms
FROM continuumio/miniconda3:25.3.1-1 AS nmrkit-ms
ARG TARGETARCH=amd64

ENV PYTHON_VERSION=3.10
Expand All @@ -24,8 +24,13 @@ RUN apt-get update && \

RUN apt-get update && apt-get -y install docker.io

RUN conda install -c conda-forge python>=PYTHON_VERSION
RUN conda install -c conda-forge openbabel>=OPENBABEL_VERSION
RUN conda config --remove-key channels && \
conda config --add channels conda-forge && \
conda config --set channel_priority strict

RUN conda install -y \
"python=${PYTHON_VERSION}" \
"openbabel>=${OPENBABEL_VERSION}"

RUN pip3 install rdkit

Expand All @@ -51,8 +56,11 @@ RUN python3 -m pip install uvicorn[standard]

COPY ./app /code/app

RUN curl -sL https://deb.nodesource.com/setup_current.x | bash -
RUN apt-get install -y nodejs
# Download the setup script first so a failure fails the build instead of being masked by the pipe
RUN curl -fsSL https://deb.nodesource.com/setup_24.x -o /tmp/nodesource_setup.sh && \
bash /tmp/nodesource_setup.sh && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/* /tmp/nodesource_setup.sh
RUN npm install -g npm@latest

RUN npm install -g /code/app/scripts/nmr-cli
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<p align="center"><a href="#" target="_blank"><img src="/public/img/logo.svg" width="400" alt="NMRKit Logo"></a></p>
<p align="center"><a href="#" target="_blank"><img src="/public/img/logo.svg" width="400" alt="NMRKit Logo"></a></p>

[![License](https://img.shields.io/badge/License-MIT%202.0-blue.svg)](https://opensource.org/licenses/MIT)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-blue.svg)](https://github.com/NFDI4Chem/nmrkit/graphs/commit-activity)
[![GitHub issues](https://img.shields.io/github/issues/NFDI4Chem/nmrkit.svg)](https://github.com/NFDI4Chem/nmrkit/issues)
[![GitHub contributors](https://img.shields.io/github/contributors/NFDI4Chem/nmrkit.svg)]([https://GitHub.com/Steinbeck-Lab/cheminformatics-python-microservice/graphs/contributors/](https://github.com/NFDI4Chem/nmrkit/graphs/contributors))
[![GitHub contributors](https://img.shields.io/github/contributors/NFDI4Chem/nmrkit.svg)](<[https://GitHub.com/Steinbeck-Lab/cheminformatics-python-microservice/graphs/contributors/](https://github.com/NFDI4Chem/nmrkit/graphs/contributors)>)
[![Powered by CDK](https://img.shields.io/badge/Powered%20by-CDK-blue.svg?style=flat&logo=chem)](https://cdk.github.io)
[![RDKit badge](https://img.shields.io/badge/Powered%20by-RDKit-3838ff.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAFVBMVEXc3NwUFP8UPP9kZP+MjP+0tP////9ZXZotAAAAAXRSTlMAQObYZgAAAAFiS0dEBmFmuH0AAAAHdElNRQfmAwsPGi+MyC9RAAAAQElEQVQI12NgQABGQUEBMENISUkRLKBsbGwEEhIyBgJFsICLC0iIUdnExcUZwnANQWfApKCK4doRBsKtQFgKAQC5Ww1JEHSEkAAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wMy0xMVQxNToyNjo0NyswMDowMDzr2J4AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDMtMTFUMTU6MjY6NDcrMDA6MDBNtmAiAAAAAElFTkSuQmCC)](https://www.rdkit.org/)
![Workflow](https://github.com/NFDI4Chem/nmrkit/actions/workflows/dev-build.yml/badge.svg)
Expand All @@ -12,7 +12,6 @@
[![framework](https://img.shields.io/badge/Framework-FastAPI-blue?style)](https://fastapi.tiangolo.com/)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8112749.svg)](https://doi.org/10.5281/zenodo.8211374)


# Welcome to NMRKit 🚀

NMRKit features a collection of powerful microservices designed to simplify your NMR data processing and analysis. Whether you're a seasoned researcher or a curious chemist, our suite of tools offers NMR Prediction, Validation, and Depiction via the nmrium library, along with seamless Format Conversion using the nmr-load-save package. With our robust API, functionalities, and developer-friendly documentation, exploring and interpreting NMR spectra has never been easier.
Expand All @@ -27,7 +26,7 @@ Key Features:
API Reference (Scalar) - https://dev.nmrkit.nmrxiv.org/latest/docs
📢 Found a bug or have a feature request? We'd love to hear from you! Please open an issue: [https://github.com/NFDI4Chem/nmrkit/issues]

Happy NMR exploring! 🧪🌟"
Happy NMR exploring..! 🧪🌟"

## Help Desk

Expand All @@ -46,9 +45,9 @@ Licensed under the [MIT license](https://opensource.org/licenses/MIT).
Venkata, C., Sharma, N. , Stefan Kuhn, Hamed Musallam nmrKit [Computer software]. https://doi.org/10.5281/zenodo.8211374

## Maintained by
NMRKit is developed and maintained by the [NFDI4Chem partners](https://www.nfdi4chem.de/) at the [Friedrich Schiller University](https://www.uni-jena.de/en/) Jena, Germany.
The code for this web application is released under the [MIT license](https://opensource.org/licenses/MIT).

NMRKit is developed and maintained by the [NFDI4Chem partners](https://www.nfdi4chem.de/) at the [Friedrich Schiller University](https://www.uni-jena.de/en/) Jena, Germany.
The code for this web application is released under the [MIT license](https://opensource.org/licenses/MIT).

<p align="left"><a href="https://nfdi4chem.de/" target="_blank"><img src="https://www.nfdi4chem.de/wp-content/themes/wptheme/assets/img/logo.svg" width="30%" alt="NFDI4Chem Logo"></a></p>
<p align="left"><a href="https://cheminf.uni-jena.de/" target="_blank"><img src="/public/img/fsu-jena.jpg" width="30%" alt="NFDI4Chem Logo"></a></p>
Expand Down
28 changes: 26 additions & 2 deletions app/routers/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io
from app.schemas import HealthCheck
from pydantic import BaseModel, HttpUrl, Field
from typing import Optional
from typing import Optional, List
import subprocess
import tempfile
import os
Expand Down Expand Up @@ -50,6 +50,10 @@ class UrlParseRequest(BaseModel):
)
raw_data: bool = Field(
False, description="Include raw data in the output (default: data source)")
include: Optional[List[str]] = Field(
None, description="Only include files matching pattern(s) (glob/regex string)")
exclude: Optional[List[str]] = Field(
None, description="Exclude files matching pattern(s) (glob/regex string)")

model_config = {
"json_schema_extra": {
Expand Down Expand Up @@ -95,6 +99,8 @@ def run_command(
auto_processing: bool = False,
auto_detection: bool = False,
raw_data: bool = False,
include: Optional[List[str]] = None,
exclude: Optional[List[str]] = None,
) -> StreamingResponse:
"""Execute nmr-cli parse-spectra command in Docker container."""

Expand All @@ -113,6 +119,12 @@ def run_command(
cmd.append("-d")
if raw_data:
cmd.append("-r")
if include:
cmd.append("--include")
cmd.extend(include)
if exclude:
cmd.append("--exclude")
cmd.extend(exclude)

try:
result = subprocess.run(
Expand Down Expand Up @@ -362,7 +374,11 @@ async def parse_spectra_from_file(
description="Enable ranges and zones automatic detection",
),
raw_data: bool = Form(
False, description="Include raw data in the output (default: data source references)")
False, description="Include raw data in the output (default: data source references)"),
include: Optional[List[str]] = Form(
None, description="Only include files matching pattern(s) (glob/regex string)"),
exclude: Optional[List[str]] = Form(
None, description="Exclude files matching pattern(s) (glob/regex string)"),
):
"""
## Parse spectra from an uploaded file
Expand All @@ -376,6 +392,8 @@ async def parse_spectra_from_file(
| `auto_processing` | Automatically process FID → FT spectra |
| `auto_detection` | Automatically detect ranges and zones |
| `raw_data` | Include raw data in the output (default: data source) |
| `include` | Only include files matching pattern(s) |
| `exclude` | Exclude files matching pattern(s) |
### Returns
Parsed spectra data in NMRium-compatible JSON format.
"""
Expand Down Expand Up @@ -405,6 +423,8 @@ async def parse_spectra_from_file(
auto_processing=auto_processing,
auto_detection=auto_detection,
raw_data=raw_data,
include=include,
exclude=exclude,
)

except HTTPException:
Expand Down Expand Up @@ -452,6 +472,8 @@ async def parse_spectra_from_url(request: UrlParseRequest):
| `auto_processing` | Automatically process FID → FT spectra |
| `auto_detection` | Automatically detect ranges and zones |
| `raw_data` | Include raw data in the output (default: data source) |
| `include` | Only include files matching pattern(s) |
| `exclude` | Exclude files matching pattern(s) |

### Returns
Parsed spectra data in NMRium-compatible JSON format.
Expand All @@ -463,6 +485,8 @@ async def parse_spectra_from_url(request: UrlParseRequest):
auto_processing=request.auto_processing,
auto_detection=request.auto_detection,
raw_data=request.raw_data,
include=request.include,
exclude=request.exclude,
)

except HTTPException:
Expand Down
16 changes: 12 additions & 4 deletions app/scripts/nmr-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# build the image ` docker build --tag nmr-cli . `
# run the container ` docker run -it nmr-cli bash `

FROM mcr.microsoft.com/playwright:v1.58.2-noble
# NOTE: if `docker run` prints
# "Error while loading conda entry point: conda-libmamba-solver (module 'libmambapy' has no attribute 'QueryFormat')"
# this is unrelated to this image/container — it comes from a version mismatch between
# conda-libmamba-solver and libmambapy in your HOST shell's conda (base) environment.
# It does not affect the container. To fix it on the host, run:
# conda update -n base -c conda-forge conda conda-libmamba-solver libmambapy
# or, if that doesn't resolve it:
# conda install -n base -c conda-forge --force-reinstall conda-libmamba-solver libmambapy
# or, to bypass libmamba entirely:
# conda config --set solver classic

FROM mcr.microsoft.com/playwright:v1.62.1-noble

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Downgrade to Node 22
RUN npm install -g n && n 22 && hash -r

WORKDIR /app

#ENV BASE_NMRIUM_URL=https://nmrium.nmrxiv.org/
Expand Down
Loading
Loading