{"action":"closed","issue":{"url":"https://api.github.com/repos/alan-turing-institute/science-gateway-middleware/issues/25","repository_url":"https://api.github.com/repos/alan-turing-institute/science-gateway-middleware","labels_url":"https://api.github.com/repos/alan-turing-institute/science-gateway-middleware/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/alan-turing-institute/science-gateway-middleware/issues/25/comments","events_url":"https://api.github.com/repos/alan-turing-institute/science-gateway-middleware/issues/25/events","html_url":"https://github.com/alan-turing-institute/science-gateway-middleware/issues/25","id":247081184,"number":25,"title":"Expose script verbs as API endpoints that the frontend can see","user":{"login":"sgrieve","id":10617231,"avatar_url":"https://avatars1.githubusercontent.com/u/10617231?v=4","gravatar_id":"","url":"https://api.github.com/users/sgrieve","html_url":"https://github.com/sgrieve","followers_url":"https://api.github.com/users/sgrieve/followers","following_url":"https://api.github.com/users/sgrieve/following{/other_user}","gists_url":"https://api.github.com/users/sgrieve/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrieve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrieve/subscriptions","organizations_url":"https://api.github.com/users/sgrieve/orgs","repos_url":"https://api.github.com/users/sgrieve/repos","events_url":"https://api.github.com/users/sgrieve/events{/privacy}","received_events_url":"https://api.github.com/users/sgrieve/received_events","type":"User","site_admin":false},"labels":[{"id":627254939,"url":"https://api.github.com/repos/alan-turing-institute/science-gateway-middleware/labels/help%20wanted","name":"help wanted","color":"128A0C","default":true}],"state":"closed","locked":false,"assignee":{"login":"sgrieve","id":10617231,"avatar_url":"https://avatars1.githubusercontent.com/u/10617231?v=4","gravatar_id":"","url":"https://api.github.com/users/sgrieve","html_url":"https://github.com/sgrieve","followers_url":"https://api.github.com/users/sgrieve/followers","following_url":"https://api.github.com/users/sgrieve/following{/other_user}","gists_url":"https://api.github.com/users/sgrieve/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrieve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrieve/subscriptions","organizations_url":"https://api.github.com/users/sgrieve/orgs","repos_url":"https://api.github.com/users/sgrieve/repos","events_url":"https://api.github.com/users/sgrieve/events{/privacy}","received_events_url":"https://api.github.com/users/sgrieve/received_events","type":"User","site_admin":false},"assignees":[{"login":"sgrieve","id":10617231,"avatar_url":"https://avatars1.githubusercontent.com/u/10617231?v=4","gravatar_id":"","url":"https://api.github.com/users/sgrieve","html_url":"https://github.com/sgrieve","followers_url":"https://api.github.com/users/sgrieve/followers","following_url":"https://api.github.com/users/sgrieve/following{/other_user}","gists_url":"https://api.github.com/users/sgrieve/gists{/gist_id}","starred_url":"https://api.github.com/users/sgrieve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgrieve/subscriptions","organizations_url":"https://api.github.com/users/sgrieve/orgs","repos_url":"https://api.github.com/users/sgrieve/repos","events_url":"https://api.github.com/users/sgrieve/events{/privacy}","received_events_url":"https://api.github.com/users/sgrieve/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2017-08-01T14:06:53Z","updated_at":"2017-08-08T13:37:18Z","closed_at":"2017-08-08T13:37:18Z","body":"We currently have one method for running a job on the cluster which uses `POST` to patch template files, copy files and scripts to the cluster, and run all of the scripts sequentially. This isn't the final behaviour we need, as we will need to be able to set up jobs, run them, check their progress, kill jobs etc.\r\n\r\nSo we need a collection of verbs attached to each script that needs to be configured for an instance of the gateway.\r\n\r\n### Verbs\r\n\r\n- [x] SETUP\r\n- [x] RUN\r\n- [x] PROGRESS\r\n- [x] CANCEL\r\n\r\nThese will all be post requests set up against api urls e.g. `http://sci-gateway.com/SETUP/<job_ID>`.\r\n\r\nPlan is that the `\"scripts\"` section of the input JSON will have a format similar to:\r\n\r\n`[\"scripts\": [ { \"source_uri\": \"./resources/scripts/start_job.sh\", \"destination_path\": \"project/case/\", \"action\": \"RUN\"}]`\r\n\r\nwith each list item containing the details for one of the verb scripts.\r\n\r\nThings to figure out:\r\n\r\n- [x] How do we track the verb attached to each script\r\n- Answer: We have adopted the `action` key in the scripts input JSON format.\r\n- [x] How best to restructure the existing post request in `JobApi` e.g. what should it do? Just patch? Patch and copy?\r\n- Answer: This method has been rewritten (see comment below) so that there is now clarity of what api endpoint does what.\r\n- [x] Should we include the simulation_root parameter somewhere in the input json, e.g. within `scripts` so the expected keys would be `source_uri`, `destination_path`, `root_path`,  `action`.\r\n- This has been done, with the `simulation_root` parameter being inserted into the `inputs` list of dictionaries. See below for an example of a complete JSON.\r\n- [x] If `simulation_root` is added, there is some refactoring to do around the `job_information_manager` and the associated tests.\r\n\r\n\r\n```\r\n{\r\n  \"id\": \"d769843b-6f37-4939-96c7-c382c3e\",\r\n  \"templates\": [\r\n    {\r\n      \"source_uri\": \".\\/resources\\/templates\\/Blue.nml\",\r\n      \"destination_path\": \"project\\/case\\/\"\r\n    }\r\n  ],\r\n  \"scripts\": [\r\n    {\r\n      \"source_uri\": \".\\/resources\\/scripts\\/start_job.sh\",\r\n      \"destination_path\": \"project\\/case\\/\",\r\n      \"action\": \"RUN\"\r\n    },\r\n    {\r\n      \"source_uri\": \".\\/resources\\/scripts\\/cancel_job.sh\",\r\n      \"destination_path\": \"project\\/case\\/\",\r\n      \"action\": \"CANCEL\"\r\n    },\r\n    {\r\n      \"source_uri\": \".\\/resources\\/scripts\\/progress_job.sh\",\r\n      \"destination_path\": \"project\\/case\\/\",\r\n      \"action\": \"PROGRESS\"\r\n    },\r\n    {\r\n      \"source_uri\": \".\\/resources\\/scripts\\/setup_job.sh\",\r\n      \"destination_path\": \"project\\/case\\/\",\r\n      \"action\": \"SETUP\"\r\n    }\r\n  ],\r\n  \"parameters\": {\r\n    \"viscosity_properties\": {\r\n      \"viscosity_phase_1\": \"0.09\"\r\n    }\r\n  },\r\n  \"inputs\": [\r\n    {\r\n      \"simulation_root\": \"\"\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\n### Workflow\r\n\r\n1. User clicks run button on frontend\r\n1. Button creates HTTP request: `curl -i -H \"Content-Type: application/json\" -X POST http://sci-gateway.com/RUN/<job-id>`\r\n1. [Assuming that auth has been set up, see #6 ]\r\n1. Request triggers api method which finds the path to the RUN script on the cluster [assumes the files have already been patched and copied, triggered by a previous UI action]\r\n1. Executes the run script on the cluster\r\n1. Returns an exit code or other info to the user as the response to the initial request made by the frontend (2.)\r\n\r\n### Tests\r\n\r\nWill also need to write tests for the new methods in `api` and in `job_information_manager` as well as potentially updating existing tests as we have changed the structure of `scripts`."}}
{"actor":{"display_login":"sgrieve"}}