feat(submit): require explicit confirmation for all prepare_submit_job params
Remove defaults from queue, executor_memory, executor_cores, num_executors, and app_name in prepare_submit_job. All must now be explicitly confirmed by the caller. Also add extra_args to the PendingSubmission snapshot so users can confirm non-conf spark-submit flags (e.g. --jars, --py-files) at prepare time; confirm_submit_job passes them through to build_spark_submit_command. This is an intentional breaking change to the MCP tool contract: callers can no longer rely on implicit defaults.
This commit is contained in:
@@ -86,7 +86,7 @@ class Connection(BaseModel):
|
||||
|
||||
class PendingSubmission(BaseModel):
|
||||
pending_id: str
|
||||
app_name: str | None = None
|
||||
app_name: str
|
||||
connection: str
|
||||
master: str
|
||||
deploy_mode: str
|
||||
@@ -97,6 +97,7 @@ class PendingSubmission(BaseModel):
|
||||
executor_cores: int
|
||||
num_executors: int
|
||||
spark_conf: dict[str, str] = Field(default_factory=dict)
|
||||
extra_args: dict[str, str] = Field(default_factory=dict)
|
||||
created_at: datetime
|
||||
status: str = "PENDING" # PENDING | SUBMITTED | CANCELLED | FAILED
|
||||
error: str | None = None
|
||||
|
||||
@@ -33,9 +33,9 @@ class SaveConnectionRequest(BaseModel):
|
||||
|
||||
class PrepareSubmitJobRequest(BaseModel):
|
||||
connection: str
|
||||
app_name: str | None = Field(
|
||||
default=None,
|
||||
description="Optional human-readable application name for tracking the pending submission.",
|
||||
app_name: str = Field(
|
||||
...,
|
||||
description="Human-readable application name for tracking the pending submission.",
|
||||
)
|
||||
script_path: str = Field(
|
||||
...,
|
||||
@@ -49,10 +49,26 @@ class PrepareSubmitJobRequest(BaseModel):
|
||||
"if the path is missing or not a file."
|
||||
),
|
||||
)
|
||||
queue: str = "default"
|
||||
executor_memory: str = "4G"
|
||||
executor_cores: int = 2
|
||||
num_executors: int = 2
|
||||
queue: str = Field(
|
||||
...,
|
||||
description="YARN queue to submit to. Must be explicitly confirmed by the caller.",
|
||||
)
|
||||
executor_memory: str = Field(
|
||||
...,
|
||||
description="Executor memory, e.g. '4G'. Must be explicitly confirmed by the caller.",
|
||||
)
|
||||
executor_cores: int = Field(
|
||||
...,
|
||||
description="Number of cores per executor. Must be explicitly confirmed by the caller.",
|
||||
)
|
||||
num_executors: int = Field(
|
||||
...,
|
||||
description="Total number of executors. Must be explicitly confirmed by the caller.",
|
||||
)
|
||||
extra_args: dict[str, str] | None = Field(
|
||||
default=None,
|
||||
description="Additional spark-submit flags (e.g. jars, py-files) confirmed at prepare time.",
|
||||
)
|
||||
|
||||
|
||||
class PendingIdRequest(BaseModel):
|
||||
|
||||
@@ -64,17 +64,18 @@ def prepare_submit_job(
|
||||
*,
|
||||
connection: str,
|
||||
script_path: str,
|
||||
queue: str = "default",
|
||||
executor_memory: str = "4G",
|
||||
executor_cores: int = 2,
|
||||
num_executors: int = 2,
|
||||
app_name: str | None = None,
|
||||
queue: str,
|
||||
executor_memory: str,
|
||||
executor_cores: int,
|
||||
num_executors: int,
|
||||
app_name: str,
|
||||
extra_args: dict[str, str] | None = None,
|
||||
) -> dict[str, object]:
|
||||
"""Snapshot connection params and persist a PendingSubmission. Does NOT submit."""
|
||||
logger.debug(
|
||||
f"prepare_submit_job enter connection={connection} script_path={script_path} "
|
||||
f"queue={queue} executor_memory={executor_memory} executor_cores={executor_cores} "
|
||||
f"num_executors={num_executors}"
|
||||
f"num_executors={num_executors} app_name={app_name}"
|
||||
)
|
||||
# Order of checks matters for the error the agent sees:
|
||||
# 1. Unknown connection -> 404 (KeyError -> 404 in server.py)
|
||||
@@ -121,6 +122,7 @@ def prepare_submit_job(
|
||||
executor_cores=executor_cores,
|
||||
num_executors=num_executors,
|
||||
spark_conf=dict(conn.spark_conf),
|
||||
extra_args=dict(extra_args or {}),
|
||||
created_at=datetime.utcnow(),
|
||||
status="PENDING",
|
||||
)
|
||||
@@ -164,6 +166,7 @@ def confirm_submit_job(*, pending_id: str) -> SubmitResult:
|
||||
executor_cores=pending.executor_cores,
|
||||
num_executors=pending.num_executors,
|
||||
spark_conf=pending.spark_conf,
|
||||
extra_args=pending.extra_args,
|
||||
)
|
||||
logger.info(
|
||||
f"confirm_submit_job start pending_id={pending_id} "
|
||||
|
||||
Reference in New Issue
Block a user