Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API call to flow/1 raises an error (status_code: 500) #305

Closed
minoriinoue opened this issue Sep 1, 2017 · 8 comments · Fixed by #818
Closed

API call to flow/1 raises an error (status_code: 500) #305

minoriinoue opened this issue Sep 1, 2017 · 8 comments · Fixed by #818
Assignees
Labels

Comments

@minoriinoue
Copy link
Contributor

Hi,

An API call flows.get_flow(1) or REST API (flow/1) raises an error. (Attached is the error message.)

screen shot 2017-09-01 at 15 46 26

I would like to fetch every flow description, and I wondered what is the problem here.

Thanks!
Minori

@joaquinvanschoren
Copy link
Contributor

joaquinvanschoren commented Sep 1, 2017 via email

@minoriinoue
Copy link
Contributor Author

Hi Joaquin,

Thanks for reply :)
Sorry, I didn't specify the situation, but I first fetch all the flows with flows.list_flows() and iterate through it. The returned list of flows contains a flow with id 1.

Here's the code:

flows_list = flows.list_flows()
flow_ids = [dict['id'] for fid, dict in flows_list.iteritems()]

openml_flows = []
for flow_id in flow_ids:
    print flow_id
    openml_flows.append(flows.get_flow(flow_id))

I skipped flow id 1 and confirmed flows.get(flow_id) works with other ids in the list :)

@joaquinvanschoren
Copy link
Contributor

joaquinvanschoren commented Sep 4, 2017 via email

@mfeurer mfeurer added the bug label Sep 29, 2017
@PGijsbers
Copy link
Collaborator

I was looking into tidying this up, but by reading the code it seems to way forward is not very clear.
As is, get_flow(1) still produces an internal server error (code 500), which in the end gets delegated down to _parse_server_exception. Here you can see (almost) complete information about the returned response object:
image

It is clear that the server error does not have text, so it fails to parse as xml. However, from _parse_server_exception comments and code, it seems that error code 500 should result in 'OpenMLServerNoResult` instead. So we have to resolve it in one of two ways:

  • Add parseable xml response to status 500 message we get back from the server, or
  • Check the error code before parsing the response text, and raise an error even if the response text can not be parsed (it may still be attempted to be parsed, but in case of a fail it would just raise something akin to OpenMLServerNoResult(code, "No text found in response message.", "").

If this is resolved, we can explicitly catch OpenMLServerNoResult exception and give a friendly error. @mfeurer

@mfeurer
Copy link
Collaborator

mfeurer commented Mar 18, 2019

Thanks for looking into this @PGijsbers

Regarding the fact that there's a server error when retrieving flow number 1, only @janvanrijn can fix this. I guess the new issue regarding the invalid xml should also be dealt by @janvanrijn

Therefore, I took the liberty of assigning @janvanrijn to this issue ;)

@mfeurer
Copy link
Collaborator

mfeurer commented Apr 17, 2019

Related to openml/OpenML#362, which should be solved.

@PGijsbers
Copy link
Collaborator

>>> f = openml.flows.get_flow(1)
Traceback (most recent call last):
  File "D:\repositories\openml-python\openml\flows\functions.py", line 64, in _get_cached_flow
    with io.open(flow_file, encoding='utf8') as fh:
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\\\.openml\\\\cache\\org\\openml\\www\\flows\\1\\flow.xml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\repositories\openml-python\openml\flows\functions.py", line 115, in _get_flow_description
    return _get_cached_flow(flow_id)
  File "D:\repositories\openml-python\openml\flows\functions.py", line 69, in _get_cached_flow
    "cached" % fid)
openml.exceptions.OpenMLCacheException: Flow file for fid 1 not cached

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\repositories\openml-python\openml\utils.py", line 310, in safe_func
    return func(*args, **kwargs)
  File "D:\repositories\openml-python\openml\flows\functions.py", line 90, in get_flow
    flow = _get_flow_description(flow_id)
  File "D:\repositories\openml-python\openml\flows\functions.py", line 127, in _get_flow_description
    return _create_flow_from_xml(flow_xml)
  File "D:\repositories\openml-python\openml\flows\functions.py", line 372, in _create_flow_from_xml
    return OpenMLFlow._from_dict(xmltodict.parse(flow_xml))
  File "D:\repositories\openml-python\openml\flows\flow.py", line 258, in _from_dict
    arguments[key] = dic["oml:" + key]
KeyError: 'oml:external_version'

External versions are required, right?

@mfeurer
Copy link
Collaborator

mfeurer commented Apr 17, 2019

mfeurer added a commit that referenced this issue Oct 14, 2019
PGijsbers pushed a commit that referenced this issue Oct 14, 2019
* fix issue #305 by not requiring external version in the flow xml

* add unit test for #305

* improve documentation

* improve based on Pieter's feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants