qmenta.core.platform

exception qmenta.core.platform.ChooseDataError(warning: str, data_to_choose: str, analysis_id: int)

When a trying to start an analysis, but data has to be chosen

Parameters:
  • warning (str) – Warning message returned by the platform

  • data_to_choose (str) – Specification of the data to choose returned by the platform

  • analysis_id (int) – The ID of the analysis for which data needs to be chosen, returned by the platform.

qmenta.core.platform.parse_response(response: Response) Any

Convert a platform response to JSON and check that it is valid. This function should be applied to the output of post().

Parameters:

response (requests.Response) – The response from the platform

Raises:
  • InvalidResponseError – When the response of the platform cannot be converted to JSON, or when it has unexpected values or missing keys.

  • ActionFailedError – When the requested action could not be performed by the platform

  • ChooseDataError – When a POST was done to start an analysis, but data needs to be chosen before the analysis can be started.

Returns:

When the platform returns a response with a list in the JSON, it is returned. Otherwise, it is assumed that the returned value is a dict. In case the dict has a ‘data’ key, the value of data in the dict is returned, otherwise the full dict is returned.

Return type:

dict or list

qmenta.core.platform.post(auth: Auth, endpoint: str, data: Dict[str, Any] = {}, headers: Dict[str, Any] = {}, stream: bool = False, timeout: float = 30.0) Response

Post the given data and headers to the specified platform’s endpoint.

Parameters:
  • auth (qmenta.core.platform.Auth) – Auth object that was used to authenticate to the QMENTA platform

  • endpoint (str) – The end-point in the platform to post to

  • data (dict) – The data to post

  • headers (dict) – The headers to post

  • stream (bool) – Stream the response. This is used when downloading files. Default value: False.

  • timeout (float) – Timeout in seconds. If no bytes have been received within this time, an exception is raised. Default value: 30.

Raises:

qmenta.core.errors.ConnectionError – When there is a problem connecting to the QMENTA platform

Returns:

The response object returned by the request.

Return type:

requests.Response