Skip to content

Commit 6a600e1

Browse files
authored
make graphviz-rust optional component (#1203)
1 parent fdd3e94 commit 6a600e1

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

ballista/scheduler/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ required-features = ["build-binary"]
3838
build-binary = ["configure_me", "clap", "tracing-subscriber", "tracing-appender", "tracing", "ballista-core/build-binary"]
3939
default = ["build-binary"]
4040
flight-sql = ["base64"]
41+
graphviz-support = ["dep:graphviz-rust"]
4142
keda-scaler = []
4243
prometheus-metrics = ["prometheus", "once_cell"]
43-
rest-api = ["graphviz-rust"]
44+
rest-api = []
4445

4546
[dependencies]
4647
arrow-flight = { workspace = true }

ballista/scheduler/src/api/handlers.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ use ballista_core::BALLISTA_VERSION;
2424
use datafusion::physical_plan::metrics::{MetricValue, MetricsSet, Time};
2525
use datafusion_proto::logical_plan::AsLogicalPlan;
2626
use datafusion_proto::physical_plan::AsExecutionPlan;
27-
use graphviz_rust::cmd::{CommandArg, Format};
28-
use graphviz_rust::exec;
29-
use graphviz_rust::printer::PrinterContext;
27+
#[cfg(feature = "graphviz-support")]
28+
use graphviz_rust::{
29+
cmd::{CommandArg, Format},
30+
exec,
31+
printer::PrinterContext,
32+
};
3033
use http::{header::CONTENT_TYPE, StatusCode};
3134
use std::sync::Arc;
3235
use std::time::Duration;
@@ -342,7 +345,7 @@ pub async fn get_query_stage_dot_graph<
342345
Ok("Not Found".to_string())
343346
}
344347
}
345-
348+
#[cfg(feature = "graphviz-support")]
346349
pub async fn get_job_svg_graph<
347350
T: AsLogicalPlan + Clone + Send + Sync + 'static,
348351
U: AsExecutionPlan + Send + Sync + 'static,

ballista/scheduler/src/api/mod.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn get_routes<
2525
>(
2626
scheduler_server: Arc<SchedulerServer<T, U>>,
2727
) -> Router {
28-
Router::new()
28+
let router = Router::new()
2929
.route("/api/state", get(handlers::get_scheduler_state::<T, U>))
3030
.route("/api/executors", get(handlers::get_executors::<T, U>))
3131
.route("/api/jobs", get(handlers::get_jobs::<T, U>))
@@ -42,10 +42,13 @@ pub fn get_routes<
4242
"/api/job/:job_id/stage/:stage_id/dot",
4343
get(handlers::get_query_stage_dot_graph::<T, U>),
4444
)
45-
.route(
46-
"/api/job/:job_id/dot_svg",
47-
get(handlers::get_job_svg_graph::<T, U>),
48-
)
49-
.route("/api/metrics", get(handlers::get_scheduler_metrics::<T, U>))
50-
.with_state(scheduler_server)
45+
.route("/api/metrics", get(handlers::get_scheduler_metrics::<T, U>));
46+
47+
#[cfg(feature = "graphviz-support")]
48+
let router = router.route(
49+
"/api/job/:job_id/dot_svg",
50+
get(handlers::get_job_svg_graph::<T, U>),
51+
);
52+
53+
router.with_state(scheduler_server)
5154
}

docs/source/user-guide/scheduler.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ The scheduler also provides a REST API that allows jobs to be monitored.
2525

2626
> This is optional scheduler feature which should be enabled with `rest-api` feature
2727
28-
| API | Method | Description |
29-
| --------------------- | ------ | ----------------------------------------------------------- |
30-
| /api/jobs | GET | Get a list of jobs that have been submitted to the cluster. |
31-
| /api/job/{job_id} | GET | Get a summary of a submitted job. |
32-
| /api/job/{job_id}/dot | GET | Produce a query plan in DOT (graphviz) format. |
33-
| /api/job/{job_id} | PATCH | Cancel a currently running job |
34-
| /api/metrics | GET | Return current scheduler metric set |
28+
| API | Method | Description |
29+
| ------------------------------------ | ------ | ----------------------------------------------------------------- |
30+
| /api/jobs | GET | Get a list of jobs that have been submitted to the cluster. |
31+
| /api/job/{job_id} | GET | Get a summary of a submitted job. |
32+
| /api/job/{job_id}/dot | GET | Produce a query plan in DOT (graphviz) format. |
33+
| /api/job/:job_id/dot_svg | GET | Produce a query plan in SVG format. (`graphviz-support` required) |
34+
| /api/job/{job_id} | PATCH | Cancel a currently running job |
35+
| /api/job/:job_id/stage/:stage_id/dot | GET | Produces stage plan in DOT (graphviz) format |
36+
| /api/metrics | GET | Return current scheduler metric set |

0 commit comments

Comments
 (0)