Skip to content

Commit

Permalink
chore: replaced all mention of create with register
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher-R-Perkins committed Jul 24, 2024
1 parent a033c0f commit 6ed6acb
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 61 deletions.
16 changes: 8 additions & 8 deletions bundled/tool/lsp_zenml.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ def copy_stack(wrapper_instance, args):
"""Copies a specified ZenML stack to a new stack."""
return wrapper_instance.copy_stack(args)

@self.command(f"{TOOL_MODULE_NAME}.createStack")
@self.command(f"{TOOL_MODULE_NAME}.registerStack")
@self.zenml_command(wrapper_name="stacks_wrapper")
def create_stack(wrapper_instance, args):
"""Creates a new ZenML stack."""
return wrapper_instance.create_stack(args)
def register_stack(wrapper_instance, args):
"""Registers a new ZenML stack."""
return wrapper_instance.register_stack(args)

@self.command(f"{TOOL_MODULE_NAME}.updateStack")
@self.zenml_command(wrapper_name="stacks_wrapper")
Expand All @@ -296,11 +296,11 @@ def delete_stack(wrapper_instance, args):
"""Deletes a specified ZenML stack ."""
return wrapper_instance.delete_stack(args)

@self.command(f"{TOOL_MODULE_NAME}.createComponent")
@self.command(f"{TOOL_MODULE_NAME}.registerComponent")
@self.zenml_command(wrapper_name="stacks_wrapper")
def create_component(wrapper_instance, args):
"""Creates a Zenml stack component"""
return wrapper_instance.create_component(args)
def register_component(wrapper_instance, args):
"""Registers a Zenml stack component"""
return wrapper_instance.register_component(args)

@self.command(f"{TOOL_MODULE_NAME}.updateComponent")
@self.zenml_command(wrapper_name="stacks_wrapper")
Expand Down
12 changes: 6 additions & 6 deletions bundled/tool/zenml_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,8 @@ def copy_stack(self, args) -> dict:
) as e:
return {"error": str(e)}

def create_stack(self, args: Tuple[str, Dict[str, str]]) -> Dict[str, str]:
"""Creates a new ZenML Stack.
def register_stack(self, args: Tuple[str, Dict[str, str]]) -> Dict[str, str]:
"""Registers a new ZenML Stack.
Args:
args (list): List containing the name and chosen components for the stack.
Expand All @@ -738,7 +738,7 @@ def create_stack(self, args: Tuple[str, Dict[str, str]]) -> Dict[str, str]:

try:
self.client.create_stack(name, components)
return {"message": f"Stack {name} successfully created"}
return {"message": f"Stack {name} successfully registered"}
except self.ZenMLBaseException as e:
return {"error": str(e)}

Expand Down Expand Up @@ -780,8 +780,8 @@ def delete_stack(self, args: Tuple[str]) -> Dict[str, str]:
except self.ZenMLBaseException as e:
return {"error": str(e)}

