Skip to content
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
3 changes: 1 addition & 2 deletions src/Microsoft.DotNet.Interactive.CSharp/CSharpKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public CSharpKernel(string name) : base(name)
KernelInfo.LanguageVersion = "12.0";
KernelInfo.DisplayName = $"{KernelInfo.LocalName} - C# Script";
KernelInfo.Description = """
This Kernel can compile and execute C# code and display the results.
The language is C# Script, a dialect of C# used for interactive programming.
Compile and run C# Script
""";
_workspace = new InteractiveWorkspace();

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.DotNet.Interactive.FSharp/FSharpKernel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type FSharpKernel () as this =
do this.KernelInfo.LanguageName <- "F#"
do this.KernelInfo.LanguageVersion <- "8.0"
do this.KernelInfo.DisplayName <- $"{this.KernelInfo.LocalName} - F# Script"
do this.KernelInfo.Description <- """This kernel can compile and execute F# code and display the results."""
do this.KernelInfo.Description <- """Compile and run F# code"""

static let lockObj = Object();

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.DotNet.Interactive.Http/HttpKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public HttpKernel(
KernelInfo.LanguageName = "HTTP";
KernelInfo.DisplayName = $"{KernelInfo.LocalName} - HTTP Request";
KernelInfo.Description = """
This Kernel is able to execute http requests and display the results.
Send HTTP requests
""";

_client = client ?? new HttpClient() { Timeout = Timeout.InfiniteTimeSpan };
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.DotNet.Interactive.Kql/MsKqlKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public MsKqlKernel(
{
_connectionDetails = connectionDetails ?? throw new ArgumentException("Value cannot be null or whitespace.", nameof(connectionDetails));
KernelInfo.Description = $"""
This Kernel can execute KQL queries against a Kusto database.
This instance is connected to cluster {connectionDetails.Cluster} and database {connectionDetails.Database}.
Query Kusto cluster {connectionDetails.Cluster} and database {connectionDetails.Database}
""";
}

Expand Down
4 changes: 1 addition & 3 deletions src/Microsoft.DotNet.Interactive.Mermaid/MermaidKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ public MermaidKernel() : base("mermaid")
{
KernelInfo.LanguageName = "Mermaid";
KernelInfo.Description = """
This Kernel uses the Mermaid library to render diagrams.

For more information about Mermaid, see https://mermaid.js.org/intro.
Render diagrams using the Mermaid language (https://mermaid.js.org/intro)
""";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public PostgreSqlKernel(string name, string connectionString) : base(name)
{
KernelInfo.LanguageName = "PostgreSQL";
KernelInfo.Description = """
This kernel is backed by a PostgreSQL database.
It can execute SQL statements against the database and display the results as tables.
Query a PostgreSQL database
""";

_connectionString = connectionString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public PowerShellKernel(string name) : base(name)
KernelInfo.LanguageName = LanguageName;
KernelInfo.LanguageVersion = "7";
KernelInfo.Description = """
This Kernel can evaluate Powershell scripts and commands.
It uses Powershell Core and can interop with the operative system and host machine.
Run PowerShell scripts and commands
""";

_psHost = new PSKernelHost(this);
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.DotNet.Interactive.SQLite/SQLiteKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public SQLiteKernel(string name, string connectionString) : base(name)
{
KernelInfo.LanguageName = "SQLite";
KernelInfo.Description ="""
This kernel is backed by a SQLite database.
It can execute SQL statements against the database and display the results as tables.
Query a SQLite database
""";

_connectionString = connectionString;
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.DotNet.Interactive.SqlServer/MsSqlKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ internal MsSqlKernel(
throw new ArgumentException("Value cannot be null or whitespace.", nameof(connectionString));
}
KernelInfo.Description = """
This Kernel can execute T-SQL and SQL queries against a SQL Server database.
It is connected to a MSSQL database.
Query a Microsoft SQL database using T-SQL
""";
_connectionString = connectionString;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ public async Task it_can_create_a_proxy_kernel_to_more_than_one_remote_subkernel
LanguageVersion = csharpKernelInfo.LanguageVersion,
RemoteUri = csharpKernelInfo.Uri,
Description = """
This Kernel can compile and execute C# code and display the results.
The language is C# Script, a dialect of C# used for interactive programming.
Compile and run C# Script
"""
};

Expand All @@ -161,7 +160,7 @@ This Kernel can compile and execute C# code and display the results.
LanguageVersion = fsharpKernelInfo.LanguageVersion,
RemoteUri = fsharpKernelInfo.Uri,
Description = """
This kernel can compile and execute F# code and display the results.
Compile and run F# code
"""
};

Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.DotNet.Interactive/HtmlKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class HtmlKernel :
public HtmlKernel() : base(DefaultKernelName)
{
KernelInfo.LanguageName = "HTML";
KernelInfo.Description = "Write and display HTML";
}

Task IKernelCommandHandler<SubmitCode>.HandleAsync(SubmitCode command, KernelInvocationContext context)
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.DotNet.Interactive/KeyValueStoreKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public KeyValueStoreKernel(string name = DefaultKernelName, HttpClient httpClien
{
_httpClient = httpClient;
KernelInfo.DisplayName = $"{KernelInfo.LocalName} - Raw Value Storage";
KernelInfo.Description = "Store raw text for sharing between subkernels";
}

Task IKernelCommandHandler<RequestValueInfos>.HandleAsync(RequestValueInfos command, KernelInvocationContext context)
Expand Down
3 changes: 3 additions & 0 deletions src/Microsoft.DotNet.Interactive/KqlDiscoverabilityKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public KqlDiscoverabilityKernel() : base(DefaultKernelName)
"MsKqlKernel"
};
KernelInfo.LanguageName = "KQL";
KernelInfo.Description = $"""
Query a Kusto database
""";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Indents - not sure whether this will end up including extra whitespace in the literal (does it?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not.

}

Task IKernelCommandHandler<SubmitCode>.HandleAsync(SubmitCode command, KernelInvocationContext context)
Expand Down
3 changes: 3 additions & 0 deletions src/Microsoft.DotNet.Interactive/SqlDiscoverabilityKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public SqlDiscoverabilityKernel() : base(DefaultKernelName)
"SQLiteKernel"
};
KernelInfo.LanguageName = "SQL";
KernelInfo.Description = $"""
Query a Microsoft SQL database
""";
}

Task IKernelCommandHandler<SubmitCode>.HandleAsync(SubmitCode command, KernelInvocationContext context)
Expand Down
3 changes: 1 addition & 2 deletions src/polyglot-notebooks-vscode-common/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ export async function activate(context: vscode.ExtensionContext) {
function configureKernel(compositeKernel: CompositeKernel, notebookUri: vscodeLike.Uri) {
compositeKernel.setDefaultTargetKernelNameForCommand(commandsAndEvents.RequestInputType, compositeKernel.name);
compositeKernel.setDefaultTargetKernelNameForCommand(commandsAndEvents.SendEditableCodeType, compositeKernel.name);
compositeKernel.kernelInfo.description = `This Kernel is provided by the .NET Interactive Extension.
This allows adding new cells to the notebook and prompting user for input.`;
compositeKernel.kernelInfo.description = `Composes a group of subkernels`;

compositeKernel.registerCommandHandler({
commandType: commandsAndEvents.RequestInputType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface KernelSelectorOption {
kernelName: string;
displayValue: string;
languageName?: string;
description?: string;
}

export function getKernelInfoDisplayValue(kernelInfo: { localName: string, displayName: string }): string {
Expand All @@ -26,13 +27,14 @@ function extractInfo(kernelInfo: commandsAndEvents.KernelInfo) {
return {
localName: kernelInfo.localName,
displayName: kernelInfo.displayName,
description: kernelInfo.description,
languageName: kernelInfo.languageName,
supportedKernelCommands: Array.from(kernelInfo.supportedKernelCommands.map(c => c.name))
};
}

export function getKernelSelectorOptions(kernel: CompositeKernel, document: vscodeLike.NotebookDocument, requiredSupportedCommandType: commandsAndEvents.KernelCommandType): KernelSelectorOption[] {
const kernelInfos: Map<string, { localName: string, displayName: string, languageName?: string, supportedKernelCommands: string[] }> = new Map();
const kernelInfos: Map<string, { localName: string, displayName: string, languageName?: string, description?: string, supportedKernelCommands: string[] }> = new Map();

// create and collect all `KernelInfo`s from document metadata...
const notebookMetadata = metadataUtilities.getNotebookDocumentMetadataFromNotebookDocument(document);
Expand Down Expand Up @@ -64,7 +66,8 @@ export function getKernelSelectorOptions(kernel: CompositeKernel, document: vsco
const selectorOptions: KernelSelectorOption[] = filteredKernels.map(kernelInfo => {
const result: KernelSelectorOption = {
kernelName: kernelInfo.localName,
displayValue: getKernelInfoDisplayValue(kernelInfo)
displayValue: getKernelInfoDisplayValue(kernelInfo),
description: kernelInfo.description
};
if (kernelInfo.languageName) {
result.languageName = kernelInfo.languageName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ import { ServiceCollection } from './serviceCollection';

const selectKernelCommandName = 'polyglot-notebook.selectCellKernel';

class KernelSelectorItem implements vscode.QuickPickItem {
constructor(label: string) {
this.label = label;
}

label: string;
description?: string | undefined;
detail?: string | undefined;
iconPath?: vscode.ThemeIcon;
}

export function registerNotbookCellStatusBarItemProvider(context: vscode.ExtensionContext, clientMapper: ClientMapper) {
const cellItemProvider = new DotNetNotebookCellStatusBarItemProvider(clientMapper);
clientMapper.onClientCreate((_uri, client) => {
Expand All @@ -31,18 +42,28 @@ export function registerNotbookCellStatusBarItemProvider(context: vscode.Extensi
if (cell) {
const client = await clientMapper.tryGetClient(cell.notebook.uri);
if (client) {
const availableOptions = kernelSelectorUtilities.getKernelSelectorOptions(client.kernel, cell.notebook, commandsAndEvents.SubmitCodeType);
const availableDisplayOptions = availableOptions.map(o => o.displayValue);
const selectedDisplayOption = await vscode.window.showQuickPick(availableDisplayOptions, { title: 'Select cell kernel' });
const kernelSelectorOptions = kernelSelectorUtilities
.getKernelSelectorOptions(client.kernel, cell.notebook, commandsAndEvents.SubmitCodeType);

const kernelSelectorItems = kernelSelectorOptions
.map(o => {
const item = new KernelSelectorItem(o.displayValue);
item.description = o.description;
item.iconPath = new vscode.ThemeIcon('notebook-kernel-select');
return item;
});

const selectedDisplayOption = await vscode.window.showQuickPick(kernelSelectorItems, { title: 'Select cell kernel' });

if (selectedDisplayOption) {
const selectedValueIndex = availableDisplayOptions.indexOf(selectedDisplayOption);
const selectedValueIndex = kernelSelectorItems.indexOf(selectedDisplayOption);
if (selectedValueIndex >= 0) {
const selectedKernelData = availableOptions[selectedValueIndex];
const selectedKernelItem = kernelSelectorOptions[selectedValueIndex];
const codeCell = await vscodeUtilities.ensureCellKernelKind(cell, vscode.NotebookCellKind.Code);
const notebookCellMetadata = metadataUtilities.getNotebookCellMetadataFromNotebookCellElement(cell);
if (notebookCellMetadata.kernelName !== selectedKernelData.kernelName) {
if (notebookCellMetadata.kernelName !== selectedKernelItem.kernelName) {
// update metadata
notebookCellMetadata.kernelName = selectedKernelData.kernelName;
notebookCellMetadata.kernelName = selectedKernelItem.kernelName;
const newRawMetadata = metadataUtilities.getRawNotebookCellMetadataFromNotebookCellMetadata(notebookCellMetadata);
const mergedMetadata = metadataUtilities.mergeRawMetadata(cell.metadata, newRawMetadata);
const _succeeded = await vscodeNotebookManagement.replaceNotebookCellMetadata(codeCell.notebook.uri, codeCell.index, mergedMetadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('kernel selector utility tests', async () => {

// add C# kernel that supports `SubmitCode`
const cs = new Kernel('csharp', 'csharp', '10.0', 'See Sharp');
cs.kernelInfo.description = 'Do C# stuff';
cs.kernelInfo.supportedKernelCommands = [{ name: commandsAndEvents.SubmitCodeType }];
kernel.add(cs);

Expand Down Expand Up @@ -50,11 +51,13 @@ describe('kernel selector utility tests', async () => {
{
kernelName: 'csharp',
displayValue: 'See Sharp',
languageName: 'csharp'
languageName: 'csharp',
description: 'Do C# stuff'
},
{
kernelName: 'fsharp',
displayValue: 'fsharp'
displayValue: 'fsharp',
description: undefined
}
]);
});
Expand Down
2 changes: 1 addition & 1 deletion src/polyglot-notebooks/src/htmlKernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class HtmlKernel extends Kernel {
constructor(kernelName?: string, private readonly htmlFragmentInserter?: (htmlFragment: string) => Promise<string>, languageName?: string, languageVersion?: string) {
super(kernelName ?? "html", languageName ?? "HTML", languageVersion ?? "5");
this.kernelInfo.displayName = 'HTML';
this.kernelInfo.description = `This Kernel can evaluate html snippets and display them as output.`;
this.kernelInfo.description = `Write and display HTML`;
if (!this.htmlFragmentInserter) {
this.htmlFragmentInserter = htmlDomFragmentInserter;
}
Expand Down
3 changes: 2 additions & 1 deletion src/polyglot-notebooks/src/javascriptKernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class JavascriptKernel extends Kernel {
constructor(name?: string) {
super(name ?? "javascript", "JavaScript");
this.kernelInfo.displayName = `${this.kernelInfo.localName} - ${this.kernelInfo.languageName}`;
this.kernelInfo.description = `This Kernel is for executing JavaScript code.`;
this.kernelInfo.description = `Run JavaScript code`;
this.suppressedLocals = new Set<string>(this.allLocalVariableNames());
this.registerCommandHandler({ commandType: commandsAndEvents.SubmitCodeType, handle: invocation => this.handleSubmitCode(invocation) });
this.registerCommandHandler({ commandType: commandsAndEvents.RequestValueInfosType, handle: invocation => this.handleRequestValueInfos(invocation) });
Expand Down Expand Up @@ -177,3 +177,4 @@ export function getType(arg: any): string {

return type; //?
}

2 changes: 1 addition & 1 deletion src/polyglot-notebooks/tests/frontEndHost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe("frontEndHost", () => {
},
{
aliases: ['js'],
description: 'This Kernel is for executing JavaScript code.',
description: 'Run JavaScript code',
displayName: 'javascript - JavaScript',
isComposite: false,
isProxy: false,
Expand Down