Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip function types in sharing variables with Python #3407

Merged
merged 2 commits into from
Jan 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def handle_control_comm_msg(self, msg):


class CommandEventHandler:
__exclude_types = ["<class 'module'>"]
__exclude_types = ["<class 'module'>", "<class 'builtin_function_or_method'>","<class 'function'>"]


def handle_command_or_event(self, data):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ namespace Microsoft.DotNet.Interactive.Jupyter;

public class ConnectJupyterKernelCommand : ConnectKernelCommand
{
private readonly List<IJupyterKernelConnectionOptions> _connectionCreaters = new();
private readonly List<IJupyterKernelConnectionOptions> _connectionCreators = new();
private KeyValuePair<int, IEnumerable<CompletionItem>> _mruKernelSpecSuggestions;

public ConnectJupyterKernelCommand() : base("jupyter",
"Connects to a jupyter kernel. This feature is in preview.")
{
AddOption(KernelSpecName.AddCompletions(ctx => GetKernelSpecsCompletions(ctx)));
AddOption(KernelSpecName.AddCompletions(GetKernelSpecsCompletions));
AddOption(InitScript);
}

Expand All @@ -44,7 +44,7 @@ public ConnectJupyterKernelCommand AddConnectionOptions(IJupyterKernelConnection
AddOption(option);
}

_connectionCreaters.Add(connectionOptions);
_connectionCreators.Add(connectionOptions);
return this;
}

Expand All @@ -60,12 +60,12 @@ public override async Task<IEnumerable<Kernel>> ConnectKernelsAsync(
var initScript = commandLineContext.ParseResult.GetValueForOption(InitScript);

var connection = GetJupyterConnection(commandLineContext.ParseResult);
if (connection == null)
if (connection is null)
{
throw new InvalidOperationException("No supported connection options were specified");
}

JupyterKernelConnector connector = new JupyterKernelConnector(connection, kernelSpecName, initScript);
var connector = new JupyterKernelConnector(connection, kernelSpecName, initScript);

var localName = commandLineContext.ParseResult.GetValueForOption(KernelNameOption);

Expand All @@ -79,7 +79,7 @@ public override async Task<IEnumerable<Kernel>> ConnectKernelsAsync(

private IJupyterConnection GetJupyterConnection(ParseResult parseResult)
{
foreach (var connectionOptions in _connectionCreaters)
foreach (var connectionOptions in _connectionCreators)
{
var connection = connectionOptions.GetConnection(parseResult);
if (connection != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@
using Microsoft.DotNet.Interactive.Commands;
using Microsoft.DotNet.Interactive.Events;
using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;

namespace Microsoft.DotNet.Interactive.Jupyter;

internal static class JupyterKernelExtensions
{
public async static Task UseConfiguration(this JupyterKernel kernel, IJupyterKernelConfiguration configuration)
public static async Task UseConfiguration(this JupyterKernel kernel, IJupyterKernelConfiguration configuration)
{
await configuration.ApplyAsync(kernel);
}

public async static Task<bool> RunOnKernelAsync(this JupyterKernel kernel, string code)
public static async Task<bool> RunOnKernelAsync(this JupyterKernel kernel, string code)
{
var results = await kernel.SendAsync(new SubmitCode(code));
var success = results.Events.OfType<CommandSucceeded>().FirstOrDefault();

return success is { };
return success is not null;
}
}
1 change: 0 additions & 1 deletion src/Microsoft.DotNet.Interactive.Jupyter/Shell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.DotNet.Interactive.Jupyter.Messaging;
using Microsoft.DotNet.Interactive.Jupyter.Protocol;
using Microsoft.DotNet.Interactive.Jupyter.ZMQ;
using Microsoft.Extensions.Hosting;
Expand Down