Skip to content

Commit

Permalink
[ML] fix(next-pylint): Resolve docstring-should-be-keyword (Azure#3…
Browse files Browse the repository at this point in the history
…1239)

* fix(next-pylint): Resolve `unused-import`

* fix(next-pylint): Fix docstrings where parameter rename isn't reflected

* fix(next-pylint): Fix shortform sphinx param in wrong order (`:param name type:` instad of `:param type name:`)

* fix(next-pylint): Fix docstrings that have param entry for removed parameter

* fix(next-pylint): Use `:keyword ` instead of `:param ` for keyword args
  • Loading branch information
kdestin authored Jul 21, 2023
1 parent 5e7dfff commit 55420bd
Show file tree
Hide file tree
Showing 71 changed files with 561 additions and 566 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def list(self, starts_with: str) -> List[str]:
blobs = self.container_client.list_blobs(name_starts_with=starts_with)
return [blob.name for blob in blobs]

def exists(self, blobpath: str, delimeter: str = "/") -> bool:
def exists(self, blobpath: str, delimiter: str = "/") -> bool:
"""Returns whether there exists a blob named `blobpath`, or if there exists a virtual directory given path
delimeter `delimeter`
Expand All @@ -281,11 +281,11 @@ def exists(self, blobpath: str, delimeter: str = "/") -> bool:
if self.container_client.get_blob_client(blobpath).exists():
return True

ensure_delimeter = delimeter if not blobpath.endswith(delimeter) else ""
ensure_delimeter = delimiter if not blobpath.endswith(delimiter) else ""

# Virtual directory only exists if there is atleast one blob with it
result = next(
self.container_client.walk_blobs(name_starts_with=blobpath + ensure_delimeter, delimiter=delimeter),
self.container_client.walk_blobs(name_starts_with=blobpath + ensure_delimeter, delimiter=delimiter),
None,
)
return result is not None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ def write_file(self, directory_path: str, file_prefix: Optional[str] = None) ->
:param directory_path: absolute path of local directory to write Dockerfile.
:type directory_path: str
:param name: name of Dockerfile prefix
:type name: str
:param file_prefix: name of Dockerfile prefix
:type file_prefix: str
"""
file_name = f"{file_prefix}.Dockerfile" if file_prefix else "Dockerfile"
self._local_dockerfile_path = str(Path(directory_path, file_name).resolve())
Expand Down
14 changes: 7 additions & 7 deletions sdk/ml/azure-ai-ml/azure/ai/ml/_local_endpoints/endpoint_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ class EndpointStub:
def create_or_update(self, endpoint: OnlineEndpoint):
"""Create or update a local endpoint.
:param endpoint OnlineEndpoint: OnlineEndpoint entity to create or update.
:param OnlineEndpoint endpoint: OnlineEndpoint entity to create or update.
"""
self._create_endpoint_cache(endpoint=endpoint)
return endpoint

