diff --git a/openml/_api_calls.py b/openml/_api_calls.py index 22223d587..0f375d15b 100644 --- a/openml/_api_calls.py +++ b/openml/_api_calls.py @@ -1,9 +1,9 @@ import time -from typing import Dict +import logging import requests import warnings - import xmltodict +from typing import Dict from . import config from .exceptions import (OpenMLServerError, OpenMLServerException, @@ -43,13 +43,22 @@ def _perform_api_call(call, request_method, data=None, file_elements=None): url += call url = url.replace('=', '%3d') - + logging.info('Starting [%s] request for the URL %s', request_method, url) + start = time.time() if file_elements is not None: if request_method != 'post': raise ValueError('request method must be post when file elements ' 'are present') - return _read_url_files(url, data=data, file_elements=file_elements) - return _read_url(url, request_method, data) + response = _read_url_files(url, data=data, file_elements=file_elements) + else: + response = _read_url(url, request_method, data) + logging.info( + '%.7fs taken for [%s] request for the URL %s', + time.time() - start, + request_method, + url, + ) + return response def _file_id_to_url(file_id, filename=None):