diff --git a/paicli/api.py b/paicli/api.py index 9a4e61b..1de2f78 100644 --- a/paicli/api.py +++ b/paicli/api.py @@ -64,6 +64,7 @@ def get_jobs_jobname(self, jobname): res.raise_for_status() def post_jobs(self, job_config_json): + """NOTE: DEPRECATED. Use post_user_username_jobs""" url = "{}/api/{}/jobs".format(self.config.api_uri, self.config.api_version) headers = self._headers_with_auth() @@ -90,6 +91,17 @@ def get_jobs_jobname_ssh(self, jobname): else: res.raise_for_status() + def post_user_username_jobs(self, username, job_config_json): + url = "{}/api/{}/user/{}/jobs".format(self.config.api_uri, self.config.api_version, username) + headers = self._headers_with_auth() + + res = requests.post(url, headers=headers, data=job_config_json) + + if res.ok: + return to_str(res.content) + else: + res.raise_for_status() + def get_user_username_jobs_jobname_ssh(self, username, jobname): url = "{}/api/{}/user/{}/jobs/{}/ssh".format(self.config.api_uri, self.config.api_version, username, jobname) res = requests.get(url) diff --git a/paicli/main.py b/paicli/main.py index 8e0f476..51f9eae 100644 --- a/paicli/main.py +++ b/paicli/main.py @@ -168,7 +168,7 @@ def submitcmd(job_config_json, profile): for _job_config_json in job_config_json_list: try: - api.post_jobs(_job_config_json) + api.post_user_username_jobs(config.username, _job_config_json) print(colored("Successfully submitted!", "green") + ": {}" .format(json.loads(_job_config_json)['jobName'])) except requests.HTTPError as e: