Skip to content

Commit 05c3ecf

Browse files
authored
Update bencher CLI to handle remote jobs (#672)
This changeset introduces the concept of a remote job to the `bencher` CLI. The `runner` CLI has also been updated to better match the conventions of the `bencher` CLI.
1 parent 1e1c3f7 commit 05c3ecf

51 files changed

Lines changed: 1848 additions & 464 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ The API server includes an OCI Distribution Spec compliant container registry, r
199199
- Use `clap` for CLI argument parsing
200200
- The `clap` struct definitions should live in a separate `parser` module
201201
- The subcommand handler logic should live in a separate module named after the binary for production code (ie `bencher`) or a module named `task` for `tasks/*` crates
202+
- Do **NOT** use `num_args` on flags in `bencher run` — it uses `trailing_var_arg = true` to match `docker run` semantics, and `num_args` conflicts with trailing vararg parsing. Validate collection sizes at the type/deserialization layer instead (e.g., `TryFrom` impls in `bencher_json`).
202203

203204
### Frontend (TypeScript)
204205

Cargo.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ bencher_context = { path = "lib/bencher_context" }
3232
bencher_endpoint = { path = "lib/bencher_endpoint" }
3333
bencher_json = { path = "lib/bencher_json" }
3434
bencher_logger = { path = "lib/bencher_logger" }
35+
bencher_parser = { path = "lib/bencher_parser" }
3536
bencher_plot = { path = "lib/bencher_plot" }
3637
bencher_rank = { path = "lib/bencher_rank" }
3738
bencher_rbac = { path = "lib/bencher_rbac" }

lib/bencher_client/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ from_client!(
7575
Entitlements,
7676
ExpirationMonth,
7777
ExpirationYear,
78-
JobUuid
78+
ImageReference,
79+
JobUuid,
80+
Timeout
7981
);
8082

8183
#[cfg(feature = "plus")]

lib/bencher_json/src/lib.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ pub use bencher_valid::{
1010
#[cfg(feature = "plus")]
1111
pub use bencher_valid::{
1212
CardBrand, CardCvc, CardNumber, Cpu, Disk, Entitlements, ExpirationMonth, ExpirationYear,
13-
GracePeriod, ImageDigest, LastFour, LicensedPlanId, Memory, MeteredPlanId, PlanLevel,
14-
PlanStatus, RecaptchaAction, RecaptchaScore, Timeout,
13+
GracePeriod, ImageDigest, ImageReference, LastFour, LicensedPlanId, Memory, MeteredPlanId,
14+
PlanLevel, PlanStatus, RecaptchaAction, RecaptchaScore, Timeout,
1515
};
1616
#[cfg(feature = "schema")]
1717
use schemars::JsonSchema;
@@ -89,8 +89,9 @@ pub use run::JsonNewRun;
8989
#[cfg(feature = "plus")]
9090
pub use runner::{
9191
DEFAULT_POLL_TIMEOUT, JobPriority, JobStatus, JobUuid, JsonClaimJob, JsonClaimedJob, JsonJob,
92-
JsonJobConfig, JsonJobs, JsonNewRunner, JsonRunner, JsonRunnerToken, JsonRunners,
93-
JsonUpdateRunner, MAX_POLL_TIMEOUT, MIN_POLL_TIMEOUT, RunnerResourceId, RunnerSlug, RunnerUuid,
92+
JsonJobConfig, JsonJobs, JsonNewRunJob, JsonNewRunner, JsonRunner, JsonRunnerToken,
93+
JsonRunners, JsonUpdateRunner, MAX_POLL_TIMEOUT, MIN_POLL_TIMEOUT, RunnerResourceId,
94+
RunnerSlug, RunnerUuid,
9495
};
9596
#[cfg(feature = "plus")]
9697
pub use spec::{
@@ -201,6 +202,15 @@ pub static PROD_BENCHER_API_URL: LazyLock<url::Url> = LazyLock::new(|| {
201202
.unwrap_or_else(|e| panic!("Failed to parse endpoint \"{PROD_BENCHER_API_URL_STR}\": {e}"))
202203
});
203204

205+
/// Maximum number of entrypoint arguments in a job config.
206+
pub const MAX_ENTRYPOINT_LEN: usize = 64;
207+
/// Maximum number of cmd arguments in a job config.
208+
pub const MAX_CMD_LEN: usize = 64;
209+
/// Maximum number of file paths in a job config.
210+
pub const MAX_FILE_PATHS_LEN: usize = 255;
211+
/// Maximum number of environment variables in a job config.
212+
pub const MAX_ENV_LEN: usize = 255;
213+
204214
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
205215
#[cfg_attr(feature = "schema", derive(JsonSchema))]
206216
pub struct JsonAny {}

lib/bencher_json/src/run.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ use crate::{
1212
},
1313
};
1414

15+
#[cfg(feature = "plus")]
16+
use crate::runner::job::JsonNewRunJob;
17+
1518
#[cfg(feature = "server")]
1619
use crate::{
1720
JsonNewReport,
@@ -59,6 +62,11 @@ pub struct JsonNewRun {
5962
pub settings: Option<JsonReportSettings>,
6063
/// Context for the report.
6164
pub context: Option<RunContext>,
65+
/// Runner job configuration. When present, the run is executed
66+
/// on a remote bare metal runner instead of locally.
67+
#[cfg(feature = "plus")]
68+
#[serde(default, skip_serializing_if = "Option::is_none")]
69+
pub job: Option<JsonNewRunJob>,
6270
}
6371

6472
#[cfg(feature = "server")]
@@ -76,6 +84,8 @@ impl From<JsonNewRun> for JsonNewReport {
7684
results,
7785
settings,
7886
context,
87+
#[cfg(feature = "plus")]
88+
job: _,
7989
} = run;
8090
let branch = branch
8191
.or_else(|| {

0 commit comments

Comments
 (0)