Skip to content

Commit 0b5dfd1

Browse files
zjgemidp-dingzhaohanpre-commit-ci[bot]njzjz
authored
Compatible for bohrium OpenAPI sandbox (#553)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **Bug Fixes** * Improved reliability of job grouping by safely handling missing data fields with sensible defaults. * Fixed conditional log retrieval to only fetch logs when appropriate. * Enhanced exit code handling for better control over job completion status. * **Improvements** * Ensured automatic creation of required directories at initialization for smoother setup. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: zjgemi <[email protected]> Co-authored-by: dingzhaohan <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jinzhe Zeng <[email protected]> Co-authored-by: Jinzhe Zeng <[email protected]>
1 parent bef2195 commit 0b5dfd1

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

dpdispatcher/contexts/openapi_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def upload_job(self, job, common_files=None):
170170
object_key = os.path.join(data["storePath"], zip_filename) # type: ignore
171171
job.upload_path = object_key
172172
job.job_id = data["jobId"] # type: ignore
173-
job.jgid = data["jobGroupId"] # type: ignore
173+
job.jgid = data.get("jobGroupId", "") # type: ignore
174174
self.storage.upload_From_file_multi_part(
175175
object_key=object_key, file_path=upload_zip, token=token
176176
)

dpdispatcher/machines/openapi.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,13 @@ def do_submit(self, job):
129129
),
130130
"out_files": self._gen_backward_files_list(job),
131131
"platform": self.remote_profile.get("platform", "ali"),
132-
"image_address": self.remote_profile.get("image_address", ""),
132+
"image_name": self.remote_profile.get("image_address", ""),
133133
}
134-
if job.job_state == JobStatus.unsubmitted:
135-
openapi_params["job_id"] = job.job_id
134+
if "real_user_id" in self.remote_profile:
135+
openapi_params["real_user_id"] = self.remote_profile["real_user_id"]
136+
if "session_id" in self.remote_profile:
137+
openapi_params["session_id"] = self.remote_profile["session_id"]
138+
openapi_params["job_id"] = job.job_id
136139
data = self.job.insert(**openapi_params)
137140

138141
job.job_id = data.get("jobId", 0) # type: ignore
@@ -182,8 +185,8 @@ def check_status(self, job):
182185
self.ignore_exit_code,
183186
)
184187
if job_state == JobStatus.finished:
185-
job_log = self.job.log(job_id)
186188
if self.remote_profile.get("output_log"):
189+
job_log = self.job.log(job_id)
187190
print(job_log, end="")
188191
self._download_job(job)
189192
elif self.remote_profile.get("output_log") and job_state == JobStatus.running:
@@ -193,7 +196,7 @@ def check_status(self, job):
193196

194197
def _download_job(self, job):
195198
data = self.job.detail(job.job_id)
196-
job_url = data["jobFiles"]["outFiles"][0]["url"] # type: ignore
199+
job_url = data["resultUrl"] # type: ignore
197200
if not job_url:
198201
return
199202
job_hash = job.job_hash
@@ -243,7 +246,7 @@ def map_dp_job_state(status, exit_code, ignore_exit_code=True):
243246
if status not in map_dict:
244247
dlog.error(f"unknown job status {status}")
245248
return JobStatus.unknown
246-
if status == -1 and exit_code != 0 and ignore_exit_code:
249+
if status == -1 and ignore_exit_code:
247250
return JobStatus.finished
248251
return map_dict[status]
249252

0 commit comments

Comments
 (0)