Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update v3 models and add get_logs method #79

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions esd_services_api_client/beast/v3/_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,18 @@ def get_configuration(
response.raise_for_status()

return SparkSubmissionConfiguration.from_dict(response.json())

def get_logs(self, request_id: str) -> Optional[str]:
"""
Returns logs for a running or a completed submission.

:param request_id: Submission request identifier.
:return: A job log, if found, or None
"""
response = self.http.get(f"{self.base_url}/job/logs/{request_id}")
if response.status_code == 404:
return None
if not response.ok:
response.raise_for_status()

return "\n".join(response.json())
37 changes: 17 additions & 20 deletions esd_services_api_client/beast/v3/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,33 +204,18 @@ class RequestDebugMode(DataClassJsonMixin):

@dataclass_json(letter_case=LetterCase.CAMEL)
@dataclass
class V1TypedLocalObjectReference(DataClassJsonMixin):
class SparkSubmissionDetails(DataClassJsonMixin):
"""
Reference to another SparkJob.
Job runtime details
"""

api_group: str
kind: str
name: str


@dataclass_json(letter_case=LetterCase.CAMEL)
@dataclass
class SparkSubmissionConfiguration(DataClassJsonMixin):
"""
Configuration CRD used by Beast to run Spark apps.
"""

root_path: str
project_name: str
version: str
runnable: str
execution_group: str
expected_parallelism: Optional[int]
flexible_driver: Optional[bool]
additional_driver_node_tolerations: Dict[str, str]
max_runtime_hours: Optional[int]
debug_mode: RequestDebugMode
debug_mode: Optional[RequestDebugMode]
submission_mode: Optional[str]
extended_code_mount: Optional[bool]
submission_job_template: str
Expand All @@ -239,5 +224,17 @@ class SparkSubmissionConfiguration(DataClassJsonMixin):
default_arguments: Dict[str, str]
inputs: List[JobSocket]
outputs: List[JobSocket]
overwrite: bool
base_submission_configuration_ref: V1TypedLocalObjectReference
overwrite: Optional[bool]


@dataclass_json(letter_case=LetterCase.CAMEL)
@dataclass
class SparkSubmissionConfiguration(DataClassJsonMixin):
"""
Configuration CRD used by Beast to run Spark apps.
"""

root_path: str
project_name: str
runnable: str
submission_details: SparkSubmissionDetails