|
1 | 1 | #
|
2 |
| -# Copyright 2022 Logical Clocks AB |
| 2 | +# Copyright 2024 Hopsworks AB |
3 | 3 | #
|
4 | 4 | # Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | # you may not use this file except in compliance with the License.
|
|
14 | 14 | # limitations under the License.
|
15 | 15 | #
|
16 | 16 |
|
17 |
| -from hopsworks import client, execution |
| 17 | +from hopsworks_common.core.execution_api import ( |
| 18 | + ExecutionApi, |
| 19 | +) |
18 | 20 |
|
19 | 21 |
|
20 |
| -class ExecutionsApi: |
21 |
| - def _start(self, job, args: str = None): |
22 |
| - _client = client.get_instance() |
23 |
| - path_params = ["project", _client._project_id, "jobs", job.name, "executions"] |
24 |
| - |
25 |
| - return execution.Execution.from_response_json( |
26 |
| - _client._send_request("POST", path_params, data=args), job |
27 |
| - ) |
28 |
| - |
29 |
| - def _get(self, job, id): |
30 |
| - _client = client.get_instance() |
31 |
| - path_params = [ |
32 |
| - "project", |
33 |
| - _client._project_id, |
34 |
| - "jobs", |
35 |
| - job.name, |
36 |
| - "executions", |
37 |
| - id, |
38 |
| - ] |
39 |
| - |
40 |
| - headers = {"content-type": "application/json"} |
41 |
| - return execution.Execution.from_response_json( |
42 |
| - _client._send_request("GET", path_params, headers=headers), job |
43 |
| - ) |
44 |
| - |
45 |
| - def _get_all(self, job): |
46 |
| - _client = client.get_instance() |
47 |
| - path_params = ["project", _client._project_id, "jobs", job.name, "executions"] |
48 |
| - |
49 |
| - query_params = {"sort_by": "submissiontime:desc"} |
50 |
| - |
51 |
| - headers = {"content-type": "application/json"} |
52 |
| - return execution.Execution.from_response_json( |
53 |
| - _client._send_request( |
54 |
| - "GET", path_params, headers=headers, query_params=query_params |
55 |
| - ), |
56 |
| - job, |
57 |
| - ) |
58 |
| - |
59 |
| - def _delete(self, job_name, id): |
60 |
| - _client = client.get_instance() |
61 |
| - path_params = [ |
62 |
| - "project", |
63 |
| - _client._project_id, |
64 |
| - "jobs", |
65 |
| - job_name, |
66 |
| - "executions", |
67 |
| - id, |
68 |
| - ] |
69 |
| - _client._send_request("DELETE", path_params) |
70 |
| - |
71 |
| - def _stop(self, job_name: str, id: int) -> None: |
72 |
| - _client = client.get_instance() |
73 |
| - path_params = [ |
74 |
| - "project", |
75 |
| - _client._project_id, |
76 |
| - "jobs", |
77 |
| - job_name, |
78 |
| - "executions", |
79 |
| - id, |
80 |
| - "status", |
81 |
| - ] |
82 |
| - _client._send_request( |
83 |
| - "PUT", |
84 |
| - path_params=path_params, |
85 |
| - data={"state": "stopped"}, |
86 |
| - headers={"Content-Type": "application/json"}, |
87 |
| - ) |
| 22 | +__all__ = [ |
| 23 | + ExecutionApi, |
| 24 | +] |
0 commit comments