Skip to content

Commit

Permalink
data-server cli changed to use snake_case in response to start.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Dec 11, 2024
1 parent 6067624 commit 0196338
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 20 deletions.
4 changes: 2 additions & 2 deletions sema4ai/src/sema4ai_code/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,6 @@ class AuthConfigTypedDict(TypedDict):
class DataServerConfigTypedDict(TypedDict):
api: ApiConfigTypedDict
auth: AuthConfigTypedDict
isRunning: bool
is_running: bool
pid: int
pidFilePath: str
pid_file_path: str
8 changes: 4 additions & 4 deletions sema4ai/tests/sema4ai_code_tests/data_server_cli_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class AuthNamedTypedDict(TypedDict):
class LaunchJsonDataTypedDict(TypedDict):
api: ApiNamedTypedDict
auth: AuthNamedTypedDict
isRunning: bool
is_running: bool
pid: int
pidFilePath: str
pid_file_path: str


class LaunchJsonTypedDict(TypedDict):
Expand Down Expand Up @@ -90,9 +90,9 @@ class LaunchJsonTypedDict(TypedDict):
# "password": "",
# "username": "mindsdb"
# },
# "isRunning": true,
# "is_running": true,
# "pid": 14848,
# "pidFilePath": "%localappdata%\\sema4ai\\data-server\\data_server.pid"
# "pid_file_path": "%localappdata%\\sema4ai\\data-server\\data_server.pid"
# }
# }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ def create_setup_config(
"password": data_server_cli.get_password(),
"username": data_server_cli.get_username(),
},
"isRunning": True,
"is_running": True,
"pid": -1,
"pidFilePath": "",
"pid_file_path": "",
}
return data_server_info

Expand Down
4 changes: 2 additions & 2 deletions sema4ai/vscode-client/src/dataExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ export async function startDataServerAndGetInfo(): Promise<DataServerConfig | un
"showUIMessages": false,
})) as DataServerConfig | undefined;
if (dataServerInfo) {
if (!dataServerInfo.isRunning) {
if (!dataServerInfo.is_running) {
failWithErrorMessage(
dataServerInfo,
"After starting the data server, isRunning still returning false in provided data server config."
"After starting the data server, is_running still returning false in provided data server config."
);
return undefined;
}
Expand Down
49 changes: 41 additions & 8 deletions sema4ai/vscode-client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,19 @@ import * as path from "path";
import * as vscode from "vscode";
import * as cp from "child_process";

import { workspace, Disposable, ExtensionContext, window, commands, extensions, env, Uri } from "vscode";
import {
workspace,
Disposable,
ExtensionContext,
window,
commands,
extensions,
env,
Uri,
ProgressLocation,
Progress,
CancellationToken,
} from "vscode";
import { LanguageClientOptions, State } from "vscode-languageclient";
import { LanguageClient, ServerOptions } from "vscode-languageclient/node";
import * as playwright from "./playwright";
Expand Down Expand Up @@ -1026,9 +1038,20 @@ export async function dropDataSource(entry?: RobotEntry) {
if (!(await verifyDataExtensionIsInstalled())) {
return;
}
const dataServerStatus = await commands.executeCommand(DATA_SERVER_STATUS_COMMAND_ID);
const dataServerStatus = await window.withProgress(
{
location: ProgressLocation.Notification,
title: "Getting data server status...",
cancellable: false,
},
async (progress: Progress<{ message?: string; increment?: number }>, token: CancellationToken) => {
const dataServerStatus = await commands.executeCommand(DATA_SERVER_STATUS_COMMAND_ID);
return dataServerStatus;
}
);

if (!dataServerStatus["success"]) {
window.showErrorMessage("Unable to get the data server status.");
window.showErrorMessage("Unable to get the data server status. Please start the data server and try again.");
return;
}

Expand Down Expand Up @@ -1078,7 +1101,7 @@ export async function dropDataSource(entry?: RobotEntry) {
return;
}
const userChoice = await vscode.window.showWarningMessage(
`Are you sure you want to drop ${entry.label}?.`,
`Are you sure you want to drop ${entry.label}?`,
{ modal: true },
"Yes",
"No"
Expand All @@ -1088,10 +1111,20 @@ export async function dropDataSource(entry?: RobotEntry) {
}
}

const result = await langServer.sendRequest("dropDataSource", {
"datasource": datasource,
"data_server_info": dataServerStatus["data"],
});
const result = await window.withProgress(
{
location: ProgressLocation.Notification,
title: "Dropping Data Source...",
cancellable: false,
},
async (progress: Progress<{ message?: string; increment?: number }>, token: CancellationToken) => {
OUTPUT_CHANNEL.appendLine("Dropping Data Source: " + JSON.stringify(datasource));
return await langServer.sendRequest("dropDataSource", {
"datasource": datasource,
"data_server_info": dataServerStatus["data"],
});
}
);

if (!result["success"]) {
window.showErrorMessage(result["message"] || "Unknown error");
Expand Down
4 changes: 2 additions & 2 deletions sema4ai/vscode-client/src/robo/actionPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ export interface DataServerConfig {
password: string;
username: string;
};
isRunning: boolean;
is_running: boolean;
pid: number;
pidFilePath: string;
pid_file_path: string;
}

function convertDataServerInfoToEnvVar(dataServerInfo: DataServerConfig): string {
Expand Down

0 comments on commit 0196338

Please sign in to comment.