Skip to content
This repository has been archived by the owner on May 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #52 from sotetsuk/feature/new-submission-api
Browse files Browse the repository at this point in the history
Use new api for submission
  • Loading branch information
sotetsuk authored Jan 9, 2019
2 parents b51c91f + 45c477a commit b778367
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions paicli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion paicli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b778367

Please sign in to comment.