-
Notifications
You must be signed in to change notification settings - Fork 3.3k
azure cognitive service CLI initial version #3060
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
|
@kostenray, |
vishrutshah
left a comment
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.
It'd be great if you can post help on each of the commands that helps reviewing the commands
| def __init__(self, method_name): | ||
| super(IntegrationTestBase, self).__init__(method_name) | ||
| self.diagnose = os.environ.get(ENV_TEST_DIAGNOSE, None) == 'True' | ||
| self.diagnose = True #os.environ.get(ENV_TEST_DIAGNOSE, None) == '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.
Why are you changing azure-cli-testsdk?
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.
Please remove this.
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.
it's checked in accidentally. removed
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.
As of now, it is still here.
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.
fixed
| def cognitiveservices_client_factory(_): | ||
| from azure.cli.core.commands.client_factory import get_mgmt_service_client | ||
| from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient | ||
| return get_mgmt_service_client(CognitiveServicesManagementClient, location='notused').cognitive_services_accounts |
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.
could you please elaborate what is location='notused' ?
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.
there is an extra parameter need passing a value when initializing the sdk management client. but it's not used by every class and operation. so for some initialization, i need pass a dummy value.
| def cognitiveservices_account_client_factory(_): | ||
| from azure.cli.core.commands.client_factory import get_mgmt_service_client | ||
| from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient | ||
| return get_mgmt_service_client(CognitiveServicesManagementClient, location='notused').accounts |
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.
could you please elaborate what is location='notused' ?
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.
see above comments
| from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient | ||
| return get_mgmt_service_client(CognitiveServicesManagementClient, location='notused').cognitive_services_accounts | ||
|
|
||
| def cognitiveservices_account_client_factory(_): |
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.
Refactor by adding get_ cognitiveservices_management_client and then use them in cognitiveservices_account_client_factory & other operations
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.
fixed
| register_cli_argument('cognitiveservices', 'tags', tags_type) | ||
| register_cli_argument('cognitiveservices', 'key_name', required=True, help='Key name to generate', choices=['key1', 'key2']) | ||
| register_cli_argument('cognitiveservices account create', 'yes', action='store_true', help='Do not prompt for terms confirmation') | ||
|
|
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.
please remove unnecessary lines
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.
fixed
|
|
||
| def create(client, resource_group_name, account_name, sku_name, kind, location, tags=None, yes=None, **kwargs): | ||
|
|
||
| terms = 'Notice\nMicrosoft may use data you send to the Cognitive Services to improve Microsoft products and services. For example we may use content that you provide to the Cognitive Services to improve our underlying algorithms and models over time. Where you send personal data to the Cognitive Services, you are responsible for obtaining sufficient consent from the data subjects. The General Privacy and Security Terms in the Online Services Terms (https://www.microsoft.com/en-us/Licensing/product-licensing/products.aspx) do not apply to the Cognitive Services. You must comply with use and display requirements for the Bing Search APIs. \n\nPlease refer to the Microsoft Cognitive Services section in the Online Services Terms for details.' |
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.
@troydai / @tjprescott Do we have any other recommendation instead of this mechanism?
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.
We have confirmation mechanism, but this is the first case for a warning. If it is for user consumption the message should be print to stdout instead of logger. The logger may be turned off.
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.
won't fix as it's fine
| def update(client, resource_group_name, account_name, sku_name=None, tags=None, **kwargs): | ||
| sku = Sku(sku_name) | ||
| return client.update(resource_group_name, account_name, sku, tags) | ||
|
|
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.
unnecessary extra lines
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.
fixed
| params = CognitiveServicesAccountCreateParameters(sku, kind, location, properties, tags) | ||
| return client.create(resource_group_name, account_name, params) | ||
|
|
||
| def update(client, resource_group_name, account_name, sku_name=None, tags=None, **kwargs): |
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.
how are you using **kwargs ?
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.
removed
| if(not option): | ||
| raise CLIError('Operation cancelled.') | ||
| sku = Sku(sku_name) | ||
| properties= {} |
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.
If properties are going to be empty dictionary, why are they not options in SDK?
| ] | ||
|
|
||
| DEPENDENCIES = [ | ||
| ] |
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.
troydai
left a comment
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.
Please fix the code styles.
| def __init__(self, method_name): | ||
| super(IntegrationTestBase, self).__init__(method_name) | ||
| self.diagnose = os.environ.get(ENV_TEST_DIAGNOSE, None) == 'True' | ||
| self.diagnose = True #os.environ.get(ENV_TEST_DIAGNOSE, None) == '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.
Please remove this.
|
|
||
| def load_commands(): | ||
| import azure.cli.command_modules.cognitiveservices.commands | ||
|
|
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.
Please run check_style --module cognitiveservices to fix all the code style issues. This file will fail the pylint because we require 2 blank lines between first level entities.
| #helps['cognitiveservices checkskuavailability'] = """ | ||
| # type: command | ||
| # short-summary: check the available skus | ||
| #""" |
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.
Please do not check in commented code.
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.
obsolete
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.
Do you mean the command is obsoleted or the help doc is obsoleted? Either way, this should be removed from the source code.
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.
removed
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: disable=line-too-long |
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.
Please do not disable pylint rules in a file scope. Make the follow the style instead of bending the rules. There are existing pylint disable statement in the legacy code base, we're in the process of retiring them.
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.
fixed
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: disable=line-too-long |
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 as above.
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.
fixed
|
|
||
| def create(client, resource_group_name, account_name, sku_name, kind, location, tags=None, yes=None, **kwargs): | ||
|
|
||
| terms = 'Notice\nMicrosoft may use data you send to the Cognitive Services to improve Microsoft products and services. For example we may use content that you provide to the Cognitive Services to improve our underlying algorithms and models over time. Where you send personal data to the Cognitive Services, you are responsible for obtaining sufficient consent from the data subjects. The General Privacy and Security Terms in the Online Services Terms (https://www.microsoft.com/en-us/Licensing/product-licensing/products.aspx) do not apply to the Cognitive Services. You must comply with use and display requirements for the Bing Search APIs. \n\nPlease refer to the Microsoft Cognitive Services section in the Online Services Terms for details.' |
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.
We have confirmation mechanism, but this is the first case for a warning. If it is for user consumption the message should be print to stdout instead of logger. The logger may be turned off.
|
|
||
| #pylint: disable=method-hidden | ||
| #pylint: disable=line-too-long | ||
| #pylint: disable=bad-continuation |
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.
Please remove pylint disable statements.
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.
fixed
| class CognitiveServicesTests(ScenarioTest): | ||
| @ResourceGroupPreparer() | ||
|
|
||
| def test_cognitiveservices(self, resource_group): |
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.
Please use a better and more elaborate test name. There will be more test cases eventually.
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.
fixed
|
|
||
| from codecs import open | ||
| from setuptools import setup | ||
|
|
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.
The setup.py should have the following:
try:
from azure_bdist_wheel import cmdclass
except ImportError:
from distutils import log as logger
logger.warn("Wheel is not available, disabling bdist_wheel hook")
cmdclass = {}
Also, it should have cmdclass=cmdclass in setup(...). See other modules for examples.
cc: @johanste
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.
fixed
| Unreleased | ||
| -------------------------- | ||
| * inital cognitive services CLI |
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.
This section should go below the 'Release History' section.
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.
fixed
| short-summary: Create a cognitive services account. | ||
| examples: | ||
| - name: create a S0 face Api cognitive services accounts in West Europe without confirmation required | ||
| text: az cognitiveservices create -n myresource -g myResrouceGroup --Kind Face --Sku S0 -l WestEurope --yes |
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.
Typo myResrouceGroup.
Also, Kind -> kind.
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.
fixed
|
|
||
| setup( | ||
| name='azure-cli-cognitiveservices', | ||
| version='1.0.0', |
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.
Version number should be 0.x.x e.g. 0.1.0
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.
fixed. is this because it's not released version yet?
| 'azure', | ||
| 'azure.cli', | ||
| 'azure.cli.command_modules', | ||
| ], |
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.
This has changed recently.
See other modules for examples.
cc: @johanste
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 checked the other modules, and they seems to be the same
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.
fixed
troydai
left a comment
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.
Please run check_style --module cognitiveservices to clear the code style issues.
| @ResourceGroupPreparer() | ||
|
|
||
| def test_cognitiveservices(self, resource_group): | ||
| def test_CRUDOperations_cognitiveservices(self, resource_group): |
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.
The format adopted by other command module is:
test_<module>_<scenario>
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.
fixed
| def __init__(self, method_name): | ||
| super(IntegrationTestBase, self).__init__(method_name) | ||
| self.diagnose = os.environ.get(ENV_TEST_DIAGNOSE, None) == 'True' | ||
| self.diagnose = True #os.environ.get(ENV_TEST_DIAGNOSE, None) == '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.
As of now, it is still here.
| #helps['cognitiveservices checkskuavailability'] = """ | ||
| # type: command | ||
| # short-summary: check the available skus | ||
| #""" |
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.
Do you mean the command is obsoleted or the help doc is obsoleted? Either way, this should be removed from the source code.
| @@ -0,0 +1,56 @@ | |||
| #!/usr/bin/env python | |||
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.
We do not need shebang on setup file.
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.
fixed
2. add the depedencies in setup,
Codecov Report
@@ Coverage Diff @@
## master #3060 +/- ##
==========================================
+ Coverage 63.15% 70.57% +7.42%
==========================================
Files 484 369 -115
Lines 27628 23902 -3726
Branches 4281 3657 -624
==========================================
- Hits 17449 16870 -579
+ Misses 9027 5956 -3071
+ Partials 1152 1076 -76
Continue to review full report at Codecov.
|
|
I'm taking another look |
derekbekoe
left a comment
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.
A couple of changes are required in setup.py but apart from that, it looks good!
|
|
||
| setup( | ||
| name='azure-cli-cognitiveservices', | ||
| version='0.1.0', |
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.
The version no. should be defined like in the other modules.
So after line 14, VERSION = '0.1.0+dev'.
Then here, version=VERSION,.
See the setup.py of other modules for an example.
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.
fixedLeave a comment
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.
fixed
| name='azure-cli-cognitiveservices', | ||
| version='0.1.0', | ||
| description='Microsoft Azure Command-Line Tools Cognitive Services Command Module', | ||
| long_description=README, |
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.
This does not include the HISTORY.rst. See the other setup.py files for examples.
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.
fixed
This checklist is used to make sure that common guidelines for a pull request are followed.
General Guidelines
Command Guidelines
(see Authoring Command Modules)