{"action":"opened","issue":{"url":"https://api.github.com/repos/uzh/gc3pie/issues/547","repository_url":"https://api.github.com/repos/uzh/gc3pie","labels_url":"https://api.github.com/repos/uzh/gc3pie/issues/547/labels{/name}","comments_url":"https://api.github.com/repos/uzh/gc3pie/issues/547/comments","events_url":"https://api.github.com/repos/uzh/gc3pie/issues/547/events","html_url":"https://github.com/uzh/gc3pie/issues/547","id":159114933,"number":547,"title":"Parse backend specific arguments to Task constructor","user":{"login":"HackerMD","id":6855297,"avatar_url":"https://avatars.githubusercontent.com/u/6855297?v=3","gravatar_id":"","url":"https://api.github.com/users/HackerMD","html_url":"https://github.com/HackerMD","followers_url":"https://api.github.com/users/HackerMD/followers","following_url":"https://api.github.com/users/HackerMD/following{/other_user}","gists_url":"https://api.github.com/users/HackerMD/gists{/gist_id}","starred_url":"https://api.github.com/users/HackerMD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HackerMD/subscriptions","organizations_url":"https://api.github.com/users/HackerMD/orgs","repos_url":"https://api.github.com/users/HackerMD/repos","events_url":"https://api.github.com/users/HackerMD/events{/privacy}","received_events_url":"https://api.github.com/users/HackerMD/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-08T09:10:33Z","updated_at":"2016-06-08T09:10:33Z","closed_at":null,"body":"There are cases where one needs to provide additional submission arguments. For example, to implement fair job scheduling across multiple users and accounts with SLURM one may need to specify `--account` or `--user`.\r\n\r\nCurrently, this can not be done programatically in the API. One could use the `environment` to specify an environment variable and alias `sbatch` in the config file, but this has many problems associated with it. It would be way cleaner to pass these arguments to the `Task` constructor.\r\n\r\ne.g.:\r\n\r\n```python\r\napp = Application(\r\n    arguments=['hostname'],\r\n    inputs=[],\r\n    outputs=[],\r\n    batch_arguments={'account': 'myAccount'}\r\n)\r\n```\r\n\r\nThe key, value pairs of the `batch_arguments` mapping could then be appended to the actual submission command (here illustrated for the SLURM backend in [slurm.py](https://github.com/uzh/gc3pie/blob/develop/gc3libs/backends/slurm.py#L193)):\r\n\r\n```python\r\ndef _submit_command(self, app):\r\n        sbatch_argv, app_argv = app.sbatch(self)\r\n        if hasattr(app, 'batch_arguments'):\r\n            valid_sbatch_args = {'account', 'user'}\r\n            for name, value in app.batch_arguments.items():\r\n                if name in valid_sbatch_args:\r\n                    sbatch_argv.extend(['--{0}'.format(str(name)), str(value)])\r\n        return (sh_quote_safe_cmdline(sbatch_argv),\r\n                sh_quote_unsafe_cmdline(app_argv))\r\n```"}}
{"actor":{"display_login":"HackerMD"}}