-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Prediction/Commands Service API v2 updates #13767
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+1.59 MB
(530%)
tools/Az.Tools.Predictor/Az.Tools.Predictor.Test/Data/CommandsModel.zip
Binary file not shown.
Binary file modified
BIN
+7.56 MB
(370%)
tools/Az.Tools.Predictor/Az.Tools.Predictor.Test/Data/PredictionsModel.zip
Binary file not shown.
Binary file removed
BIN
-2.49 MB
tools/Az.Tools.Predictor/Az.Tools.Predictor.Test/Data/SuggestionsModel.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
tools/Az.Tools.Predictor/Az.Tools.Predictor.Test/ModelEntry.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Serialization; | ||
|
||
namespace Microsoft.Azure.PowerShell.Tools.AzPredictor.Test | ||
{ | ||
/// <summary> | ||
/// Represents a command entry in the model files. | ||
/// </summary> | ||
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] | ||
public class ModelEntry | ||
{ | ||
/// <summary> | ||
/// The command in the model. | ||
/// </summary> | ||
[JsonProperty("suggestion", Required = Required.Always)] | ||
public string Command { get; set; } | ||
|
||
/// <summary> | ||
/// The description of the command in the model. | ||
/// </summary> | ||
[JsonProperty(Required = Required.Always)] | ||
public string Description { get; set; } | ||
|
||
/// <summary> | ||
/// The prediction count in the model. | ||
/// </summary> | ||
[JsonProperty("suggestion count", Required = Required.Always)] | ||
public int PredictionCount { get; set; } | ||
|
||
/// <summary> | ||
/// The history count in the model. | ||
/// </summary> | ||
[JsonProperty("history count", Required = Required.Always)] | ||
public int HistoryCount { get; set; } | ||
|
||
/// <summary> | ||
/// Transforms the model entry into the client PredictiveCommand object. | ||
/// </summary> | ||
/// <returns>The PredictiveCommand object used on the client.</returns> | ||
public PredictiveCommand TransformEntry() | ||
{ | ||
return new PredictiveCommand() | ||
{ | ||
Command = this.Command, | ||
Description = this.Description | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tools/Az.Tools.Predictor/Az.Tools.Predictor/AzPredictorSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"maxAllowedCommandDuplicate": 1, | ||
"serviceUri": "https://app.aladdin.microsoft.com/api/v1", | ||
"serviceUri": "https://app.aladdin.microsoft.com/api/v2.0", | ||
"suggestionCount": 7 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you convert to use the built-in json serialization https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-how-to?pivots=dotnet-5-0
You can find the default option for deserialization here https://github.com/Azure/azure-powershell/blob/master/tools/Az.Tools.Predictor/Az.Tools.Predictor/Utilities/JsonUtilities.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same to other files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we use the built-in json serialization over the Newtonsoft one? I ask because it seems the built-in version wasn't able to parse the string into the objects I had defined. I'm sure it is possible but I found that the Newtonsoft library was able to do it without any issue. If we really don't want to have a dependency on this library, I can find out how to do this using the built-in version.