Skip to content

Conversation

@kostenray
Copy link
Contributor


This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • The PR has modified HISTORY.rst with an appropriate description of the change (see Modifying change log).

Command Guidelines

  • Each command and parameter has a meaningful description.
  • Each new command has a test.

(see Authoring Command Modules)

@msftclas
Copy link

@kostenray,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

Copy link
Contributor

@vishrutshah vishrutshah left a 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'
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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' ?

Copy link
Contributor Author

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
Copy link
Contributor

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' ?

Copy link
Contributor Author

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(_):
Copy link
Contributor

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

Reference: https://github.com/Azure/azure-cli/blob/master/src/command_modules/azure-cli-monitor/azure/cli/command_modules/monitor/_client_factory.py#L8

Copy link
Contributor Author

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')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove unnecessary lines

Copy link
Contributor Author

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.'
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary extra lines

Copy link
Contributor Author

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):
Copy link
Contributor

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 ?

Copy link
Contributor Author

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= {}
Copy link
Contributor

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 = [
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@troydai troydai left a 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'
Copy link
Contributor

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

Copy link
Contributor

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
#"""
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obsolete

Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Contributor Author

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.'
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

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):
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Member

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

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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',
Copy link
Member

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

Copy link
Contributor Author

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',
],
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

@troydai troydai left a 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):
Copy link
Contributor

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>

Copy link
Contributor Author

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'
Copy link
Contributor

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
#"""
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@derekbekoe derekbekoe added this to the Build Milestone milestone May 1, 2017
@codecov-io
Copy link

codecov-io commented May 2, 2017

Codecov Report

Merging #3060 into master will increase coverage by 7.42%.
The diff coverage is 90.9%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
.../cli/command_modules/cognitiveservices/commands.py 100% <100%> (ø)
.../azure-cli-cognitiveservices/azure/cli/__init__.py 100% <100%> (ø)
...ules/azure-cli-cognitiveservices/azure/__init__.py 100% <100%> (ø)
...mmand_modules/cognitiveservices/_client_factory.py 100% <100%> (ø)
.../cli/command_modules/cognitiveservices/__init__.py 100% <100%> (ø)
...e/cli/command_modules/cognitiveservices/_params.py 100% <100%> (ø)
...ure/cli/command_modules/cognitiveservices/_help.py 100% <100%> (ø)
...tiveservices/azure/cli/command_modules/__init__.py 100% <100%> (ø)
...re/cli/command_modules/cognitiveservices/custom.py 72% <72%> (ø)
.../cli/command_modules/appservice/_client_factory.py 35.71% <0%> (-64.29%) ⬇️
... and 238 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c97edcf...9065ccc. Read the comment docs.

@troydai
Copy link
Contributor

troydai commented May 2, 2017

I'm taking another look

Copy link
Member

@derekbekoe derekbekoe left a 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',
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixedLeave a comment

Copy link
Contributor Author

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,
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@derekbekoe derekbekoe dismissed vishrutshah’s stale review May 2, 2017 18:46

Dismissing as he's oof.

@derekbekoe derekbekoe merged commit 21e1f9d into Azure:master May 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants