mtzgroup / chemcloud-client

Python client for TeraChem Cloud
MIT License
11 stars 3 forks source link

Mix of 500 and 410 HTTP Errors w/ Geom Opt #52

Closed corinwagen closed 9 months ago

corinwagen commented 9 months ago

I'm trying to run the "basic working example" from here, but I'm not having very good luck. Here's my code (I get 500 with subprogram as both "terachem" and "psi4"):

from chemcloud import CCClient
from qcio import DualProgramInput, Molecule, OptimizationOutput

water = Molecule(
    symbols=["O", "H", "H"],
    geometry=[
        [0.0000, 0.00000, 0.0000],
        [0.2774, 0.89290, 0.2544],
        [0.6067, -0.23830, -0.7169],
    ],
)

client = CCClient()

prog_inp = DualProgramInput(
    molecule=water,
    calctype="optimization",
    keywords={"maxiter": 3},
    subprogram="terachem",
    subprogram_args={"model": {"method": "b3lyp", "basis": "6-31g"}},
)

# Submit calculation
future_result = client.compute("geometric", prog_inp)
output: OptimizationOutput = future_result.get()

if output.success:
    print("Optimization succeeded!")
    # Will be OptimizationResult object
    print(output)
    # The final molecule of the geometry optimization
    print(output.results.final_molecule)
    # Initial molecule
    print(output.input_data.molecule)
    # A list of ordered AtomicResult objects for each step in the optimization
    print(output.results.trajectory)
    # A list of ordered energies for each step in the optimization
    print(output.results.energies)
else:
    print("Optimization failed!")
    # Will be FailedOperation object
    print(output)
    # Error information
    print(output.traceback)

And here's what I get:

(kestrel) Trafalgar:terachem cwagen$ dotenv run python ex.py
Traceback (most recent call last):
  File "/Users/cwagen/business_code/terachem/ex.py", line 26, in <module>
    output: OptimizationOutput = future_result.get()
  File "/opt/miniconda3/envs/kestrel/lib/python3.10/site-packages/chemcloud/models.py", line 85, in get
    self.status
  File "/opt/miniconda3/envs/kestrel/lib/python3.10/site-packages/chemcloud/models.py", line 111, in status
    self._state, self.result = self._output()
  File "/opt/miniconda3/envs/kestrel/lib/python3.10/site-packages/chemcloud/models.py", line 97, in _output
    return self.client.output(self.task_id)
  File "/opt/miniconda3/envs/kestrel/lib/python3.10/site-packages/chemcloud/http_client.py", line 309, in output
    response = self._authenticated_request("get", f"/compute/output/{task_id}")
  File "/opt/miniconda3/envs/kestrel/lib/python3.10/site-packages/chemcloud/http_client.py", line 202, in _authenticated_request
    return self._request(
  File "/opt/miniconda3/envs/kestrel/lib/python3.10/site-packages/chemcloud/http_client.py", line 194, in _request
    response.raise_for_status()
  File "/opt/miniconda3/envs/kestrel/lib/python3.10/site-packages/httpx/_models.py", line 749, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Server error '500 Internal Server Error' for url 'https://chemcloud.mtzlab.com/api/v2/compute/output/f0470afc-d8c0-4229-9885-c98555939777'
For more information check: https://httpstatuses.com/500

Regular, non-geometry optimizations seem to work fine for me, FWIW. I've tried other scripts and I get 410 error there:

httpx.HTTPStatusError: Client error '410 Gone' for url 'https://chemcloud.mtzlab.com/api/v2/compute/output/e27c7e59-9fdb-4879-9460-384ad74edbd3'
For more information check: https://httpstatuses.com/410

(I'm using dotenv to handle ChemCloud auth)

coltonbh commented 9 months ago

Hi @corinwagen . Fixed with #53.

The issue was that the geometry in the example takes more than 3 iterations to converge, so the error was resulting. I updated the example script to use a geometry that optimizes faster and bumped maxiter from 3 -> 25. The underlying issue is in qcop where an exception from geometric is not properly caught and turned into a qcop exception class. I'll fix that later this week.

Curious if you're using these tools at Rowan? :)

coltonbh commented 9 months ago

Also, FYI the 500 is the server error because the exception is not properly handled, the 410 means that the result you are looking for no longer exists on the server, i.e., you have already retrieved it.

corinwagen commented 9 months ago

Ok, gotcha, makes sense. I was surprised that 3 iterations was going to be enough.... I'll figure out what I'm doing wrong w.r.t. 410

We're using our own engine right now, but I'm looking into it - Todd suggested that we try running TCC as a Rowan backend. I've been experimenting with writing code to interface chemcloud/qcop with our data format, stjames, but I got distracted (we had our private alpha kick off yesterday).

Happy to chat more in a different venue if you want - corin@rowansci.com

coltonbh commented 9 months ago

Will follow up via email!