Trouble with some WebMOREST methods

Post Reply
christinem2005
Posts: 3
Joined: Fri Sep 06, 2024 4:08 pm
Full Name: Christine Morales
Organization: University of Mount Union
Subdiscipline: Chemistry

Trouble with some WebMOREST methods

Post by christinem2005 »

I am trying to use the new REST framework in WebMO, which should allow WebMO to run a calculation in response to requests from a Jupyter notebook. I have followed templates from the website (https://www.webmo.net/link/help/PythonInterface.html) as well as from a poster presented by a student from Hope College, Caleb Brzezenski at the MU3C virtual winter meeting in early February 2025. I should mention that the server (MU3C cluster at Hope College) is running WebMO v.23 and the latest version of Apache. Is it possible that the WebMO version or Apache configuration might matter on the server side? Or is this something I could resolve solely on the client side?

I have tried to run most of the methods available for WebMOREST, and while most are working, the following methods still are not working for me:
  • 404 Client Error: Not Found was returned for the following methods: get_engines(), get_templates()
    403 Client Error: Forbidden was returned for the following methods: get_job_archive(), get_job_spreadsheet()
    Timeout waiting for response from Javascript: was returned for: async display_job_property()
    422 Client Error: Unprocessable Entity was returned for: submit_job()
    I did not try: generate_input(), wait_for_job(),wait_for_jobs()
I have included below a minimal example of code cells for a Jupyter notebook that fails for me in code cell 4. (I've replaced the URL and username in code cell 2, and the job number in code cell 3, with generic words in all-caps.) Code cell 3 works for me, so I'm certain that a REST session has been established and authenticated, but code cell 4 does not work for me.

Code: Select all

import webmo 
import webmo.util
from pprint import pprint
from webmo import WebMOREST
from requests import HTTPError
import json
import io

Code: Select all

URL = "https://SERVER/~webmo/cgi-bin/webmo/rest.cgi"
username = "USER"

Code: Select all

job = JOB

try:
    #obtain a REST session
    rest=webmo.WebMOREST(URL,username)
    #obtain results from the specified job number
    results = rest.get_job_results(job)
    pprint(results["comment"])

#Catch any HTTP / REST exceptions and log the underlying cause
except HTTPError as e:
    print("Error during REST request: %s" % e)

Code: Select all

try:
    engines = rest.get_engines()
    print("Please choose an engine")
    pprint(list(engines_keys()))
    
#Catch any HTTP / REST exceptions and log the underlying cause
except HTTPError as e:
    print("Error during REST request: %s" % e)
Any and all advice would be much appreciated!! THANK YOU for all your support over the years.
schmidt
Posts: 117
Joined: Sat May 30, 2020 3:00 pm
Full Name: JR Schmidt
Organization: WebMO, LLC

Re: Trouble with some WebMOREST methods

Post by schmidt »

Many of these methods require both:

(1) The newest version of the Python library (which you can obtain free from the PyPi repository). You can always upgrade to the newest Python version with: pip install --upgrade pip

(2) In addition, some of these methods require WebMO v24 or even v25.
christinem2005
Posts: 3
Joined: Fri Sep 06, 2024 4:08 pm
Full Name: Christine Morales
Organization: University of Mount Union
Subdiscipline: Chemistry

Re: Trouble with some WebMOREST methods

Post by christinem2005 »

Thank you!!!

I have now upgraded to the latest version of WebMO on the client side. On the server side, I will need to communicate with the system administrators regarding possible future updates to WebMO.

Is there a list somewhere of the WebMOREST methods that work with different versions of WebMO? I did not see it in the Release Notes.

Much appreciated, again!!
polik
Posts: 27
Joined: Fri May 29, 2020 6:20 pm
Full Name: Will Polik
Organization: WebMO LLC

Re: Trouble with some WebMOREST methods

Post by polik »

The WebMO website has online documentation for the webmo Python library that is supported by the current version of WebMO Enterprise (WebMO 25 at the time of this post).

The Python functions available for a specific version of WebMO Enterprise are those that are documented in the Help page for that version:
For WebMO 24, see Enterprise Features > Python Interface
For WebMO 25, see Enterprise Features > WebMO Python Library

These can be found on the Help documentation of your local installation of WebMO Enterprise.
Post Reply