oeplatform icon indicating copy to clipboard operation
oeplatform copied to clipboard

OEP Data Upload Documentation: Duplicate tutorials exist, some with incorrect code

Open amanda-wein opened this issue 1 year ago • 1 comments

Description of the issue

There are currently several tutorials for uploading data to the OEP, and some contain outdated processes and non-functional code examples. In addition to the tutorials for the data upload wizard, there are two separate API upload tutorials:

  • https://openenergyplatform.github.io/academy/tutorials/01_api/02_api_upload/
  • https://openenergyplatform.github.io/academy/tutorials/99_other/beginners_guide/
    • Known error (identified by @jh-RLI): In section 2.1.1 the code snippet "url = API_URL + '/topic/model_draft/tables/' + TABLE_NAME" is incorrect and should be "url = API_URL + '/schema/model_draft/tables/' + TABLE_NAME"

Ideas of solution

Rework the tutorials so that there is only one tutorial article for each topic. During this rework, verify the content of the tutorials to make sure that the procedures are still accurate and the code examples function properly.

Workflow checklist

amanda-wein avatar Sep 09 '24 14:09 amanda-wein

Even that example URL is not completely correct. It should be

url = API_URL + '/schema/model_draft/tables/' + TABLE_NAME + '/'

Else you get a 500 error of Django (on debug)

You called this URL via PUT, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining PUT data. Change your form to point to localhost:8080/api/v0/schema/model_draft/tables/test1/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.

or in OEP:

{"reason": "Table contains no columns"}
Traceback (most recent call last):
  File "/home/me/create_table.py", line 41, in <module>
    res.raise_for_status() # check: throws exception if not successful
  File "/home/me/.local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://openenergyplatform.org/api/v0/schema/model_draft/tables/test_v2353457/

(even though requests shows a wrong exception here with a trailing /, but is only created with the full url above an then provides an empty dict as response.)

ebroda avatar Sep 10 '24 12:09 ebroda