This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathExperimentalFeatures.cs
More file actions
59 lines (50 loc) · 1.88 KB
/
ExperimentalFeatures.cs
File metadata and controls
59 lines (50 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.Jupyter.Core.Protocol;
using Newtonsoft.Json;
namespace Microsoft.Quantum.IQSharp.Kernel
{
/// <summary>
/// Message content to be received when a client asks for an
/// experimental feature to be turned on.
/// </summary>
public class ExperimentalFeatureContent : MessageContent
{
/// <summary>
/// The name of the experimental feature to be enabled.
/// </summary>
[JsonProperty("feature_name")]
public string? FeatureName { get; set; }
/// <summary>
/// The names and versions of any optional packages used with the
/// requested experimental feature.
/// </summary>
[JsonProperty("optional_dependencies")]
public List<string>? OptionalDependencies { get; set; }
}
/// <summary>
/// Event type for when a Python client enables an experimental
/// feature.
/// </summary>
public record ExperimentalFeatureEnabledEvent : Event<ExperimentalFeatureContent>;
/// <summary>
/// Shell handler that allows for firing off events when a Python
/// client enables an experimental feature via
/// <c>qsharp.experimental</c>.
/// </summary>
internal class ExperimentalFeaturesShellHandler : IShellHandler
{
public string MessageType => "iqsharp_python_enable_experimental";
private readonly IEventService events;
public ExperimentalFeaturesShellHandler(IEventService events)
{
this.events = events;
}
public Task HandleAsync(Message message)
{
var content = message.To<ExperimentalFeatureContent>();
events?.Trigger<ExperimentalFeatureEnabledEvent, ExperimentalFeatureContent>(content);
return Task.CompletedTask;
}
}
}