Skip to content

Commit a5a7c3d

Browse files
Copilotkingernupur
andcommitted
Fix pylint C4766 and C4762 errors by removing exception details from higher-level logs
Co-authored-by: kingernupur <[email protected]>
1 parent eaaf8bd commit a5a7c3d

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/_azure_environments.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,16 @@ def _get_clouds_by_metadata_url(metadata_url: str) -> Dict[str, Dict[str, str]]:
297297
)
298298
return cli_cloud_dict
299299
except Exception as ex: # pylint: disable=broad-except
300-
module_logger.debug(
301-
"Error: Azure ML was unable to load cloud metadata from the url specified by %s. %s. "
300+
module_logger.warning(
301+
"Error: Azure ML was unable to load cloud metadata from the url specified by %s. "
302302
"This may be due to a misconfiguration of networking controls. Azure Machine Learning Python "
303303
"SDK requires outbound access to Azure Resource Manager. Please contact your networking team "
304304
"to configure outbound access to Azure Resource Manager on both Network Security Group and "
305305
"Firewall. For more details on required configurations, see "
306306
"https://learn.microsoft.com/azure/machine-learning/how-to-access-azureml-behind-firewall.",
307307
metadata_url,
308-
ex,
309308
)
309+
module_logger.debug("Exception details: %s", ex)
310310
return {}
311311

312312

@@ -330,7 +330,8 @@ def _convert_arm_to_cli(arm_cloud_metadata) -> Dict[str, Dict[str, str]]:
330330
EndpointURLS.REGISTRY_DISCOVERY_ENDPOINT: registry_discovery_url,
331331
}
332332
except KeyError as ex:
333-
module_logger.debug("Property on cloud not found in arm cloud metadata: %s", ex)
333+
module_logger.warning("Property on cloud not found in arm cloud metadata")
334+
module_logger.debug("Missing property: %s", ex)
334335
continue
335336
return cli_cloud_metadata_dict
336337

sdk/ml/azure-ai-ml/azure/ai/ml/_utils/_artifact_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ def _download_artifacts(
239239
try:
240240
self._redirect_artifacts_tool_path(organization)
241241
except Exception as e: # pylint: disable=W0718
242-
_logger.debug("Redirect artifacts tool path failed, details: %s", e)
242+
_logger.warning("Redirect artifacts tool path failed")
243+
_logger.debug("Exception details: %s", e)
243244

244245
retries += 1
245246
result = subprocess.run(

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/job.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,14 @@ def _from_rest_object( # pylint: disable=too-many-return-statements
334334
raise ex
335335
except Exception as ex:
336336
error_message = json.dumps(obj.as_dict(), indent=2) if obj else None
337+
module_logger.info(
338+
"Unable to parse the job resource: %s",
339+
error_message,
340+
)
337341
module_logger.debug(
338-
"Exception: %s.\n%s\nUnable to parse the job resource: %s.\n",
342+
"Exception: %s.\n%s",
339343
ex,
340344
traceback.format_exc(),
341-
error_message,
342345
)
343346
raise JobParsingError(
344347
message=str(ex),

sdk/ml/azure-ai-ml/azure/ai/ml/operations/_component_operations.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,11 @@ def _reset_version_if_no_change(self, component: Component, current_name: str, c
500500
)
501501
return component.version, component._to_rest_object()
502502
except ResourceNotFoundError as e:
503-
logger.debug("Failed to get component version, %s", e)
503+
logger.info("Failed to get component version")
504+
logger.debug("Exception details: %s", e)
504505
except Exception as e: # pylint: disable=W0718
505-
logger.debug("Failed to compare client_component_hash, %s", e)
506+
logger.error("Failed to compare client_component_hash")
507+
logger.debug("Exception details: %s", e)
506508

507509
return current_version, rest_component_resource
508510

sdk/ml/azure-ai-ml/azure/ai/ml/operations/_workspace_operations_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,8 @@ def resource(self) -> Any:
11331133
# duration comes in format: "PT1M56.3454108S"
11341134
module_logger.info("Total time : %s\n", from_iso_duration_format_min_sec(total_duration))
11351135
except Exception as e: # pylint: disable=W0718
1136-
module_logger.debug("Exception occurred while logging total duration: %s", e)
1136+
module_logger.warning("Exception occurred while logging total duration")
1137+
module_logger.debug("Exception details: %s", e)
11371138
return self.func()
11381139

11391140
# pylint: disable=docstring-missing-param

0 commit comments

Comments
 (0)