quanted / cts_app

cts repo
3 stars 3 forks source link

Error message if no reaction library or an invalid one is requested for Metabolizer #207

Closed popenc closed 1 year ago

popenc commented 1 year ago

I was looking at the CTS API for Metabolizer predictions, and I wondered what would happen if someone used the API without specifying a reaction library and/or with an invalid reaction library name. If the user enters an invalid reaction library name in the desktop application, Metabolizer reverts to the default library, which has a lot of questionable predictions. Is there a way to block API users from executing Metabolizer using the default library? For example, could the API return an error message if the library is unspecified or an invalid name? (The reason I started thinking about this possibility is that the CCTE Hazard Comparison Dashboard is getting some strange predicted products. Tony Williams mentioned that they were using CTS web services for getting at least some of the predictions, but there shouldn’t be a way to generate the strange predicted products with any of the CTS reaction libraries.)

popenc commented 1 year ago

@cstevens227, they're using the /cts/rest/metabolizer endpoint I'm assuming? I'm testing results for that endpoint without a library and with an invalid library, and I'm seeing error messages coming back. I'm interested in the requests they're making and what the output looks like.

Here's a response from CTS API with an invalid library:

{
  "metaInfo": {
    "model": "metabolizer",
    "collection": "qed",
    "modelVersion": "",
    "description": "",
    "status": "",
    "timestamp": "20221024104845091041",
    "url": {
      "type": "application/json",
      "href": "http://qedinternal.epa.gov/cts/rest/metabolizer"
    }
  },
  "data": {
    "calc": "metabolizer",
    "prop": "products",
    "node": [
      null
    ],
    "data": null,
    "total_products": 0,
    "unique_products": 0,
    "chemical": [
      "CCCC"
    ],
    "workflow": "gentrans",
    "run_type": [
      "batch"
    ],
    "request_post": {
      "metabolizer_post": {
        "structure": "CCCC",
        "generationLimit": 0,
        "populationLimit": 0,
        "likelyLimit": 0.1,
        "transformationLibraries": [
          "invalid"
        ],
        "excludeCondition": "hasValenceError()"
      },
      "chemical": "CCCC",
      "gen_limit": 0
    },
    "error": "Error getting transformation products"
  }
}

Here's a response from CTS API with no library in request:

{
  "metaInfo": {
    "model": "metabolizer",
    "collection": "qed",
    "modelVersion": "",
    "description": "",
    "status": "",
    "timestamp": "20221024105153833596",
    "url": {
      "type": "application/json",
      "href": "http://qedinternal.epa.gov/cts/rest/metabolizer"
    }
  },
  "data": {
    "calc": "metabolizer",
    "prop": "products",
    "node": [
      null
    ],
    "data": null,
    "total_products": 0,
    "unique_products": 0,
    "chemical": [
      "CCCC"
    ],
    "workflow": "gentrans",
    "run_type": [
      "batch"
    ],
    "request_post": {
      "metabolizer_post": {
        "structure": "CCCC",
        "generationLimit": 0,
        "populationLimit": 0,
        "likelyLimit": 0.1,
        "transformationLibraries": [],
        "excludeCondition": "hasValenceError()"
      },
      "chemical": "CCCC",
      "gen_limit": 0
    },
    "error": "Can only run one transformation library at a time."
  }
}
popenc commented 1 year ago

Closing this issue as it appears proper error handling is occurring. Still haven't heard back from original user who brought up the issue.