Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Explorer: Synchronize generated comms with upstream changes #643

Merged
merged 2 commits into from
Nov 26, 2024
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
35 changes: 34 additions & 1 deletion crates/amalthea/src/comm/data_explorer_comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
use serde::Deserialize;
use serde::Serialize;

/// Result in Methods
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct OpenDatasetResult {
/// An error message if opening the dataset failed
pub error_message: Option<String>
}

/// Result in Methods
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct SearchSchemaResult {
Expand Down Expand Up @@ -67,7 +74,15 @@ pub struct BackendState {
pub sort_keys: Vec<ColumnSortKey>,

/// The features currently supported by the backend instance
pub supported_features: SupportedFeatures
pub supported_features: SupportedFeatures,

/// Optional flag allowing backend to report that it is unable to serve
/// requests. This parameter may change.
pub connected: Option<bool>,

/// Optional experimental parameter to provide an explanation when
/// connected=false. This parameter may change.
pub error_message: Option<String>
}

/// Schema for a column in a table
Expand Down Expand Up @@ -985,6 +1000,13 @@ pub enum ArraySelection {
SelectIndices(DataSelectionIndices)
}

/// Parameters for the OpenDataset method.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct OpenDatasetParams {
/// The resource locator or file path
pub uri: String,
}

/// Parameters for the GetSchema method.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct GetSchemaParams {
Expand Down Expand Up @@ -1079,6 +1101,9 @@ pub struct ReturnColumnProfilesParams {

/// Array of individual column profile results
pub profiles: Vec<ColumnProfileResult>,

/// Optional error message if something failed to compute
pub error_message: Option<String>,
}

/**
Expand All @@ -1087,6 +1112,12 @@ pub struct ReturnColumnProfilesParams {
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(tag = "method", content = "params")]
pub enum DataExplorerBackendRequest {
/// Request to open a dataset given a URI
///
/// Request to open a dataset given a URI
#[serde(rename = "open_dataset")]
OpenDataset(OpenDatasetParams),

/// Request schema
///
/// Request subset of column schemas for a table-like object
Expand Down Expand Up @@ -1160,6 +1191,8 @@ pub enum DataExplorerBackendRequest {
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(tag = "method", content = "result")]
pub enum DataExplorerBackendReply {
OpenDatasetReply(OpenDatasetResult),

GetSchemaReply(TableSchema),

SearchSchemaReply(SearchSchemaResult),
Expand Down
1 change: 1 addition & 0 deletions crates/ark/src/data_explorer/column_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub async fn handle_columns_profiles_requests(
let event = DataExplorerFrontendEvent::ReturnColumnProfiles(ReturnColumnProfilesParams {
callback_id,
profiles,
error_message: None,
});

let json_event = serde_json::to_value(event)?;
Expand Down
6 changes: 6 additions & 0 deletions crates/ark/src/data_explorer/r_data_explorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,10 @@ impl RDataExplorer {

DataExplorerBackendRequest::GetState => r_task(|| self.r_get_state()),

DataExplorerBackendRequest::OpenDataset(_) => {
return Err(anyhow!("Data Explorer: Not yet supported"));
},

DataExplorerBackendRequest::SearchSchema(_) => {
return Err(anyhow!("Data Explorer: Not yet supported"));
},
Expand Down Expand Up @@ -873,6 +877,8 @@ impl RDataExplorer {
fn r_get_state(&self) -> anyhow::Result<DataExplorerBackendReply> {
let state = BackendState {
display_name: self.title.clone(),
connected: Some(true),
error_message: None,
table_shape: TableShape {
num_rows: match self.filtered_indices {
Some(ref indices) => indices.len() as i64,
Expand Down
Loading