From d9391ec1b74660c4cdf55658b63c418d18147522 Mon Sep 17 00:00:00 2001 From: MMensi <72437941+MMensi@users.noreply.github.com> Date: Thu, 30 May 2024 16:44:41 +0200 Subject: [PATCH 1/6] parameters updated --- .env | 4 ++-- xpsservice/settings.py | 12 ++++++++---- xpsservice/xps.py | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.env b/.env index 8f2b093..109778d 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ WORKERS=1 OMP_NUM_THREADS=1,1 -PORT=40129 -TIMEOUT=30 +PORT=8091 +TIMEOUT=500 diff --git a/xpsservice/settings.py b/xpsservice/settings.py index 92bb5de..85b7453 100644 --- a/xpsservice/settings.py +++ b/xpsservice/settings.py @@ -7,17 +7,17 @@ #Conformer generation method ALLOWED_FF = ("uff", "mmff94", "mmff94s") -MAX_ATOMS_FF = int(os.getenv("MAX_ATOMS_FF", 100)) +MAX_ATOMS_FF = int(os.getenv("MAX_ATOMS_FF", 200)) #XTB optimization method ALLOWED_METHODS = ("GFNFF", "GFN2xTB", "GFN1xTB") -MAX_ATOMS_XTB = int(os.getenv("MAX_ATOMS_XTB", 100)) -ALLOWED_FMAX = (0.000001, 0.1) +MAX_ATOMS_XTB = int(os.getenv("MAX_ATOMS_XTB", 200)) +ALLOWED_FMAX = (0.000001, 1) #timeout for the overall calculation -TIMEOUT = int(os.getenv("TIMEOUT", 100)) +TIMEOUT = int(os.getenv("TIMEOUT", 500)) # Define transition_map dictionary(list of orbitals for which a photoelectron emission is calculated) @@ -37,6 +37,10 @@ } } +# Derive allowed elements from transition_map +def derive_allowed_elements(transition_map: dict) -> Set[str]: + allowed_elements = {info["element"] for info in transition_map .values()} + return allowed_elements # Derive allowed elements from transition_map def derive_allowed_elements(transition_map: dict) -> Set[str]: diff --git a/xpsservice/xps.py b/xpsservice/xps.py index 38238c7..12e4d25 100644 --- a/xpsservice/xps.py +++ b/xpsservice/xps.py @@ -171,7 +171,7 @@ def run_xps_calculations(ase_mol: Atoms, transition_map) -> dict: @wrapt_timeout_decorator.timeout(TIMEOUT, use_signals=False) def calculate_from_molfile(molfile, method, fmax, transition_map) -> XPSResult: - smiles = molfile2smiles(molfile) + ase_mol, mol = molfile2ase(molfile, get_max_atoms(method)) opt_result = run_xtb_opt(ase_mol, fmax=fmax, method=method) From 6856a73b9d1bb5b1f7f5e22a894d89ee0d35bfb1 Mon Sep 17 00:00:00 2001 From: MMensi <72437941+MMensi@users.noreply.github.com> Date: Thu, 30 May 2024 16:59:05 +0200 Subject: [PATCH 2/6] nb atoms --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 34d423f..46907c7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,8 +9,8 @@ services: - CACHEDIR=/xpscache - WORKERS=${WORKERS} - OMP_NUM_THREADS=${OMP_NUM_THREADS} - - MAX_ATOMS_XTB=100 - - MAX_ATOMS_FF=100 + - MAX_ATOMS_XTB=200 + - MAX_ATOMS_FF=200 - TIMEOUT=${TIMEOUT} - LOG_LEVEL=DEBUG ports: From 6d51ebd962177a3fee0a0924920dbe7a8eb72699 Mon Sep 17 00:00:00 2001 From: MMensi <72437941+MMensi@users.noreply.github.com> Date: Thu, 30 May 2024 21:05:03 +0200 Subject: [PATCH 3/6] bash run fixed --- run_docker.sh | 2 +- xpsservice/xps.py | 304 --------------------------------------- xpsservice/xpsservice.py | 35 ----- 3 files changed, 1 insertion(+), 340 deletions(-) diff --git a/run_docker.sh b/run_docker.sh index aeb1a0b..e02e30c 100755 --- a/run_docker.sh +++ b/run_docker.sh @@ -1,4 +1,4 @@ #!/bin/bash echo "connect to http://localhost:8091" -docker run -d -p 8091:8091 -e PORT=8091 -e WORKERS=1 -e OMP_NUM_THREADS=1 -e TIMEOUT=200 --rm --name=xps-serviceinstance --security-opt=seccomp:unconfined xps-service \ No newline at end of file +docker run -d -p 8091:8091 -e PORT=8091 -e WORKERS=1 -e OMP_NUM_THREADS=1 -e TIMEOUT=500 --rm --name=xps-serviceinstance --security-opt=seccomp:unconfined xps-service \ No newline at end of file diff --git a/xpsservice/xps.py b/xpsservice/xps.py index 12e4d25..8a71164 100644 --- a/xpsservice/xps.py +++ b/xpsservice/xps.py @@ -218,307 +218,3 @@ def reorder_predictions(be_predictions: dict, ase_mol: Atoms, transition_map: di return ordered_predictions - -'''Hs missing in the output -def reorder_predictions(be_predictions: dict, ase_mol: Atoms, transition_map: dict) -> List[Prediction]: - ordered_predictions = [] - - atom_index_map = {i: atom for i, atom in enumerate(ase_mol)} - - for transition_key, predictions in be_predictions.items(): - transition_info = transition_map[transition_key] - element = transition_info['element'] - - element_indices = [i for i, atom in enumerate(ase_mol) if atom.symbol == element] - - for idx, prediction in zip(element_indices, predictions): - atom = atom_index_map[idx] - position = dict(x=atom.position[0], y=atom.position[1], z=atom.position[2]) - binding_energy, standard_deviation = prediction - - prediction_data = {transition_key: PredictionData( - bindingEnergy=binding_energy, - standardDeviation=standard_deviation - )} - - ordered_predictions.append(Prediction(atom=atom.symbol, position=position, prediction=prediction_data)) - - return ordered_predictions -''' - - - - - - - - - - - -''' -DEPRECIATED CODE: HOWEVER THOUROUGLY CHECK NEW ONE ABOVE BEFORE PROD -import os - -from functools import lru_cache -from typing import List, Tuple, Union - -import numpy as np -import wrapt_timeout_decorator -import logging -import pickle -import hashlib - -from ase import Atoms -from ase.build.tools import sort -from quippy.descriptors import Descriptor - -from .cache import soap_config_cache, model_cache -from .models import * -from .optimize import run_xtb_opt -from .settings import MAX_ATOMS_XTB, MAX_ATOMS_FF, TIMEOUT -from .utils import ( - cache_hash, - molfile2ase, - molfile2smiles, - compare_atom_order -) - - - -def load_ml_model(transition_info): - try: - model_filepath = transition_info['model_filepath'] - with open(model_filepath, 'rb') as model_file: - model = pickle.load(model_file) - logging.debug(f"Loaded ML model for {transition_info['element']} {transition_info['orbital']}") - return model - except FileNotFoundError: - raise FileNotFoundError(f"Model file not found at {model_filepath}.") - except pickle.UnpicklingError as e: - raise RuntimeError(f"Failed to load model file {model_filepath}: {str(e)}") - - -def load_soap_config(transition_info): - try: - soap_config_filepath = transition_info['soap_config_filepath'] - with open(soap_config_filepath, 'rb') as soap_config_file: - soap_config = pickle.load(soap_config_file) - logging.debug(f"Loaded ML model for {transition_info['element']} {transition_info['orbital']}") - return soap_config - except FileNotFoundError: - raise FileNotFoundError(f"SOAP descriptor not found at {soap_config_filepath}.") - except pickle.UnpicklingError as e: - raise RuntimeError(f"Failed to load model file {soap_config_filepath}: {str(e)}") - - -def load_soap_configs_and_models(transition_map): - #clear old cache - soap_config_cache.clear() - model_cache.clear() - - for transition_key, transition_info in transition_map.items(): - try: - - # Load SOAP config and store in cache - soap_config = load_soap_config(transition_info) - soap_config_hashed_key = cache_hash(transition_key, "soap_config_cache") - print(soap_config_hashed_key) - soap_config_cache.set(soap_config_hashed_key, soap_config) - logging.debug(f"SOAP config for {transition_key} loaded") - - # Load ML model and store in cache - ml_model = load_ml_model(transition_info) - ml_model_hashed_key = cache_hash(transition_key, "ml_model_cache") - model_cache.set(ml_model_hashed_key, ml_model) - logging.debug(f"ML model for {transition_key} loaded") - - except Exception as e: - logging.error(f"Error loading data for transition {transition_key}: {str(e)}") - continue # Optionally skip to the next iteration on error - - -def check_cache_status(transition_map) -> Dict[str, Dict[str, bool]]: - cache_status = {} - - # Iterate through each transition in the transition_map - for transition_key in transition_map: - # Check the status of each cache for the transition key - soap_config_loaded = cache_hash(transition_key, "soap_config_cache") in soap_config_cache - model_loaded = cache_hash(transition_key, "ml_model_cache") in model_cache - - # Store the status in the cache_status dictionary - cache_status[transition_key] = { - "soap_config_loaded": soap_config_loaded, - "model_loaded": model_loaded, - } - - return cache_status - - -def has_any_cache_failure(cache_status: Dict[str, Dict[str, bool]]) -> bool: - # Iterate through each transition and check each status - for transition_key, status_dict in cache_status.items(): - for status_name, status_value in status_dict.items(): - if not status_value: - # If any status is False, return True - return True - - # If all statuses are True, return False - return False - - -def get_max_atoms(method): - if method == "GFNFF": - return MAX_ATOMS_FF - elif method == "GFN2xTB": - return MAX_ATOMS_XTB - elif method == "GFN1xTB": - return MAX_ATOMS_XTB - - -def calculate_binding_energies(ase_mol: Atoms, transition_key): - print("Entered calculate_binding_energies") - if not isinstance(ase_mol, Atoms): - raise TypeError(f"in calculate_binding_energies expected ase_mol to be of type Atoms, but got {type(ase_mol).__name__}") - - transition_info = transition_map[transition_key] - element = transition_info['element'] - orbital = transition_info['orbital'] - - if transition_key not in transition_map: - raise KeyError(f"Transition '{transition_key}' is not a valid transition. Valid transitions are: {list(transition_map.keys())}") - - soap_config_hashed_key = cache_hash(transition_key, "soap_config_cache") - soap_config = soap_config_cache.get(soap_config_hashed_key) - if soap_config is None: - logging.error(f"SOAP config not found in cache for transition {transition_key}") - return [] - - soap_descriptor = Descriptor(soap_config) - if soap_descriptor is None: - logging.error(f"SOAP descriptor could not be built from SOAP config for transition {transition_key}") - return [] - - model_hashed_key = cache_hash(transition_key, "ml_model_cache") - ml_model = model_cache.get(model_hashed_key) - if ml_model is None: - logging.error(f"ML model not found in cache for transition {transition_key}") - return [] - - desc_data = soap_descriptor.calc(ase_mol) - if 'data' not in desc_data: - logging.error(f"No descriptor data found for molecule with transition {transition_key}") - return [] - - desc_molecule = desc_data['data'] - - try: - be, std = ml_model.predict(desc_molecule, return_std=True) - print(f'Predicted binding energies: {be}') - print(f'Predicted standard deviations: {std}') - logging.info(f'Predicted {len(be)} binding energies for element {element}, orbital {orbital}, defined in {transition_key}') - except Exception as e: - logging.error(f"Error during prediction: {e}") - return [] - - if not hasattr(be, '__iter__') or not hasattr(std, '__iter__'): - logging.error(f"Expected iterable outputs from predict method, got {type(be)} and {type(std)}") - return [] - - return list(zip(be, std)) - - - - - -def run_xps_calculations(ase_mol: Atoms, transition_map) -> dict: - #Check the type of the input molecule - if not isinstance(ase_mol, Atoms): - raise TypeError(f"in run_xps_calculation, expected ase_mol to be of type Atoms, but got {type(ase_mol).__name__}") - - # Dictionary to store predictions by element and transition - be_predictions = {} - - # Iterate through the keys (transitions) in transition_map - for transition_key in transition_map.keys(): - # Retrieve the element and orbital from the transition info - transition_info = transition_map[transition_key] - element = transition_info['element'] - - # Check if the element is present in the ASE molecule - if element in ase_mol.symbols: - # Calculate binding energies for the element and transition - predictions = calculate_binding_energies(ase_mol, transition_key) - - # Store the predictions in the dictionary using the transition_key as the key - be_predictions[transition_key] = predictions - else: - logging.warning(f"No model found for element {element} in transition {transition_key}") - - return be_predictions - -@wrapt_timeout_decorator.timeout(TIMEOUT, use_signals=False) -def calculate_from_molfile(molfile, method, fmax, transition_map) -> XPSResult: - - # Convert molfile to smiles and ASE molecule - smiles = molfile2smiles(molfile) - ase_mol, mol = molfile2ase(molfile, get_max_atoms(method)) - - # Optimize the geometry of the ASE molecule using xTB - opt_result = run_xtb_opt(ase_mol, fmax=fmax, method=method) - opt_ase_mol = opt_result.atoms - if not isinstance(opt_ase_mol, Atoms): - raise TypeError(f"After xtb optimization, expected ase_mol to be of type Atoms, but got {type(ase_mol).__name__}") - - # Run XPS calculations - be_predictions = run_xps_calculations(opt_ase_mol, transition_map) - - # Reorder predictions if available - if isinstance(be_predictions, dict): - ordered_predictions = reorder_predictions(be_predictions, ase_mol, transition_map) - else: - logging.error(f"Unexpected format for be_predictions: {be_predictions}") - ordered_predictions = [] - - return ordered_predictions - - -def reorder_predictions(be_predictions: dict, ase_mol: Atoms, transition_map: dict) -> List[Prediction]: - ordered_predictions = [] - - # Iterate over atoms in the ASE molecule - for atom in ase_mol: - atom_symbol = atom.symbol - position = dict(x=atom.position[0], y=atom.position[1], z=atom.position[2]) - prediction_data = {} - - # Check if predictions are available for the current atom - for transition_key, predictions in be_predictions.items(): - print(f"Processing transition {transition_key} for atom {atom_symbol}") - # Retrieve the element from transition_map using the transition_key - element = transition_map.get(transition_key, {}).get("element") - - if element == atom_symbol: - print("Element matches atom symbol") - # Create Prediction_data objects for each prediction - for prediction in predictions: - print(f"Processing prediction: {prediction}") - # Check if prediction is in the expected format - if isinstance(prediction, tuple) and len(prediction) == 2: - binding_energy, standard_deviation = prediction - prediction_data[transition_key] = PredictionData( - bindingEnergy=binding_energy, - standardDeviation=standard_deviation - ) - else: - # Log warning if prediction format is unexpected - logging.warning(f"Unexpected format for prediction: {prediction}") - break # No need to check other transitions if a match is found - - # Create Prediction object for the atom - ordered_predictions.append(Prediction(atom=atom_symbol, position=position, prediction=prediction_data)) - - return ordered_predictions - -''' \ No newline at end of file diff --git a/xpsservice/xpsservice.py b/xpsservice/xpsservice.py index 82ddb6e..a930b27 100644 --- a/xpsservice/xpsservice.py +++ b/xpsservice/xpsservice.py @@ -137,41 +137,6 @@ def predict_binding_energies_endpoint(request: XPSRequest): # Return the result return xps_result -'''# Predicts the binding energies -@app.post("/predict_binding_energies", response_model=XPSResult) -def predict_binding_energies_endpoint(request: XPSRequest): - - # Get the cache status from the function and optionnaly relaod - cache_status = check_cache_status(selected_transition_map) - if has_any_cache_failure(cache_status) == True: - load_soap_configs_and_models(selected_transition_map) - - # Extract the input data - smiles = request.smiles - molfile = request.molFile - method = request.method - fmax = request.fmax - - # Perform conversions to molfile based on the provided input - if smiles and not molfile: - logging.debug("if smiles") - # Convert SMILES to molFile using your function - molfile = smiles2molfile(smiles) - logging.debug("smiles conversion") - elif molfile and not smiles: - # Convert molFile to SMILES using your function - smiles = molfile2smiles(molfile) - else: - raise HTTPException(status_code=400, detail="Either SMILES or molFile must be provided.") - print("converted format") - # Perform calculations - try: - result = calculate_from_molfile(molfile, method, fmax, selected_transition_map) - except Exception as e: - raise HTTPException(status_code=400, detail=str(e)) - - # Return the result - return result''' #checks version @app.get("/app_version") From fb8839eb143fa1211ea4a6c8c481c8c512c99cd8 Mon Sep 17 00:00:00 2001 From: MMensi <72437941+MMensi@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:41:04 +0200 Subject: [PATCH 4/6] Added solid phase correction --- xpsservice/models.py | 14 +++++++++-- xpsservice/settings.py | 10 +++++--- xpsservice/xps.py | 53 +++++++++++++++++++++++++++++++++++++++- xpsservice/xpsservice.py | 10 ++------ 4 files changed, 73 insertions(+), 14 deletions(-) diff --git a/xpsservice/models.py b/xpsservice/models.py index bbfd6d3..188e45a 100644 --- a/xpsservice/models.py +++ b/xpsservice/models.py @@ -6,7 +6,7 @@ from ase import Atoms from pydantic import BaseModel, Field, validator from rdkit import Chem -from .settings import ALLOWED_FMAX, ALLOWED_ELEMENTS, ALLOWED_FF, ALLOWED_METHODS, transition_map +from .settings import ALLOWED_FMAX, ALLOWED_ELEMENTS, ALLOWED_FF, ALLOWED_METHODS, ALLOWED_ENERGY_REFERENCE, transition_map class TransitionValidator(BaseModel): @@ -33,9 +33,13 @@ class XPSRequest(BaseModel): description="Method for geometry optimization and XPS binding energies calculation. Allowed values: `GFNFF`, `GFN2xTB`, `GFN1xTB`.", ) fmax: Optional[float] = Field( - 0.01, + 0.001, description="Maximum force admissible during geometry optimization. Typically ranging from 0.1 to 0.0001." ) + energyReference: Optional[str] = Field( + "solid", + description="Energy referencing performed through polynomial regression, for gaz phase, solid state or none (raw data)" + ) @validator("smiles") def validate_smiles(cls, v): @@ -70,6 +74,12 @@ def validate_fmax(cls, v): if not (ALLOWED_FMAX[0] <= v <= ALLOWED_FMAX[1]): raise ValueError(f"fmax must be within the range {ALLOWED_FMAX}") return v + + @validator("energyReference") + def validate_energy_reference(cls, v): + if v not in ALLOWED_ENERGY_REFERENCE: + raise ValueError(f"Method must be in {ALLOWED_ENERGY_REFERENCE}") + return v class Position(BaseModel): diff --git a/xpsservice/settings.py b/xpsservice/settings.py index 85b7453..bd4e44b 100644 --- a/xpsservice/settings.py +++ b/xpsservice/settings.py @@ -13,7 +13,8 @@ #XTB optimization method ALLOWED_METHODS = ("GFNFF", "GFN2xTB", "GFN1xTB") MAX_ATOMS_XTB = int(os.getenv("MAX_ATOMS_XTB", 200)) -ALLOWED_FMAX = (0.000001, 1) +ALLOWED_FMAX = (0.000001, 0.1) +ALLOWED_ENERGY_REFERENCE = ("none", "solid") #timeout for the overall calculation @@ -22,18 +23,21 @@ # Define transition_map dictionary(list of orbitals for which a photoelectron emission is calculated) # Several maps possible. Adjust which one to load in xpsservice +# The regression coefficient are for polynomial a + bx + cx^2 + ..., given in an array [a,b,c,...] transition_map = { "C1s": { "element": "C", "orbital": "1s", "soap_config_filepath": os.path.abspath("SOAP_configs/soap_config_C1s.pkl"), - "model_filepath": os.path.abspath("ML_models/XPS_GPR_C1s_xtb.pkl") + "model_filepath": os.path.abspath("ML_models/XPS_GPR_C1s_xtb.pkl"), + "regression_coefficients": [-2501.002792622873, 18.12807741, -0.02938832] }, "O1s": { "element": "O", "orbital": "1s", "soap_config_filepath": os.path.abspath("SOAP_configs/soap_config_O1s.pkl"), - "model_filepath": os.path.abspath("ML_models/XPS_GPR_O1s_xtb.pkl") + "model_filepath": os.path.abspath("ML_models/XPS_GPR_O1s_xtb.pkl"), + "regression_coefficients": [-14914.578039681715, 5.67166123e+01, -5.20506217e-02] } } diff --git a/xpsservice/xps.py b/xpsservice/xps.py index 8a71164..d0c9845 100644 --- a/xpsservice/xps.py +++ b/xpsservice/xps.py @@ -7,6 +7,7 @@ import logging import pickle import hashlib +from fastapi.logger import logger from ase import Atoms from ase.build.tools import sort from quippy.descriptors import Descriptor @@ -170,7 +171,7 @@ def run_xps_calculations(ase_mol: Atoms, transition_map) -> dict: return be_predictions @wrapt_timeout_decorator.timeout(TIMEOUT, use_signals=False) -def calculate_from_molfile(molfile, method, fmax, transition_map) -> XPSResult: +def calculate_from_molfile(molfile, method, fmax, energy_reference, transition_map) -> XPSResult: ase_mol, mol = molfile2ase(molfile, get_max_atoms(method)) @@ -181,6 +182,11 @@ def calculate_from_molfile(molfile, method, fmax, transition_map) -> XPSResult: be_predictions = run_xps_calculations(opt_ase_mol, transition_map) + #reference the binding enregy if queried + if energy_reference == 'solid': + referenced_be_predictions = reference_be_predictions(be_predictions, transition_map) + be_predictions = referenced_be_predictions + if isinstance(be_predictions, dict): ordered_predictions = reorder_predictions(be_predictions, opt_ase_mol, transition_map) else: @@ -218,3 +224,48 @@ def reorder_predictions(be_predictions: dict, ase_mol: Atoms, transition_map: di return ordered_predictions +# Energy referencing of the whole predictions +def reference_be_predictions(be_predictions: dict, transition_map: dict): + + referenced_be_predictions = {} + + for transition_key, predictions in be_predictions.items(): + # get regression coeffs + transition_info = transition_map[transition_key] + regression_coefficients = transition_info['regression_coefficients'] + + referenced_predictions = [] + for prediction in predictions: + referenced_predictions.append(reference_be_prediction(prediction, regression_coefficients)) + + referenced_be_predictions[transition_key] = referenced_predictions + + return referenced_be_predictions + +''' +# Energy referencing of a single prediction based on polynomial fitting of experimental data +def reference_be_prediction(be_prediction: float, regression_coefficients: list): + + referenced_be_prediction = be_prediction + for i, coeff in enumerate(regression_coefficients): + logger.debug(f"be_prediction format {be_prediction}") + referenced_be_prediction[0] += coeff * (be_prediction[0] ** i) + + return referenced_be_prediction +''' + +# Energy referencing of a single prediction based on polynomial fitting of experimental data +def reference_be_prediction(be_prediction: tuple, regression_coefficients: list): + # Unpack the tuple + prediction, std_dev = be_prediction + + # Initialize the referenced prediction with the original prediction value + referenced_prediction = 0.0 + + # Apply the polynomial correction + for i, coeff in enumerate(regression_coefficients): + referenced_prediction += coeff * (prediction ** i) + + # Return the modified tuple with the referenced prediction and original standard deviation + return (referenced_prediction, std_dev) + diff --git a/xpsservice/xpsservice.py b/xpsservice/xpsservice.py index a930b27..610b84f 100644 --- a/xpsservice/xpsservice.py +++ b/xpsservice/xpsservice.py @@ -44,7 +44,6 @@ #Initial loading #load_soap_configs_and_models(selected_transition_map) - app = FastAPI( title="EPFL-ISIC-XRDSAP: XPS webservice", description="Offers XPS binding energy prediction tool, based on simulation, and a Gaussian process ML model. Allowed elements/orbitals to be predicted are `C1s` and `O1s`. Hydrogens are taken into account but not predicted. Allowed methods for molecular geometry optimization are `GFNFF`, `GFN2xTB`, `GFN1xTB`", @@ -54,12 +53,6 @@ ) -#ping -@app.get("/ping") -def ping(): - return {"message": "pongping"} - - #load models and descriptors @app.get("/load_soap_configs_and_models") async def load_soap_configs_and_models_endpoint() -> bool: @@ -104,6 +97,7 @@ def predict_binding_energies_endpoint(request: XPSRequest): molfile = request.molFile method = request.method fmax = request.fmax + energy_reference = request.energyReference # Perform conversions to molfile based on the provided input if smiles and not molfile: @@ -119,7 +113,7 @@ def predict_binding_energies_endpoint(request: XPSRequest): print("converted format") # Perform calculations try: - predictions = calculate_from_molfile(molfile, method, fmax, selected_transition_map) + predictions = calculate_from_molfile(molfile, method, fmax, energy_reference, selected_transition_map) except Exception as e: raise HTTPException(status_code=400, detail=str(e)) From 4940c99a56fab2ac178931fd571c08608acc99b6 Mon Sep 17 00:00:00 2001 From: MMensi <72437941+MMensi@users.noreply.github.com> Date: Tue, 11 Jun 2024 16:08:34 +0200 Subject: [PATCH 5/6] chore: change port number --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 109778d..36ac7aa 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ WORKERS=1 OMP_NUM_THREADS=1,1 -PORT=8091 +PORT=40129 TIMEOUT=500 From 278883404fa3e73afbe82f8876d81b09138548f2 Mon Sep 17 00:00:00 2001 From: MMensi <72437941+MMensi@users.noreply.github.com> Date: Tue, 11 Jun 2024 16:10:03 +0200 Subject: [PATCH 6/6] chore: changed timeout --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 36ac7aa..8f2b093 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ WORKERS=1 OMP_NUM_THREADS=1,1 PORT=40129 -TIMEOUT=500 +TIMEOUT=30