Skip to content
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
11 changes: 11 additions & 0 deletions src/blaxel/core/client/models/create_job_execution_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class CreateJobExecutionRequest:
"""Request to create a job execution

Attributes:
allow_queue (Union[Unset, bool]): When false, capacity is checked synchronously and the request is rejected
immediately with a 429 error if the execution cannot start right now, instead of being queued and retried in the
background. No execution is created on rejection. Defaults to true (queue and retry).
env (Union[Unset, CreateJobExecutionRequestEnv]): Environment variable overrides (optional, will merge with
job's environment variables) Example: {"MY_VAR": "custom_value", "BATCH_SIZE": "100"}.
execution_id (Union[Unset, str]): Execution ID (optional, will be generated if not provided)
Expand All @@ -30,6 +33,7 @@ class CreateJobExecutionRequest:
workspace_id (Union[Unset, str]): Workspace ID
"""

allow_queue: Union[Unset, bool] = UNSET
env: Union[Unset, "CreateJobExecutionRequestEnv"] = UNSET
execution_id: Union[Unset, str] = UNSET
id: Union[Unset, str] = UNSET
Expand All @@ -41,6 +45,8 @@ class CreateJobExecutionRequest:

def to_dict(self) -> dict[str, Any]:

allow_queue = self.allow_queue

env: Union[Unset, dict[str, Any]] = UNSET
if self.env and not isinstance(self.env, Unset) and not isinstance(self.env, dict):
env = self.env.to_dict()
Expand Down Expand Up @@ -70,6 +76,8 @@ def to_dict(self) -> dict[str, Any]:
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if allow_queue is not UNSET:
field_dict["allowQueue"] = allow_queue
if env is not UNSET:
field_dict["env"] = env
if execution_id is not UNSET:
Expand Down Expand Up @@ -97,6 +105,8 @@ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T | None:
if not src_dict:
return None
d = src_dict.copy()
allow_queue = d.pop("allowQueue", d.pop("allow_queue", UNSET))

_env = d.pop("env", UNSET)
env: Union[Unset, CreateJobExecutionRequestEnv]
if isinstance(_env, Unset):
Expand All @@ -122,6 +132,7 @@ def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T | None:
workspace_id = d.pop("workspaceId", d.pop("workspace_id", UNSET))

create_job_execution_request = cls(
allow_queue=allow_queue,
env=env,
execution_id=execution_id,
id=id,
Expand Down
14 changes: 14 additions & 0 deletions src/blaxel/core/jobs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def run(
env: Dict[str, str] | None = None,
memory: int | None = None,
execution_id: str | None = None,
allow_queue: bool | None = None,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 New allow_queue feature ships without an integration test

AGENTS.md requires every feature to ship with an integration test against the real API. The new allow_queue parameter on run/arun has no test in tests/integration/core/jobs/test_jobs.py, unlike the existing memory and env overrides.

Prompt for agents
AGENTS.md states every feature must ship with an integration test exercising it against the real API. The new allow_queue option added to BlJob.run and BlJob.arun (and the CreateJobExecutionRequest model) has no integration test. Add a test in tests/integration/core/jobs/test_jobs.py that runs a job with allow_queue=False (and/or True), following the existing patterns like test_run_job_with_memory_override, including the not-found skip handling.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in follow-up PR #227 (this PR was already merged): adds test_run_job_with_allow_queue_false to tests/integration/core/jobs/test_jobs.py, treating an immediate 429 as the expected no-capacity rejection.

) -> str:
"""
Run the job with the provided tasks and optional overrides.
Expand All @@ -95,6 +96,10 @@ def run(
env: Optional environment variable overrides (merged with job's environment)
memory: Optional memory override in megabytes (must be <= job's configured memory)
execution_id: Optional custom execution ID
allow_queue: When False, capacity is checked synchronously and the request is
rejected immediately with a 429 error if the execution cannot start right
now, instead of being queued and retried in the background. Omitted or
True keeps the queue-and-retry behavior.

Returns:
str: The execution ID
Expand All @@ -111,6 +116,8 @@ def run(
request.memory = memory
if execution_id is not None:
request.execution_id = execution_id
if allow_queue is not None:
request.allow_queue = allow_queue

return self.create_execution(request)

Expand All @@ -120,6 +127,7 @@ async def arun(
env: Dict[str, str] | None = None,
memory: int | None = None,
execution_id: str | None = None,
allow_queue: bool | None = None,
) -> str:
"""
Run the job with the provided tasks and optional overrides (async).
Expand All @@ -129,6 +137,10 @@ async def arun(
env: Optional environment variable overrides (merged with job's environment)
memory: Optional memory override in megabytes (must be <= job's configured memory)
execution_id: Optional custom execution ID
allow_queue: When False, capacity is checked synchronously and the request is
rejected immediately with a 429 error if the execution cannot start right
now, instead of being queued and retried in the background. Omitted or
True keeps the queue-and-retry behavior.

Returns:
str: The execution ID
Expand All @@ -145,6 +157,8 @@ async def arun(
request.memory = memory
if execution_id is not None:
request.execution_id = execution_id
if allow_queue is not None:
request.allow_queue = allow_queue

return await self.acreate_execution(request)

Expand Down
Loading