-
Notifications
You must be signed in to change notification settings - Fork 4k
Batch first OM based cmdlet #127
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
Conversation
jasper-schneider
commented
Jan 30, 2015
- Batch PowerShell data models and tool to generate them
- Infrastructure for cmdlets based on the Batch OM
- Get-AzureBatchWorkItem cmdlet + some unit tests
Can one of the admins verify this patch? |
Hi @jasper-schneider, I'm your friendly neighborhood Azure Pull Request Bot (You can call me AZPRBOT). Thanks for your contribution!
TTYL, AZPRBOT; |
@azuresdkci add to whitelist |
@azuresdkci test this please |
@@ -186,6 +220,7 @@ | |||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | |||
</PropertyGroup> | |||
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" /> | |||
<Error Condition="!Exists('..\..\..\packages\xunit.runner.visualstudio.2.0.0-rc1-build1030\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\xunit.runner.visualstudio.2.0.0-rc1-build1030\build\net20\xunit.runner.visualstudio.props'))" /> |
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.
Should follow up with Yugang on the changes to move all xunit use to the package instead of the extension.
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.
I'll send him mail.
using System.Management.Automation; | ||
using Constants = Microsoft.Azure.Commands.Batch.Utils.Constants; | ||
|
||
namespace Microsoft.Azure.Commands.Batch |
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.
All code inside cmdlets including checks and everything should be wrapped in the client. For example, this class should be (using ExecuteCmdlet
as this is the expected method)
public override void ExecuteCmdlet()
{
WorkItemsFilterOptions options = new WorkItemsFilterOptions { Name = Name, Filter = Filter };
BatchClient.GetWorkItem(
}
Please fix this pattern in all future cmdlets
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.
Updated to using ExecuteCmdlet()
Regarding putting everything into a client method, how does that work when the two parameter sets have different output types (single object vs. collection object)? I'd rather not have the method have output type object, so it seems like I need to do some parameter processing in the cmdlet to choose the correct client method. Looking at Storage's Get-AzureStorageBlob for example, it seems like they're doing something similar with choosing the method to use based on parameter set. Is there a different example I should be following?
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.
In this case, your conv. method will return collection and you need to call write object with true flag. PowerShell will handle the single/multiple case:
WriteObject(collection, true);
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.
Hmm, I'd prefer to call WriteObject(collection, false) in the case that I'm actually returning a collection. We have a custom enumerator that has some features that let it handle large scale data sets pretty well, such as only querying the service in chunks when the enumerator is actually being iterated through and supporting parallel iteration very well. Walking through the entire collection up front removes some of these benefits.
Would this level of logic in the cmdlet be ok?
if (name not null) { WriteObject(client.GetSingleItem()); }
else { WriteObject(client.GetCollection(), false); }
|
Removed code gen tool. Regarding the mocked scenario tests, the Batch OM isn't built on top of Hyak yet, so it doesn't hook into the Http interceptor. We do have a plan to replace the Batch OM REST layer with Hyak in the future, in which case we should get this behavior. |
@azuresdkci test this please |
@jasper-schneider We cannot accept this PR that adds such an olde version of storage to the ARM clients. Please upgrade to a later version of storage and submit for the next release (end of Feb). |
@jasper-schneider these tests are for guarding your cmdlets in case a change happened in PowerShell code so people can verify the change without need for pinging every single service team |
Bug #4266426: Removing Default Parameter set from RegisterContainer c…