Skip to content

Commit

Permalink
Run Format/lint scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
marwan37 committed Apr 3, 2024
1 parent 783b3e8 commit a9eca07
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 72 deletions.
13 changes: 10 additions & 3 deletions src/commands/pipelines/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ export const registerPipelineCommands = (context: ExtensionContext) => {
'zenml.deletePipelineRun',
async (node: PipelineTreeItem) => await pipelineCommands.deletePipelineRun(node)
),
registerCommand('zenml.nextPipelineRunsPage', async () => pipelineDataProvider.goToNextPage()),
registerCommand('zenml.previousPipelineRunsPage', async () => pipelineDataProvider.goToPreviousPage()),
registerCommand("zenml.setPipelineRunsPerPage", async () => await pipelineDataProvider.updateItemsPerPage()),
registerCommand('zenml.nextPipelineRunsPage', async () =>
pipelineDataProvider.goToNextPage()
),
registerCommand('zenml.previousPipelineRunsPage', async () =>
pipelineDataProvider.goToPreviousPage()
),
registerCommand(
'zenml.setPipelineRunsPerPage',
async () => await pipelineDataProvider.updateItemsPerPage()
),
];

registeredCommands.forEach(cmd => {
Expand Down
5 changes: 4 additions & 1 deletion src/commands/stack/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export const registerStackCommands = (context: ExtensionContext) => {
const stackDataProvider = StackDataProvider.getInstance();
try {
const registeredCommands = [
registerCommand("zenml.setStackItemsPerPage", async () => await stackDataProvider.updateItemsPerPage()),
registerCommand(
'zenml.setStackItemsPerPage',
async () => await stackDataProvider.updateItemsPerPage()
),
registerCommand('zenml.refreshStackView', async () => await stackCommands.refreshStackView()),
registerCommand(
'zenml.refreshActiveStack',
Expand Down
22 changes: 11 additions & 11 deletions src/common/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function getPythonExtensionAPI(): Promise<PythonExtension | undefined> {

/**
* Initialize the python extension.
*
*
* @param disposables - List of disposables to be disposed when the extension is deactivated.
*/
export async function initializePython(disposables: Disposable[]): Promise<void> {
Expand All @@ -57,12 +57,12 @@ export async function initializePython(disposables: Disposable[]): Promise<void>
}
}

/**
/**
* Resolve the python interpreter.
*
*
* @param interpreter - The interpreter to resolve.
* @returns The resolved environment.
*/
*/
export async function resolveInterpreter(
interpreter: string[]
): Promise<ResolvedEnvironment | undefined> {
Expand All @@ -72,7 +72,7 @@ export async function resolveInterpreter(

/**
* Get the interpreter details.
*
*
* @param resource - The resource to get the interpreter details from.
* @returns The interpreter details.
*/
Expand All @@ -89,7 +89,7 @@ export async function getInterpreterDetails(resource?: Uri): Promise<IInterprete

/**
* Get the path to the debugger.
*
*
* @returns The path to the debugger.
*/
export async function getDebuggerPath(): Promise<string | undefined> {
Expand All @@ -99,7 +99,7 @@ export async function getDebuggerPath(): Promise<string | undefined> {

/**
* Run a python extension command.
*
*
* @param command - The command to run.
* @param rest - The rest of the arguments.
* @returns The result of the command.
Expand All @@ -111,7 +111,7 @@ export async function runPythonExtensionCommand(command: string, ...rest: any[])

/**
* Check if the python version is supported.
*
*
* @param resolved - The resolved environment.
* @returns True if the version is supported, false otherwise.
*/
Expand All @@ -127,12 +127,12 @@ export function checkVersion(resolved: ResolvedEnvironment | undefined): boolean
return false;
}

/**
/**
* Check if the python version is supported.
*
*
* @param resolvedEnv - The resolved environment.
* @returns An object with the result and an optional message.
*/
*/
export function isPythonVersionSupported(resolvedEnv: ResolvedEnvironment | undefined): {
isSupported: boolean;
message?: string;
Expand Down
4 changes: 2 additions & 2 deletions src/services/ZenExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { registerLogger, traceLog, traceVerbose } from '../common/log/logging';
import {
IInterpreterDetails,
initializePython,
isPythonVersonSupported,
isPythonVersionSupported,
onDidChangePythonInterpreter,
resolveInterpreter,
} from '../common/python';
Expand Down Expand Up @@ -132,7 +132,7 @@ export class ZenExtension {
this.interpreterCheckInProgress = true;
if (interpreterDetails.path) {
const resolvedEnv = await resolveInterpreter(interpreterDetails.path);
const { isSupported, message } = isPythonVersonSupported(resolvedEnv);
const { isSupported, message } = isPythonVersionSupported(resolvedEnv);
if (!isSupported) {
vscode.window.showErrorMessage(`Interpreter not supported: ${message}`);
this.interpreterCheckInProgress = false;
Expand Down
1 change: 0 additions & 1 deletion src/types/PipelineTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import { ErrorMessageResponse, VersionMismatchError } from './LSClientResponseTypes';


interface PipelineRunsData {
runs: PipelineRun[];
total: number;
Expand Down
2 changes: 1 addition & 1 deletion src/types/StackTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ interface StackComponent {
type: string;
}

export type StacksReponse = StacksData | ErrorMessageResponse | VersionMismatchError;
export type StacksResponse = StacksData | ErrorMessageResponse | VersionMismatchError;

export { Stack, Components, StackComponent, StacksData };
10 changes: 5 additions & 5 deletions src/views/activityBar/common/ErrorTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ export const createErrorItem = (error: any): TreeItem[] => {

/**
* Creates an error item for authentication errors.
*
*
* @param errorMessage The error message to parse.
* @returns The error tree item(s),
*/
export const createAuthErrorItem = (errorMessage: string): ErrorTreeItem[] => {
const parts = errorMessage.split(':').map(part => part.trim());

let generalError = "";
let detailedError = "";
let actionSuggestion = "";
let generalError = '';
let detailedError = '';
let actionSuggestion = '';

if (parts.length > 2) {
generalError = parts[0]; // "Failed to retrieve pipeline runs"
Expand All @@ -76,4 +76,4 @@ export const createAuthErrorItem = (errorMessage: string): ErrorTreeItem[] => {
}

return errorItems;
}
};
8 changes: 4 additions & 4 deletions src/views/activityBar/common/PaginationTreeItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export class CommandTreeItem extends TreeItem {

export class SetItemsPerPageTreeItem extends TreeItem {
constructor() {
super("Set items per page", TreeItemCollapsibleState.None);
this.tooltip = "Click to set the number of items shown per page";
super('Set items per page', TreeItemCollapsibleState.None);
this.tooltip = 'Click to set the number of items shown per page';
this.command = {
command: "zenml.setStacksPerPage",
title: "Set Stack Items Per Page",
command: 'zenml.setStacksPerPage',
title: 'Set Stack Items Per Page',
arguments: [],
};
}
Expand Down
12 changes: 8 additions & 4 deletions src/views/activityBar/environmentView/EnvironmentDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
import { EventEmitter, TreeDataProvider, TreeItem } from 'vscode';
import { State } from 'vscode-languageclient';
import { EventBus } from '../../../services/EventBus';
import { LSCLIENT_STATE_CHANGED, LSP_IS_ZENML_INSTALLED, REFRESH_ENVIRONMENT_VIEW, LSP_ZENML_CLIENT_INITIALIZED } from '../../../utils/constants';
import {
LSCLIENT_STATE_CHANGED,
LSP_IS_ZENML_INSTALLED,
REFRESH_ENVIRONMENT_VIEW,
LSP_ZENML_CLIENT_INITIALIZED,
} from '../../../utils/constants';
import { EnvironmentItem } from './EnvironmentItem';
import {
createInterpreterDetails,
Expand Down Expand Up @@ -46,7 +51,6 @@ export class EnvironmentDataProvider implements TreeDataProvider<TreeItem> {
this.eventBus.on(REFRESH_ENVIRONMENT_VIEW, this.refresh.bind(this));
}


/**
* Retrieves the singleton instance of ServerDataProvider.
*
Expand All @@ -60,8 +64,8 @@ export class EnvironmentDataProvider implements TreeDataProvider<TreeItem> {
}

/**
* Explicitly trigger loading state for ZenML installation check and ZenML client initialization.
*/
* Explicitly trigger loading state for ZenML installation check and ZenML client initialization.
*/
private triggerLoadingStateForZenMLChecks() {
this.zenmlClientReady = false;
this.zenmlInstallationStatus = null;
Expand Down
13 changes: 7 additions & 6 deletions src/views/activityBar/environmentView/viewHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export function createLSClientItem(lsClientStatus: State): EnvironmentItem {
[State.Stopped]: { description: 'Stopped', icon: 'close' },
};


const { description, icon } = statusMappings[lsClientStatus];

return new EnvironmentItem(
Expand All @@ -52,7 +51,6 @@ export function createLSClientItem(lsClientStatus: State): EnvironmentItem {
export function createZenMLClientStatusItem(zenmlClientReady: boolean): EnvironmentItem {
const localZenML = LSClient.getInstance().localZenML;


const zenMLClientStatusItem = new EnvironmentItem(
'ZenML Client',
!localZenML.is_installed ? '' : zenmlClientReady ? 'Initialized' : 'Awaiting Initialization',
Expand All @@ -65,11 +63,13 @@ export function createZenMLClientStatusItem(zenmlClientReady: boolean): Environm

/**
* Creates the ZenML installation item for the environment view.
*
*
* @param installationStatus The installation status of ZenML.
* @returns {EnvironmentItem} The ZenML installation item.
*/
export function createZenMLInstallationItem(installationStatus: LSNotificationIsZenMLInstalled | null): EnvironmentItem {
export function createZenMLInstallationItem(
installationStatus: LSNotificationIsZenMLInstalled | null
): EnvironmentItem {
if (!installationStatus) {
return new EnvironmentItem(
'ZenML Local Installation',
Expand All @@ -79,7 +79,9 @@ export function createZenMLInstallationItem(installationStatus: LSNotificationIs
);
}

const description = installationStatus.is_installed ? `Installed (v${installationStatus.version})` : 'Not Installed';
const description = installationStatus.is_installed
? `Installed (v${installationStatus.version})`
: 'Not Installed';
const icon = installationStatus.is_installed ? 'check' : 'warning';

return new EnvironmentItem(
Expand All @@ -90,7 +92,6 @@ export function createZenMLInstallationItem(installationStatus: LSNotificationIs
);
}


/**
* Creates the workspace settings items for the environment view.
*
Expand Down
41 changes: 31 additions & 10 deletions src/views/activityBar/pipelineView/PipelineDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export class PipelineDataProvider implements TreeDataProvider<TreeItem> {
totalPages: 0,
};


constructor() {
this.subscribeToEvents();
}
Expand Down Expand Up @@ -133,12 +132,29 @@ export class PipelineDataProvider implements TreeDataProvider<TreeItem> {
return this.pipelineRuns;
}

const runs = await this.fetchPipelineRuns(this.pagination.currentPage, this.pagination.itemsPerPage);
const runs = await this.fetchPipelineRuns(
this.pagination.currentPage,
this.pagination.itemsPerPage
);
if (this.pagination.currentPage < this.pagination.totalPages) {
runs.push(new CommandTreeItem("Next Page", 'zenml.nextPipelineRunsPage', undefined, 'arrow-circle-right'));
runs.push(
new CommandTreeItem(
'Next Page',
'zenml.nextPipelineRunsPage',
undefined,
'arrow-circle-right'
)
);
}
if (this.pagination.currentPage > 1) {
runs.unshift(new CommandTreeItem("Previous Page", 'zenml.previousPipelineRunsPage', undefined, 'arrow-circle-left'));
runs.unshift(
new CommandTreeItem(
'Previous Page',
'zenml.previousPipelineRunsPage',
undefined,
'arrow-circle-left'
)
);
}
return runs;
} else if (element instanceof PipelineTreeItem) {
Expand All @@ -157,10 +173,10 @@ export class PipelineDataProvider implements TreeDataProvider<TreeItem> {
}
try {
const lsClient = LSClient.getInstance();
const result = await lsClient.sendLsClientRequest<PipelineRunsResponse>(
'getPipelineRuns',
[page, itemsPerPage]
);
const result = await lsClient.sendLsClientRequest<PipelineRunsResponse>('getPipelineRuns', [
page,
itemsPerPage,
]);

if (Array.isArray(result) && result.length === 1 && 'error' in result[0]) {
const errorMessage = result[0].error;
Expand Down Expand Up @@ -209,7 +225,12 @@ export class PipelineDataProvider implements TreeDataProvider<TreeItem> {
}
} catch (error: any) {
console.error(`Failed to fetch stacks: ${error}`);
return [new ErrorTreeItem("Error", `Failed to fetch pipeline runs: ${error.message || error.toString()}`)];
return [
new ErrorTreeItem(
'Error',
`Failed to fetch pipeline runs: ${error.message || error.toString()}`
),
];
}
}

Expand All @@ -229,7 +250,7 @@ export class PipelineDataProvider implements TreeDataProvider<TreeItem> {

public async updateItemsPerPage() {
const selected = await window.showQuickPick(ITEMS_PER_PAGE_OPTIONS, {
placeHolder: "Choose the max number of pipeline runs to display per page",
placeHolder: 'Choose the max number of pipeline runs to display per page',
});
if (selected) {
this.pagination.itemsPerPage = parseInt(selected, 10);
Expand Down
5 changes: 4 additions & 1 deletion src/views/activityBar/serverView/ServerDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ export class ServerDataProvider implements TreeDataProvider<TreeItem> {
getTreeItem(element: TreeItem): TreeItem {
if (element instanceof ServerTreeItem) {
if (element.serverStatus.isConnected) {
element.iconPath = new ThemeIcon('vm-active', new ThemeColor('gitDecoration.addedResourceForeground'));
element.iconPath = new ThemeIcon(
'vm-active',
new ThemeColor('gitDecoration.addedResourceForeground')
);
} else {
element.iconPath = new ThemeIcon('vm-connect');
}
Expand Down
14 changes: 10 additions & 4 deletions src/views/activityBar/serverView/ServerTreeItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ export class ServerTreeItem extends TreeItem {
children.push(new ServerDetailTreeItem('Username', this.serverStatus.username, 'account'));
}
if (this.serverStatus.debug !== undefined) {
children.push(new ServerDetailTreeItem('Debug', this.serverStatus.debug ? 'true' : 'false', 'bug'));
children.push(
new ServerDetailTreeItem('Debug', this.serverStatus.debug ? 'true' : 'false', 'bug')
);
}
if (this.serverStatus.auth_scheme) {
children.push(new ServerDetailTreeItem('Auth Scheme', this.serverStatus.auth_scheme, 'shield'));
children.push(
new ServerDetailTreeItem('Auth Scheme', this.serverStatus.auth_scheme, 'shield')
);
}
// Specific to SQL Server Status
if (this.serverStatus.database) {
Expand All @@ -97,11 +101,13 @@ export class ServerTreeItem extends TreeItem {
);
}
if (this.serverStatus.backup_strategy) {
children.push(new ServerDetailTreeItem('Backup Strategy', this.serverStatus.backup_strategy, 'shield'));
children.push(
new ServerDetailTreeItem('Backup Strategy', this.serverStatus.backup_strategy, 'shield')
);
}

return children;
}

contextValue = 'server';
}
}
Loading

0 comments on commit a9eca07

Please sign in to comment.