Skip to content

Commit

Permalink
Merge pull request #3 from zenml-io/default-view
Browse files Browse the repository at this point in the history
Default view
  • Loading branch information
treskey authored Jul 16, 2024
2 parents fcac4f9 + 185c277 commit 34c4d7f
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 31 deletions.
9 changes: 9 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.11.9-slim-bookworm

# Install git
RUN apt-get -y update
RUN apt-get -y install git

# Install ZenML
RUN pip install --no-cache-dir zenml
RUN zenml integration install sklearn -y
6 changes: 4 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
Expand All @@ -22,5 +24,5 @@
"containerEnv": {
"PYTHONPATH": "/workspaces/vscode-quickstart-extension/zenmlQuickstart/quickstartModules"
},
"onCreateCommand": "pip install zenml && zenml integration install sklearn -y && zenml init && zenml stack set default"
"onCreateCommand": "zenml init && zenml stack set default"
}
Binary file modified .devcontainer/extensions/zenml-vscode-quickstart-0.0.1.vsix
Binary file not shown.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"categories": [
"Other"
],
"activationEvents": [],
"activationEvents": [
"onStartupFinished"
],
"main": "./out/extension.js",
"contributes": {
"viewsContainers": {
Expand Down Expand Up @@ -41,7 +43,8 @@
"pretest": "npm run compile && npm run lint",
"lint": "eslint src --ext ts",
"test": "vscode-test",
"buildExtension:replace": "vsce package && rm .devcontainer/extensions/zenml-vscode* && mv zenml-vscode* .devcontainer/extensions"
"buildExtension:replace": "vsce package && rm .devcontainer/extensions/zenml-vscode* && mv zenml-vscode* .devcontainer/extensions && npm run moveExtension:quickstart",
"moveExtension:quickstart": "rm ../vscode-quickstart/.devcontainer/extensions/zenml-vscode-quickstart* && cp .devcontainer/extensions/zenml-vscode* ../vscode-quickstart/.devcontainer/extensions"
},
"devDependencies": {
"@types/mocha": "^10.0.7",
Expand Down
14 changes: 7 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import * as vscode from "vscode";
import quickstartMetadata from "./quickstartMetadata.json";
import Quickstart from "./quickstart";
import ZenmlViewProvider from "./zenmlViewProvider";
import { setCWD, unsetCWD } from "./utils/setExtensionCWD";
import setDirectory from "./utils/setExtensionDirectory";

export async function activate(context: vscode.ExtensionContext) {
// if running in production set correct cwd for local devcontainer or codespace
// if running in production set working directory for local devcontainer or codespace
if (context.extensionMode === vscode.ExtensionMode.Production) {
setCWD();
setDirectory();
}

const quickstart = new Quickstart(quickstartMetadata, context);
Expand All @@ -23,6 +23,9 @@ export async function activate(context: vscode.ExtensionContext) {
)
);

// Focuses the webview side panel
await vscode.commands.executeCommand("zenml.stepsView.focus");

// If a user closes the terminal the extension opened we set it
// back to undefined so we know to open a new terminal
context.subscriptions.push(
Expand All @@ -37,7 +40,4 @@ export async function activate(context: vscode.ExtensionContext) {
}

// This method is called when your extension is deactivated
export function deactivate() {
// Sets cwd back to default
unsetCWD();
}
export function deactivate() {}
20 changes: 0 additions & 20 deletions src/utils/setExtensionCWD.ts

This file was deleted.

26 changes: 26 additions & 0 deletions src/utils/setExtensionDirectory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as vscode from "vscode";

export default async function setDirectory() {
const isCodespace = process.env.CODESPACES === "true";

const targetUri = vscode.Uri.file(
`/root/${
isCodespace ? ".vscode-remote" : ".vscode-server"
}/extensions/zenml.zenml-vscode-quickstart-0.0.1/zenmlQuickstart/sections`
);

const currentWorkspace = vscode.workspace.workspaceFolders;

if (
!currentWorkspace ||
currentWorkspace[0].uri.fsPath !== targetUri.fsPath
) {
try {
await vscode.commands.executeCommand("vscode.openFolder", targetUri);
} catch (e) {
vscode.window.showErrorMessage(
`There was a problem opening the directory: ${e}`
);
}
}
}

0 comments on commit 34c4d7f

Please sign in to comment.