def get(self, endpoint_name: str):
"""Get a local endpoint.
:param endpoint_name str: Name of local endpoint to get.
:param str endpoint_name: Name of local endpoint to get.
"""
endpoint_path = self._get_endpoint_cache_file(endpoint_name=endpoint_name)
if endpoint_path.exists():
Expand All @@ -49,7 +49,7 @@ def list(self) -> Iterable[Path]:
def delete(self, endpoint_name: str):
"""Delete a local endpoint.
:param endpoint_name str: Name of local endpoint to delete.
:param str endpoint_name: Name of local endpoint to delete.
"""
build_directory = self._get_build_directory(endpoint_name=endpoint_name)
shutil.rmtree(build_directory)
Expand All @@ -67,7 +67,7 @@ def invoke(self):
def _create_endpoint_cache(self, endpoint: OnlineEndpoint):
"""Create or update a local endpoint cache.
:param endpoint OnlineEndpoint: OnlineEndpoint entity to create or update.
:param OnlineEndpoint endpoint: OnlineEndpoint entity to create or update.
"""
endpoint_cache_path = self._get_endpoint_cache_file(endpoint_name=endpoint.name)
endpoint_metadata = json.dumps(endpoint.dump())
Expand All @@ -77,7 +77,7 @@ def _create_endpoint_cache(self, endpoint: OnlineEndpoint):
def _get_endpoint_cache_file(self, endpoint_name: str) -> Path:
"""Get a local endpoint cache Path. Idempotent.
:param endpoint_name str: Name of local endpoint to get local cache.
:param str endpoint_name: Name of local endpoint to get local cache.
:returns Path: path to cached endpoint file.
"""
build_directory = self._create_build_directory(endpoint_name=endpoint_name)
Expand All @@ -86,7 +86,7 @@ def _get_endpoint_cache_file(self, endpoint_name: str) -> Path:
def _create_build_directory(self, endpoint_name: str) -> Path:
"""Create or update a local endpoint build directory.
:param endpoint_name str: Name of local endpoint to get local directory.
:param str endpoint_name: Name of local endpoint to get local directory.
:returns Path: path to endpoint build directory.
"""
build_directory = self._get_build_directory(endpoint_name=endpoint_name)
Expand All @@ -96,7 +96,7 @@ def _create_build_directory(self, endpoint_name: str) -> Path:
def _get_build_directory(self, endpoint_name: str) -> Path:
"""Get a local endpoint build directory. Idempotent.
:param endpoint_name str: Name of local endpoint to get local directory.
:param str endpoint_name: Name of local endpoint to get local directory.
:returns Path: path to endpoint build directory.
"""
return Path(self._get_inferencing_cache_dir(), endpoint_name)
Expand Down
4 changes: 2 additions & 2 deletions sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,11 @@ def from_config(
:param credential: The credential object for the workspace.
:type credential: ~azure.core.credentials.TokenCredential
:param path: The path to the config file or starting directory to search.
:keyword path: The path to the config file or starting directory to search.
The parameter defaults to starting the search in the current directory.
Defaults to None
:type path: typing.Union[os.PathLike, str]
:param file_name: Allows overriding the config file name to search for when path is a directory path.
:keyword file_name: Allows overriding the config file name to search for when path is a directory path.
(Default value = None)
:type file_name: str
:keyword str cloud: The cloud name to use. Defaults to AzureCloud.
Expand Down
4 changes: 2 additions & 2 deletions sdk/ml/azure-ai-ml/azure/ai/ml/_schema/core/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def _deserialize(self, value, attr, data, **kwargs):

def ComputeField(**kwargs):
"""
:param required : if set to True, it is not possible to pass None
:keyword required: if set to True, it is not possible to pass None
:type required: bool
"""
return UnionField(
Expand All @@ -658,7 +658,7 @@ def ComputeField(**kwargs):

def CodeField(**kwargs):
"""
:param required : if set to True, it is not possible to pass None
:keyword required: if set to True, it is not possible to pass None
:type required: bool
"""
return UnionField(
Expand Down
12 changes: 6 additions & 6 deletions sdk/ml/azure-ai-ml/azure/ai/ml/_telemetry/logging_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ def get_appinsights_log_handler(
:param user_agent: Information about the user's browser.
:type user_agent: Dict[str, str]
:param instrumentation_key: The Application Insights instrumentation key.
:param args: Optional arguments for formatting messages.
:type args: list
:keyword instrumentation_key: The Application Insights instrumentation key.
:type instrumentation_key: str
:param component_name: The component name.
:keyword component_name: The component name.
:type component_name: str
:param enable_telemetry: Whether to enable telemetry. Will be overriden to False if not in a Jupyter Notebook.
:keyword enable_telemetry: Whether to enable telemetry. Will be overriden to False if not in a Jupyter Notebook.
:type enable_telemetry: bool
:param args: Optional arguments for formatting messages.
:type args: list
:param kwargs: Optional keyword arguments for adding additional information to messages.
:keyword kwargs: Optional keyword arguments for adding additional information to messages.
:type kwargs: dict
:return: The logging handler.
:rtype: AzureMLSDKLogHandler
Expand Down
2 changes: 1 addition & 1 deletion sdk/ml/azure-ai-ml/azure/ai/ml/_utils/_endpoint_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def local_endpoint_polling_wrapper(func: Callable, message: str, **kwargs) -> An
:param Callable func: Name of the endpoint.
:param str message: Message to print out before starting operation write-out.
:param dict kwargs: kwargs to be passed to the func
:keyword dict kwargs: kwargs to be passed to the func
:return: The type returned by Func
"""
pool = concurrent.futures.ThreadPoolExecutor()
Expand Down
2 changes: 1 addition & 1 deletion sdk/ml/azure-ai-ml/azure/ai/ml/_utils/_http_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def decorated(self: "HttpPipeline", *args: P.args, **kwargs: P.kwargs) -> HttpRe
Accepts the same parameters as azure.core.rest.HttpRequest, except for the method.
All other kwargs are forwarded to azure.core.Pipeline.run
:param bool stream: Whether to stream the response, defaults to False
:keyword bool stream: Whether to stream the response, defaults to False
:return HttpResponse:
"""
request = HttpRequest(
Expand Down
11 changes: 7 additions & 4 deletions sdk/ml/azure-ai-ml/azure/ai/ml/_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,10 @@ def load_yaml(source: Optional[Union[AnyStr, PathLike, IO]]) -> Dict:
# via CLI, which is then populated through CLArgs.
"""Load a local YAML file.
:param file_path: The relative or absolute path to the local file.
:type file_path: str
:param source: Either
* The relative or absolute path to the local file.
* A readable File-like object
:type source: Optional[Union[AnyStr, PathLike, IO]]
:raises ~azure.ai.ml.exceptions.ValidationException: Raised if file or folder cannot be successfully loaded.
Details will be provided in the error message.
:return: A dictionary representation of the local file's contents.
Expand Down Expand Up @@ -775,7 +777,8 @@ def try_enable_internal_components(*, force=False):
"""Try to enable internal components for the current process. This is the only function outside _internal that
references _internal.
:param force: Force enable internal components even if enabled before.
:keyword force: Force enable internal components even if enabled before.
:type force: bool
"""
if is_internal_components_enabled():
from azure.ai.ml._internal import enable_internal_components_in_pipeline
Expand Down Expand Up @@ -972,7 +975,7 @@ def get_valid_dot_keys_with_wildcard(
:type root: Dict[str, Any]
:param dot_key_wildcard: Dot key with wildcard, e.g. "a.*.c".
:type dot_key_wildcard: str
:param validate_func: Validation function. It takes two parameters: the root node and the dot key parts.
:keyword validate_func: Validation function. It takes two parameters: the root node and the dot key parts.
If None, no validation will be performed.
:type validate_func: Optional[Callable[[List[str], Dict[str, Any]], bool]]
:return: List of valid dot keys.
Expand Down
48 changes: 24 additions & 24 deletions sdk/ml/azure-ai-ml/azure/ai/ml/automl/_automl_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def image_classification(
) -> ImageClassificationJob:
"""Creates an object for AutoML Image multi-class Classification job.
:param training_data: The training data to be used within the experiment.
:keyword training_data: The training data to be used within the experiment.
:type training_data: Input
:param target_column_name: The name of the label column.
:keyword target_column_name: The name of the label column.
This parameter is applicable to ``training_data`` and ``validation_data`` parameters.
:type target_column_name: str
:param primary_metric: The metric that Automated Machine Learning will optimize for model selection.
:keyword primary_metric: The metric that Automated Machine Learning will optimize for model selection.
Automated Machine Learning collects more metrics than it can optimize.
For more information on how metrics are calculated, see
https://docs.microsoft.com/azure/machine-learning/how-to-configure-auto-train#primary-metric.
Expand All @@ -67,17 +67,17 @@ def image_classification(
and precision_score_weighted
Defaults to accuracy.
:type primary_metric: Union[str, ClassificationPrimaryMetrics]
:param validation_data: The validation data to be used within the experiment.
:keyword validation_data: The validation data to be used within the experiment.
:type validation_data: Input, optional
:param validation_data_size: What fraction of the data to hold out for validation when user validation data
:keyword validation_data_size: What fraction of the data to hold out for validation when user validation data
is not specified. This should be between 0.0 and 1.0 non-inclusive.
Specify ``validation_data`` to provide validation data, otherwise set ``validation_data_size``
to extract validation data out of the specified training data.
Defaults to .2
:type validation_data_size: float, optional
:param kwargs: A dictionary of additional configuration parameters.
:keyword kwargs: A dictionary of additional configuration parameters.
:type kwargs: dict
:return: Image classification job object that can be submitted to an Azure ML compute for execution.
Expand Down Expand Up @@ -106,12 +106,12 @@ def image_classification_multilabel(
) -> ImageClassificationMultilabelJob:
"""Creates an object for AutoML Image multi-label Classification job.
:param training_data: The training data to be used within the experiment.
:keyword training_data: The training data to be used within the experiment.
:type training_data: Input
:param target_column_name: The name of the label column.
:keyword target_column_name: The name of the label column.
This parameter is applicable to ``training_data`` and ``validation_data`` parameters.
:type target_column_name: str
:param primary_metric: The metric that Automated Machine Learning will optimize for model selection.
:keyword primary_metric: The metric that Automated Machine Learning will optimize for model selection.
Automated Machine Learning collects more metrics than it can optimize.
For more information on how metrics are calculated, see
https://docs.microsoft.com/azure/machine-learning/how-to-configure-auto-train#primary-metric.
Expand All @@ -120,17 +120,17 @@ def image_classification_multilabel(
precision_score_weighted, and Iou
Defaults to Iou.
:type primary_metric: Union[str, ClassificationMultilabelPrimaryMetrics]
:param validation_data: The validation data to be used within the experiment.
:keyword validation_data: The validation data to be used within the experiment.
:type validation_data: Input, optional
:param validation_data_size: What fraction of the data to hold out for validation when user validation data
:keyword validation_data_size: What fraction of the data to hold out for validation when user validation data
is not specified. This should be between 0.0 and 1.0 non-inclusive.
Specify ``validation_data`` to provide validation data, otherwise set ``validation_data_size``
to extract validation data out of the specified training data.
Defaults to .2
:type validation_data_size: float, optional
:param kwargs: A dictionary of additional configuration parameters.
:keyword kwargs: A dictionary of additional configuration parameters.
:type kwargs: dict
:return: Image multi-label classification job object that can be submitted to an Azure ML compute for execution.
Expand Down Expand Up @@ -159,30 +159,30 @@ def image_object_detection(
) -> ImageObjectDetectionJob:
"""Creates an object for AutoML Image Object Detection job.
:param training_data: The training data to be used within the experiment.
:keyword training_data: The training data to be used within the experiment.
:type training_data: Input
:param target_column_name: The name of the label column.
:keyword target_column_name: The name of the label column.
This parameter is applicable to ``training_data`` and ``validation_data`` parameters.
:type target_column_name: str
:param primary_metric: The metric that Automated Machine Learning will optimize for model selection.
:keyword primary_metric: The metric that Automated Machine Learning will optimize for model selection.
Automated Machine Learning collects more metrics than it can optimize.
For more information on how metrics are calculated, see
https://docs.microsoft.com/azure/machine-learning/how-to-configure-auto-train#primary-metric.
Acceptable values: MeanAveragePrecision
Defaults to MeanAveragePrecision.
:type primary_metric: Union[str, ObjectDetectionPrimaryMetrics]
:param validation_data: The validation data to be used within the experiment.
:keyword validation_data: The validation data to be used within the experiment.
:type validation_data: Input, optional
:param validation_data_size: What fraction of the data to hold out for validation when user validation data
:keyword validation_data_size: What fraction of the data to hold out for validation when user validation data
is not specified. This should be between 0.0 and 1.0 non-inclusive.
Specify ``validation_data`` to provide validation data, otherwise set ``validation_data_size``
to extract validation data out of the specified training data.
Defaults to .2
:type validation_data_size: float, optional
:param kwargs: A dictionary of additional configuration parameters.
:keyword kwargs: A dictionary of additional configuration parameters.
:type kwargs: dict
:return: Image object detection job object that can be submitted to an Azure ML compute for execution.
Expand Down Expand Up @@ -211,30 +211,30 @@ def image_instance_segmentation(
) -> ImageInstanceSegmentationJob:
"""Creates an object for AutoML Image Instance Segmentation job.
:param training_data: The training data to be used within the experiment.
:keyword training_data: The training data to be used within the experiment.
:type training_data: Input
:param target_column_name: The name of the label column.
:keyword target_column_name: The name of the label column.
This parameter is applicable to ``training_data`` and ``validation_data`` parameters.
:type target_column_name: str
:param primary_metric: The metric that Automated Machine Learning will optimize for model selection.
:keyword primary_metric: The metric that Automated Machine Learning will optimize for model selection.
Automated Machine Learning collects more metrics than it can optimize.
For more information on how metrics are calculated, see
https://docs.microsoft.com/azure/machine-learning/how-to-configure-auto-train#primary-metric.
Acceptable values: MeanAveragePrecision
Defaults to MeanAveragePrecision.
:type primary_metric: Union[str, InstanceSegmentationPrimaryMetrics]
:param validation_data: The validation data to be used within the experiment.
:keyword validation_data: The validation data to be used within the experiment.
:type validation_data: Input, optional
:param validation_data_size: What fraction of the data to hold out for validation when user validation data
:keyword validation_data_size: What fraction of the data to hold out for validation when user validation data
is not specified. This should be between 0.0 and 1.0 non-inclusive.
Specify ``validation_data`` to provide validation data, otherwise set ``validation_data_size``
to extract validation data out of the specified training data.
Defaults to .2
:type validation_data_size: float, optional
:param kwargs: A dictionary of additional configuration parameters.
:keyword kwargs: A dictionary of additional configuration parameters.
:type kwargs: dict
:return: Image instance segmentation job
Expand Down
Loading

0 comments on commit 55420bd

Please sign in to comment.