Skip to content

Commit 7291f86

Browse files
authored
[FSTORE-1452] Deduplicate job- and execution-related code (#247)
* Move job- and execution-related files from hopsworks * Partially adapt the moved files * Merge hsfs Job into hopsworks_common * Partial merge of hsfs job/execution * Fix docgen * Fix mocking in test_ingestion_job * Fix mocking in text_job * Fix mocking in test_python * Move job configurations * Merge hsfs job_api * Move ingestion_job * Create alias for ingestion_job * Adapt the moved code * Fix mocking * Fix renaming to JobApi and ExecutionApi * Fix missing job in Execution.from_response_json * Fix mocking in test_feature_group_writer * Addressing the review * Revert redundant mocking * Fix client mocking * Add comment with possible execution states
1 parent 17de091 commit 7291f86

40 files changed

+2350
-2294
lines changed

Diff for: python/auto_doc.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@
5656
),
5757
},
5858
"api/jobs.md": {
59-
"job_api_handle": ["hopsworks.project.Project.get_jobs_api"],
60-
"job_create": ["hopsworks.core.job_api.JobsApi.create_job"],
61-
"job_get": ["hopsworks.core.job_api.JobsApi.get_job"],
62-
"job_get_all": ["hopsworks.core.job_api.JobsApi.get_jobs"],
59+
"job_api_handle": ["hopsworks.project.Project.get_job_api"],
60+
"job_create": ["hopsworks.core.job_api.JobApi.create_job"],
61+
"job_get": ["hopsworks.core.job_api.JobApi.get_job"],
62+
"job_get_all": ["hopsworks.core.job_api.JobApi.get_jobs"],
6363
"job_properties": keras_autodoc.get_properties("hopsworks.job.Job"),
64-
"job_config": ["hopsworks.core.job_api.JobsApi.get_configuration"],
64+
"job_config": ["hopsworks.core.job_api.JobApi.get_configuration"],
6565
"job_methods": keras_autodoc.get_methods(
6666
"hopsworks.job.Job", exclude=["from_response_json", "json"]
6767
),

Diff for: python/hopsworks/core/execution_api.py

+7-70
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2022 Logical Clocks AB
2+
# Copyright 2024 Hopsworks AB
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -14,74 +14,11 @@
1414
# limitations under the License.
1515
#
1616

17-
from hopsworks import client, execution
17+
from hopsworks_common.core.execution_api import (
18+
ExecutionApi,
19+
)
1820

1921

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

Comments
 (0)