Demonstrator - Reasoning WebAPI issueshttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues2021-05-13T11:43:50Zhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/56Cleanup2021-05-13T11:43:50ZSiebers, MichaelCleanupSmall tasks to be done before bumping the version number:
- change pldoc alias from `__API__` to `_API_` (consistent with default aliases)
- move `version.pl` to root directory (more prominent position)
- export version number under oth...Small tasks to be done before bumping the version number:
- change pldoc alias from `__API__` to `_API_` (consistent with default aliases)
- move `version.pl` to root directory (more prominent position)
- export version number under other name (`this_version/1` is rather uncommon), or export `api_version//0` instead
- remove mockups
- remove unused predicates?
- define and use location `background`?
- verify schemata
- provide curls?Version 1.0Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/55Automatically generate standalone documentation2021-06-04T21:54:14ZSiebers, MichaelAutomatically generate standalone documentationGenerate standalone documentation in form of local html pages. Generation may be done in CI/CD.Generate standalone documentation in form of local html pages. Generation may be done in CI/CD.Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/36POST Request with negative Content-Length leads to 500 status2020-12-04T17:46:04ZSiebers, MichaelPOST Request with negative Content-Length leads to 500 statusSending a request with negative `Content-Length` header leads to a `500 Internal Server Error`. Error message is accompanied by an HTML error message.
This should be a `4xx` status with a JSON error message.Sending a request with negative `Content-Length` header leads to a `500 Internal Server Error`. Error message is accompanied by an HTML error message.
This should be a `4xx` status with a JSON error message.https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/30'Request zero' at GET2020-11-30T16:09:54ZSebastian Seufert'Request zero' at GETAPI reacts with completed request 0.
```server(started, 1606395900).
/*Thu Nov 26 14:04:59 2020*/
request(1, 1606395899.985, [peer(ip(127,0,0,1)),method(get),request_uri('/bg'),path('/bg'),http_version(1-1),content_type('application/js...API reacts with completed request 0.
```server(started, 1606395900).
/*Thu Nov 26 14:04:59 2020*/
request(1, 1606395899.985, [peer(ip(127,0,0,1)),method(get),request_uri('/bg'),path('/bg'),http_version(1-1),content_type('application/json'),user_agent('PostmanRuntime/7.26.8'),postman_token('fc04c4f5-3f71-40a2-b3fe-66fc358a9f10'),host(localhost),port(5000),content_length(735)]).
completed(1, 0.029408105, 630, 200, ok).
completed(0, 0.047579236, 328, 400, error("Illegal HTTP parameter: { (in_http_request)")).
server(stopped, 1606395987).
```
----
I have no idea at the moment what causes this / where this comes from, but since it does not crop up in Postman or curl, I assume this _should_ not interfere with API functionality from the clients perspective.
Investigating.Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/26Startup parameters2020-11-26T13:39:06ZSiebers, MichaelStartup parametersStartup options for the server (like port to run on) seem to be managed in the predicate server_opts/1. However, I do not use how to use them. Regarding the port option, for instance, neither of the following works:
```
swipl -s run.pl ...Startup options for the server (like port to run on) seem to be managed in the predicate server_opts/1. However, I do not use how to use them. Regarding the port option, for instance, neither of the following works:
```
swipl -s run.pl --port 8976
```
```
swipl -s run.pl --port=8976
```
```
swipl -s run.pl port=8976
```
According to the swipl usage message, swi-options and programm arguments should (can?) be separated by `--`. This seems to kinda work. However, then our code complains that `--` is no valid argument.
Basically, I have the following questions:
1. How is it possible to start the server with arguments?
1. Which arguments are defined? Or rather, what do they do?
1. Can we print some usage message ourselves? For example with `-h` but without interfering with swipl's `-h` argument?Version 1.0Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/23Automate API-tests2021-06-12T09:00:31ZSiebers, MichaelAutomate API-testsAPI testing could be automated using Postman. There test requests with success conditions can be defined. These requests can be stored in collections which may be executed from CLI/CI.API testing could be automated using Postman. There test requests with success conditions can be defined. These requests can be stored in collections which may be executed from CLI/CI.https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/58Support for running as daemon under *nix2021-06-02T12:42:13ZSebastian SeufertSupport for running as daemon under *nixWhen the API is started as daemon it quits/fails.\
Assumption is this is due to SWI's expected environment during runtime / when starting as default REPL with stdio
(case at hand: this [student-project](https://gitlab.rz.uni-bamberg.de/c...When the API is started as daemon it quits/fails.\
Assumption is this is due to SWI's expected environment during runtime / when starting as default REPL with stdio
(case at hand: this [student-project](https://gitlab.rz.uni-bamberg.de/cogsys/its/its-subtraction-webinterface) for which @klaus.stein tried to run a stripped version of the API in a docker container).
@michael.siebers
this might be a somewhat easy fix, c.f. the library-support for http-daemons [here](https://github.com/SWI-Prolog/packages-http/blob/master/http_unix_daemon.pl).\
Do you see any problems I might not see if we used this as wrapper around `web_api.pl`?
-----------------------
Thinking ahead on what might be a problem:
We deliberately ignored anything related to multiuser/threading issues, so could it be possible for the container to be configured s.t. it spawns separate isolated daemon-processes if needed? @klaus.stein \
(I know this is not all that needs to be considered...)Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/57Number headers only for documentation2020-12-13T19:24:59ZSiebers, MichaelNumber headers only for documentationRegarding the numbering of headers introduced in commit 1dd752e6cf9ca4831eb9c1144ed5c887440dacd1: These are applied to all headlines (in our documentation, auto-generated directory views and the manual). In some places this looks rather ...Regarding the numbering of headers introduced in commit 1dd752e6cf9ca4831eb9c1144ed5c887440dacd1: These are applied to all headlines (in our documentation, auto-generated directory views and the manual). In some places this looks rather ugly, e.g. http://localhost:4444/doc/pldoc/man?section=preddesc.
Could we restrict this formatting to our documentation (directly below `/doc`)?
Implementation note: our documentation is surrounded with a custom wrapper div (id `wiki-wrapper`?)Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/54review readme.md2020-12-19T04:18:55ZSiebers, Michaelreview readme.mdRevise main [readme.md](readme.md):
- requirements (SWI-Prolog 8.2.2.)
- short intro how to start server (without arguments or only with `--port`)
- refer to documentation server by the software itselfRevise main [readme.md](readme.md):
- requirements (SWI-Prolog 8.2.2.)
- short intro how to start server (without arguments or only with `--port`)
- refer to documentation server by the software itselfVersion 1.0Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/52revise API endpoint documentation2021-06-12T09:00:31ZSiebers, Michaelrevise API endpoint documentationreview and amend [api_endpoints.md](doc/api_endpoints.md):
- review `/bg (GET)`, `/bg (POST)`, `/clear`
- add `/clear/all`
- handle todos in file
- write short section introductionsreview and amend [api_endpoints.md](doc/api_endpoints.md):
- review `/bg (GET)`, `/bg (POST)`, `/clear`
- add `/clear/all`
- handle todos in file
- write short section introductionsVersion 1.0https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/51document JSON schemas2021-06-12T09:00:31ZSiebers, Michaeldocument JSON schemas- revise JSON schemas below `doc/schema`
- link JSON schemas in [api_endpoints.md](doc/api_endpoints.md) where appropriate
- write [schema overview](doc/schema/index.html)- revise JSON schemas below `doc/schema`
- link JSON schemas in [api_endpoints.md](doc/api_endpoints.md) where appropriate
- write [schema overview](doc/schema/index.html)Version 1.0https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/50describe module web_api2020-12-19T04:18:55ZSiebers, Michaeldescribe module web_apiWrite developer documentation for module web_api in [module_web_api.md](doc/module_web_api.md).Write developer documentation for module web_api in [module_web_api.md](doc/module_web_api.md).Version 1.0Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/49describe module theory_bg2021-05-13T11:30:31ZSiebers, Michaeldescribe module theory_bgWrite developer documentation for module theory_bg in [module_theory_bg.md](doc/module_theory_bg.md).Write developer documentation for module theory_bg in [module_theory_bg.md](doc/module_theory_bg.md).Version 1.0Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/48describe module types2020-12-19T04:18:55ZSiebers, Michaeldescribe module typesWrite developer documentation for module types in [module_types.md](doc/module_types.md).Write developer documentation for module types in [module_types.md](doc/module_types.md).Version 1.0Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/46write documentation overview2021-05-13T11:30:31ZSiebers, Michaelwrite documentation overviewwrite / amend the documentation's [landing page](doc/overview.md)write / amend the documentation's [landing page](doc/overview.md)Version 1.0https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/43Write module description for web_api2021-05-13T11:30:31ZSiebers, MichaelWrite module description for web_apiReword structured PLDoc comment in `/src/web_api.pl`.Reword structured PLDoc comment in `/src/web_api.pl`.Version 1.0https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/42Integrate PLDoc server2020-12-10T18:07:35ZSiebers, MichaelIntegrate PLDoc serverAn additional PLDoc server would autogenerate and serve HTML files for the prolog predicate definitions. This server shall be integrated into the main server.
- The endpoint `/doc` will serve the main documentation (started in the WIKI)...An additional PLDoc server would autogenerate and serve HTML files for the prolog predicate definitions. This server shall be integrated into the main server.
- The endpoint `/doc` will serve the main documentation (started in the WIKI).
- The endpoint `doc/pldoc` will serve the actual predicate documentation.
- Whether documentation is served is configurable using a CLI switch (default is yes)
- The served pages will have some custom look and feel (nice-to-have).
- Footer will display the used SWI-Prolog and WebAPI version.https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/37Refactor endpoints2020-12-13T15:13:09ZSiebers, MichaelRefactor endpointsFor naming consistency I propose the following new endpoint names for POST requests:
| New Endpoint | Old Endpoint
|-----|-----|
|`/bg/add` | `/bg` |
|`/bg/remove` | `/clear` |
|`/bg/clear` | `/clear/all` |
The functionally of GET...For naming consistency I propose the following new endpoint names for POST requests:
| New Endpoint | Old Endpoint
|-----|-----|
|`/bg/add` | `/bg` |
|`/bg/remove` | `/clear` |
|`/bg/clear` | `/clear/all` |
The functionally of GET requests to `/bg` should be kept.
# Rationale
All endpoints working on background knowledge work on prefix `/bg`. The suffixes `/add`, `/remove`, and `/clear` convey their meaning more concisely than the original paths. The GET request to `/bg` is clearly separated from other requests.Version 1.0Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/31Document allowed characterpatterns for abs_path2020-12-10T18:07:35ZSebastian SeufertDocument allowed characterpatterns for abs_pathEither as schema or as regular expression.
@michael.siebers since this is related to your typechecking, where to best document this?Either as schema or as regular expression.
@michael.siebers since this is related to your typechecking, where to best document this?Version 1.0Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/29/clear endpoint not working2020-12-04T17:46:04ZSyed Mamoon Ahmed/clear endpoint not workingMy request is:
> {
> "type" : "file",
> "abs_path": "/A/B/Filename-2.exe",
> "file_size": 1024,
> "creation_time": "1604235569",
> "modification_time": "1604235569",
> "access_time": "1604235569",
> "change_time": "1...My request is:
> {
> "type" : "file",
> "abs_path": "/A/B/Filename-2.exe",
> "file_size": 1024,
> "creation_time": "1604235569",
> "modification_time": "1604235569",
> "access_time": "1604235569",
> "change_time": "1604235569",
> "media_type": "img",
> "filename_extension": "png"
> }
The response is this:
<> html>
> <head>
> <meta content="HTML Tidy for Java (vers. 26 Sep 2004), see www.w3.org" name="generator"/>
> <title>500 Internal server error</title>
> <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
> </head>
> <body>
> <h1>Internal server error</h1>
> <p>
> Arguments are not sufficiently instantiated
> <br/>
> In:
> <br/>
> [20] _6592 is _6598-1
> <br/>
> [19] web_api:clear_bg([protocol(http),...|...]) at /home/transmatter/folders/code/uniBam/thesis/demonstrator/web_api.pl:266
> <br/>
> [18] http_dispatch:call_action(web_api:clear_bg,[protocol(http),...|...]) at /usr/lib/swi-prolog/library/http/http_dispatch.pl:1030
> <br/>
> [16] time:run_alarm_goal('$alarm'(11197176410828),http_dispatch:call_action(...,...,...)) at /usr/lib/swi-prolog/library/time.pl:147
> <br/>
> [15] setup_call_catcher_cleanup(time:alarm(300,...,...,...),time:run_alarm_goal(...,...),_850,time:remove_alarm_notrace(...)) at /usr/lib/swi-prolog/boot/init.pl:564
> <br/>
> [8] httpd_wrapper:call_handler(web_api:http_dispatch,28,[protocol(http),...|...]) at /usr/lib/swi-prolog/library/http/http_wrapper.pl:329
> <br/>
> [7] catch(httpd_wrapper:call_handler(...,28,...),error(instantiation_error,context(...,_1000)),httpd_wrapper:true) at /usr/lib/swi-prolog/boot/init.pl:482
> <br/>
> [6] httpd_wrapper:handler_with_output_to(web_api:http_dispatch,28,[protocol(http),...|...],current_output,error(instantiation_error,context(...,_1078))) at /usr/lib/swi-prolog/library/http/http_wrapper.pl:306
> <br/>
> [5] httpd_wrapper:handler_with_output_to(web_api:http_dispatch,28,[protocol(http),...|...],<stream>(0x7f071c03dd50),error(instantiation_error,context(...,_1150))) at /usr/lib/swi-prolog/library/http/http_wrapper.pl:318
> <br/>
> <br/>
> Note: some frames are missing due to last-call optimization.
> <br/>
> Re-run your program in debug mode (:- debug.) to get more detail.
> </p>
> <address>
> <a href="http://www.swi-prolog.org">SWI-Prolog</a>
> httpd at transmatter-laptop
> </address>
> </body>
> </html>
and the log is attached:
[log.txt](/uploads/6c3cc7d695f0c3347e4915d18510b856/log.txt)
PS. There was some documentation on how to use these endpoints in README.md. I cannot find it anymore, so I just used my previous requests.