import xmltodict from openml._api_calls import _perform_api_call def _check_flow_exists(name, version): """Retrieves the flow id of the flow uniquely identified by name+version. Parameter --------- name : string Name of the flow version : string Version information associated with flow. Returns ------- flow_exist : int Flow id or -1 if the flow doesn't exist. Notes ----- see https://www.openml.org/api_docs/#!/flow/get_flow_exists_name_version """ if not (type(name) is str and len(name) > 0): raise ValueError('Argument \'name\' should be a non-empty string') if not (type(version) is str and len(version) > 0): raise ValueError('Argument \'version\' should be a non-empty string') return_code, xml_response = _perform_api_call( "flow/exists/%s/%s" % (name, version)) # TODO check with latest version of code if this raises an exception if return_code != 200: # fixme raise appropriate error raise ValueError("api call failed: %s" % xml_response) xml_dict = xmltodict.parse(xml_response) flow_id = xml_dict['oml:flow_exists']['oml:id'] return return_code, xml_response, flow_id