def create_component(self, args: Tuple[str, str, str, Dict[str, str]]) -> Dict[str, str]:
"""Creates a new ZenML stack component.
def register_component(self, args: Tuple[str, str, str, Dict[str, str]]) -> Dict[str, str]:
"""Registers a new ZenML stack component.
Args:
args (list): List containing the component type, flavor used, name, and configuration of the desired new component.
Expand All @@ -793,7 +793,7 @@ def create_component(self, args: Tuple[str, str, str, Dict[str, str]]) -> Dict[s
try:
self.client.create_stack_component(name, flavor, component_type, configuration)

return {"message": f"Stack Component {name} successfully created"}
return {"message": f"Stack Component {name} successfully registered"}
except self.ZenMLBaseException as e:
return {"error": str(e)}

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@
"category": "ZenML Stacks"
},
{
"command": "zenml.createStack",
"title": "Create Stack",
"command": "zenml.registerStack",
"title": "Register New Stack",
"icon": "$(add)",
"category": "ZenML Stacks"
},
Expand Down Expand Up @@ -233,8 +233,8 @@
"category": "ZenML Components"
},
{
"command": "zenml.createComponent",
"title": "Create Component",
"command": "zenml.registerComponent",
"title": "Register New Component",
"icon": "$(add)",
"category": "ZenML Components"
},
Expand Down Expand Up @@ -369,7 +369,7 @@
},
{
"when": "stackCommandsRegistered && view == zenmlStackView",
"command": "zenml.createStack",
"command": "zenml.registerStack",
"group": "navigation@1"
},
{
Expand All @@ -384,7 +384,7 @@
},
{
"when": "componentCommandsRegistered && view == zenmlComponentView",
"command": "zenml.createComponent",
"command": "zenml.registerComponent",
"group": "navigation@1"
},
{
Expand Down
8 changes: 5 additions & 3 deletions resources/components-form/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
const form = document.querySelector('form');
const submit = document.querySelector('input[type="submit"]');
const spinner = document.querySelector('.loader');
const title = document.querySelector('h2');

let mode = 'create';
let mode = 'register';
let type = '';
let flavor = '';
let id = '';
Expand Down Expand Up @@ -135,8 +136,8 @@ window.addEventListener('message', evt => {
const message = evt.data;

switch (message.command) {
case 'create':
mode = 'create';
case 'register':
mode = 'register';
type = message.type;
flavor = message.flavor;
id = '';
Expand All @@ -147,6 +148,7 @@ window.addEventListener('message', evt => {
type = message.type;
flavor = message.flavor;
id = message.id;
title.innerText = title.innerText.replace('Register', 'Update');
setValues(message.name, message.config);
break;

Expand Down
8 changes: 4 additions & 4 deletions resources/stacks-form/stacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const submit = document.querySelector('input[type="submit"]');
const spinner = document.querySelector('.loader');
let previousValues = {};
let id = undefined;
let mode = 'create';
let mode = 'register';

form.addEventListener('click', evt => {
const target = evt.target;
Expand Down Expand Up @@ -71,9 +71,9 @@ window.addEventListener('message', evt => {
const message = evt.data;

switch (message.command) {
case 'create':
mode = 'create';
title.innerText = 'Create Stack';
case 'register':
mode = 'register';
title.innerText = 'Register Stack';
id = undefined;
previousValues = {};
form.reset();
Expand Down
22 changes: 11 additions & 11 deletions src/commands/components/ComponentsForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ export default class ComponentForm extends WebviewBase {
}

/**
* Opens a webview panel based on the flavor config schema to create a new
* Opens a webview panel based on the flavor config schema to register a new
* component
* @param {Flavor} flavor Flavor of component to create
* @param {Flavor} flavor Flavor of component to register
*/
public async createForm(flavor: Flavor) {
public async registerForm(flavor: Flavor) {
const panel = await this.getPanel();
const description = flavor.config_schema.description.replaceAll('\n', '<br>');
panel.webview.html = this.template({
Expand All @@ -92,7 +92,7 @@ export default class ComponentForm extends WebviewBase {
fields: this.toFormFields(flavor.config_schema),
});

panel.webview.postMessage({ command: 'create', type: flavor.type, flavor: flavor.name });
panel.webview.postMessage({ command: 'register', type: flavor.type, flavor: flavor.name });
}

/**
Expand Down Expand Up @@ -164,8 +164,8 @@ export default class ComponentForm extends WebviewBase {
delete data.id;

switch (message.command) {
case 'create':
success = await this.createComponent(name, type, flavor, data);
case 'register':
success = await this.registerComponent(name, type, flavor, data);
break;
case 'update':
success = await this.updateComponent(id, name, type, data);
Expand All @@ -183,31 +183,31 @@ export default class ComponentForm extends WebviewBase {
);
}

private async createComponent(
private async registerComponent(
name: string,
type: string,
flavor: string,
data: object
): Promise<boolean> {
const lsClient = LSClient.getInstance();
try {
const resp = await lsClient.sendLsClientRequest('createComponent', [
const resp = await lsClient.sendLsClientRequest('registerComponent', [
type,
flavor,
name,
data,
]);

if ('error' in resp) {
vscode.window.showErrorMessage(`Unable to create component: "${resp.error}"`);
vscode.window.showErrorMessage(`Unable to register component: "${resp.error}"`);
console.error(resp.error);
traceError(resp.error);
return false;
}

traceInfo(resp.message);
} catch (e) {
vscode.window.showErrorMessage(`Unable to create component: "${e}"`);
vscode.window.showErrorMessage(`Unable to register component: "${e}"`);
console.error(e);
traceError(e);
return false;
Expand Down Expand Up @@ -314,7 +314,7 @@ export default class ComponentForm extends WebviewBase {
</head>
<body>
<div class="container">
<h2>Create {{type}} Stack Component ({{flavor}})</h2>
<h2>Register {{type}} Stack Component ({{flavor}})</h2>
<div class="block">
<article class="description"><img class="logo" src="{{logo}}">{{{description}}}</article>
Expand Down
14 changes: 8 additions & 6 deletions src/commands/components/cmds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ const refreshComponentView = async () => {
};

/**
* Allows one to choose a component type and flavor, then opens the component form webview panel to a form specific to creating a component of that type and flavor.
* Allows one to choose a component type and flavor, then opens the component
* form webview panel to a form specific to register a new a component of that
* type and flavor.
*/
const createComponent = async () => {
const registerComponent = async () => {
const lsClient = LSClient.getInstance();
try {
const types = await lsClient.sendLsClientRequest<ComponentTypesResponse>('getComponentTypes');
Expand All @@ -58,7 +60,7 @@ const createComponent = async () => {
}

const type = await vscode.window.showQuickPick(types, {
title: 'What type of component to create?',
title: 'What type of component to register?',
});
if (!type) {
return;
Expand All @@ -71,14 +73,14 @@ const createComponent = async () => {

const flavorNames = flavors.map(flavor => flavor.name);
const selectedFlavor = await vscode.window.showQuickPick(flavorNames, {
title: `What flavor of a ${type} component to create?`,
title: `What flavor of a ${type} component to register?`,
});
if (!selectedFlavor) {
return;
}

const flavor = flavors.find(flavor => selectedFlavor === flavor.name);
await ComponentForm.getInstance().createForm(flavor as Flavor);
await ComponentForm.getInstance().registerForm(flavor as Flavor);
} catch (e) {
vscode.window.showErrorMessage(`Unable to open component form: ${e}`);
traceError(e);
Expand Down Expand Up @@ -151,7 +153,7 @@ const deleteComponent = async (node: StackComponentTreeItem) => {

export const componentCommands = {
refreshComponentView,
createComponent,
registerComponent,
updateComponent,
deleteComponent,
};
4 changes: 2 additions & 2 deletions src/commands/components/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const registerComponentCommands = (context: ExtensionContext) => {
async () => await componentCommands.refreshComponentView()
),
registerCommand(
'zenml.createComponent',
async () => await componentCommands.createComponent()
'zenml.registerComponent',
async () => await componentCommands.registerComponent()
),
registerCommand(
'zenml.updateComponent',
Expand Down
20 changes: 10 additions & 10 deletions src/commands/stack/StackForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ export default class StackForm extends WebviewBase {
}

/**
* Opens a webview panel with a form to create a new stack
* Opens a webview panel with a form to register a new stack
*/
public async createForm() {
public async registerForm() {
const panel = await this.display();
panel.webview.postMessage({ command: 'create' });
panel.webview.postMessage({ command: 'register' });
}

/**
Expand Down Expand Up @@ -116,8 +116,8 @@ export default class StackForm extends WebviewBase {
delete data.id;

switch (message.command) {
case 'create':
success = await this.createStack(name, data);
case 'register':
success = await this.registerStack(name, data);
break;
case 'update': {
const updateData = Object.fromEntries(
Expand All @@ -139,24 +139,24 @@ export default class StackForm extends WebviewBase {
);
}

private async createStack(
private async registerStack(
name: string,
components: { [type: string]: string }
): Promise<boolean> {
const lsClient = LSClient.getInstance();
try {
const resp = await lsClient.sendLsClientRequest('createStack', [name, components]);
const resp = await lsClient.sendLsClientRequest('registerStack', [name, components]);

if ('error' in resp) {
vscode.window.showErrorMessage(`Unable to create stack: "${resp.error}"`);
vscode.window.showErrorMessage(`Unable to register stack: "${resp.error}"`);
console.error(resp.error);
traceError(resp.error);
return false;
}

traceInfo(resp.message);
} catch (e) {
vscode.window.showErrorMessage(`Unable to create stack: "${e}"`);
vscode.window.showErrorMessage(`Unable to register stack: "${e}"`);
console.error(e);
traceError(e);
return false;
Expand Down Expand Up @@ -248,7 +248,7 @@ export default class StackForm extends WebviewBase {
<title>Stack Form</title>
</head>
<body>
<h2>Create Stack</h2>
<h2>Register Stack</h2>
<form>
<label for="name" required><strong>Stack Name:</strong></label> <input type="text" name="name" id="name">
{{#each options}}
Expand Down
9 changes: 5 additions & 4 deletions src/commands/stack/cmds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,11 @@ const goToStackUrl = (node: StackTreeItem) => {
};

/**
* Opens the stack form webview panel to a form specific to creating a stack.
* Opens the stack form webview panel to a form specific to registering a new
* stack.
*/
const createStack = () => {
StackForm.getInstance().createForm();
const registerStack = () => {
StackForm.getInstance().registerForm();
};

/**
Expand Down Expand Up @@ -260,7 +261,7 @@ export const stackCommands = {
copyStack,
setActiveStack,
goToStackUrl,
createStack,
registerStack,
updateStack,
deleteStack,
};
Loading

0 comments on commit 6ed6acb

Please sign in to comment.