Skip to content

Commit

Permalink
chore: add a compile cfg for python in cmd package (#4406)
Browse files Browse the repository at this point in the history
* chore: add a compile cfg for python

* fix: feature gate additive turn off default features in workspace&add cfg in place

* chore: remove unused in different cfg
  • Loading branch information
discord9 authored Jul 24, 2024
1 parent 918be09 commit 024dac8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ auth = { path = "src/auth" }
cache = { path = "src/cache" }
catalog = { path = "src/catalog" }
client = { path = "src/client" }
cmd = { path = "src/cmd" }
cmd = { path = "src/cmd", default-features = false }
common-base = { path = "src/common/base" }
common-catalog = { path = "src/common/catalog" }
common-config = { path = "src/common/config" }
Expand Down Expand Up @@ -213,7 +213,7 @@ datanode = { path = "src/datanode" }
datatypes = { path = "src/datatypes" }
file-engine = { path = "src/file-engine" }
flow = { path = "src/flow" }
frontend = { path = "src/frontend" }
frontend = { path = "src/frontend", default-features = false }
index = { path = "src/index" }
log-store = { path = "src/log-store" }
meta-client = { path = "src/meta-client" }
Expand Down
4 changes: 3 additions & 1 deletion src/cmd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ name = "greptime"
path = "src/bin/greptime.rs"

[features]
default = ["python"]
tokio-console = ["common-telemetry/tokio-console"]
python = ["frontend/python"]

[lints]
workspace = true
Expand Down Expand Up @@ -47,7 +49,7 @@ either = "1.8"
etcd-client.workspace = true
file-engine.workspace = true
flow.workspace = true
frontend.workspace = true
frontend = { workspace = true, default-features = false }
futures.workspace = true
human-panic = "1.2.2"
lazy_static.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ pub enum Error {
location: Location,
},

#[cfg(feature = "python")]
#[snafu(display("Failed to start script manager"))]
StartScriptManager {
#[snafu(implicit)]
Expand Down Expand Up @@ -438,6 +439,7 @@ impl ErrorExt for Error {
Error::External { source, .. } => source.status_code(),
Error::FindTableRoute { source, .. } => source.status_code(),

#[cfg(feature = "python")]
Error::StartScriptManager { source, .. } => source.status_code(),

Error::TableOperation { source, .. } => source.status_code(),
Expand Down
19 changes: 9 additions & 10 deletions src/frontend/src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@
// limitations under the License.

use std::collections::HashMap;
use std::sync::Arc;

use catalog::CatalogManagerRef;
use common_error::ext::ErrorExt;
use common_query::Output;
use query::QueryEngineRef;
use servers::query_handler::grpc::GrpcQueryHandler;
use session::context::QueryContextRef;

use crate::error::{Error, Result};

type FrontendGrpcQueryHandlerRef = Arc<dyn GrpcQueryHandler<Error = Error> + Send + Sync>;
use crate::error::Result;
use crate::instance::Instance;

#[cfg(not(feature = "python"))]
mod dummy {
Expand All @@ -40,7 +36,7 @@ mod dummy {
Ok(Self {})
}

pub fn start(&self, instance: &Instance) -> Result<()> {
pub fn start(&self, _instance: &Instance) -> Result<()> {
Ok(())
}

Expand All @@ -66,12 +62,14 @@ mod dummy {

#[cfg(feature = "python")]
mod python {
use std::sync::Arc;

use api::v1::ddl_request::Expr;
use api::v1::greptime_request::Request;
use api::v1::DdlRequest;
use arc_swap::ArcSwap;
use catalog::RegisterSystemTableRequest;
use common_error::ext::BoxedError;
use common_error::ext::{BoxedError, ErrorExt};
use common_telemetry::{error, info};
use script::manager::ScriptManager;
use servers::query_handler::grpc::GrpcQueryHandler;
Expand All @@ -80,8 +78,9 @@ mod python {
use table::table_name::TableName;

use super::*;
use crate::error::{CatalogSnafu, TableNotFoundSnafu};
use crate::instance::Instance;
use crate::error::{CatalogSnafu, Error, TableNotFoundSnafu};

type FrontendGrpcQueryHandlerRef = Arc<dyn GrpcQueryHandler<Error = Error> + Send + Sync>;

/// A placeholder for the real gRPC handler.
/// It is temporary and will be replaced soon.
Expand Down

0 comments on commit 024dac8

Please sign in to comment.