Skip to content

Commit c615ebb

Browse files
committed
job download log interface
1 parent b233a4a commit c615ebb

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/bohrium/resources/job/job.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def detail(self, job_id):
9494
response = self._client.get(f"/openapi/v1/job/{job_id}")
9595
pprint(response.request)
9696
print(response.json())
97+
return response.json().get("data")
9798

9899
def create_job(
99100
self,
@@ -140,6 +141,11 @@ def uploadr(self, work_dir, store_path, token):
140141
self.upload(full_path, object_key, token)
141142

142143

144+
def download(self, job_id, save_path):
145+
detail = self.detail(job_id)
146+
tiefblue = Tiefblue()
147+
tiefblue.download_from_url(detail["resultUrl"], save_path)
148+
143149
class AsyncJob(AsyncAPIResource):
144150
pass
145151

tests/job.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
if __name__ == "__main__":
66

77
bohrium = Bohrium(
8-
access_key="7d300756a875455a9faff8eaad2337bf",
8+
access_key="7bbf9f82c3904a1c909644e0f7e5ee58",
99
project_id="154",
1010
timeout=httpx.Timeout(40.0),
1111
)
1212

1313
data = {
14-
"job_type": "container",
1514
"job_name": "test-name",
1615
"project_id": 154,
1716
"machine_type": "c2_m4_cpu",
@@ -25,18 +24,20 @@
2524
"result": "/personal/test/result"
2625
}
2726

28-
job = bohrium.job.submit(
29-
project_id=data["project_id"],
30-
job_name=data["job_name"],
31-
machine_type=data["machine_type"],
32-
cmd=data["cmd"],
33-
image_address=data["image_address"],
34-
job_group_id=data["job_group_id"],
35-
work_dir=data["work_dir"],
36-
result=data["result"],
37-
dataset_path=data["dataset_path"],
38-
log_files=data["log_files"],
39-
out_files=data["out_files"],
40-
)
27+
# job = bohrium.job.submit(
28+
# project_id=data["project_id"],
29+
# job_name=data["job_name"],
30+
# machine_type=data["machine_type"],
31+
# cmd=data["cmd"],
32+
# image_address=data["image_address"],
33+
# job_group_id=data["job_group_id"],
34+
# work_dir=data["work_dir"],
35+
# result=data["result"],
36+
# dataset_path=data["dataset_path"],
37+
# log_files=data["log_files"],
38+
# out_files=data["out_files"],
39+
# )
4140

42-
job = bohrium.job.detail("12513182")
41+
# job = bohrium.job.detail("12513182")
42+
# job = bohrium.job.download("12513182", "./output.zip")
43+
job = bohrium.job.log("12513182")

0 commit comments

Comments
 (0)