-
Notifications
You must be signed in to change notification settings - Fork 3.3k
4117433: Update _asset_utils.py to fix Performance issue #46572
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,9 +5,9 @@ | |||||||
| # pylint: disable=protected-access,too-many-lines | ||||||||
|
|
||||||||
| import hashlib | ||||||||
| import json | ||||||||
| import logging | ||||||||
| import os | ||||||||
| import json | ||||||||
| import uuid | ||||||||
| import warnings | ||||||||
| from concurrent.futures import ThreadPoolExecutor, as_completed | ||||||||
|
|
@@ -16,7 +16,17 @@ | |||||||
| from os import PathLike | ||||||||
| from pathlib import Path | ||||||||
| from platform import system | ||||||||
| from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Tuple, Union, cast | ||||||||
| from typing import ( | ||||||||
| TYPE_CHECKING, | ||||||||
| Any, | ||||||||
| Dict, | ||||||||
| Iterable, | ||||||||
| List, | ||||||||
| Optional, | ||||||||
| Tuple, | ||||||||
| Union, | ||||||||
| cast, | ||||||||
| ) | ||||||||
|
|
||||||||
| from colorama import Fore | ||||||||
| from tqdm import TqdmWarning, tqdm | ||||||||
|
|
@@ -49,14 +59,19 @@ | |||||||
| ModelContainersOperations, | ||||||||
| ModelVersionsOperations, | ||||||||
| ) | ||||||||
| from azure.ai.ml._restclient.arm_ml_service.models import ( | ||||||||
| DataVersionBase as DataVersionBaseData, | ||||||||
| ModelVersion as ModelVersionData, | ||||||||
| from azure.ai.ml._restclient.v2022_05_01.models import ( | ||||||||
| DataVersionBaseData, | ||||||||
| ModelVersionData, | ||||||||
| ModelVersionResourceArmPaginatedResult, | ||||||||
| ) | ||||||||
| from azure.ai.ml._restclient.arm_ml_service.models import PendingUploadRequestDto | ||||||||
| from azure.ai.ml._restclient.v2023_04_01.models import PendingUploadRequestDto | ||||||||
|
Comment on lines
+62
to
+67
|
||||||||
| from azure.ai.ml._utils._pathspec import GitWildMatchPattern, normalize_file | ||||||||
| from azure.ai.ml._utils.utils import convert_windows_path_to_unix, retry, snake_to_camel | ||||||||
| from azure.ai.ml.constants._common import MAX_AUTOINCREMENT_ATTEMPTS, DefaultOpenEncoding, OrderString | ||||||||
| from azure.ai.ml.constants._common import ( | ||||||||
| MAX_AUTOINCREMENT_ATTEMPTS, | ||||||||
| DefaultOpenEncoding, | ||||||||
| OrderString, | ||||||||
| ) | ||||||||
| from azure.ai.ml.entities._assets.asset import Asset | ||||||||
| from azure.ai.ml.exceptions import ( | ||||||||
| AssetPathException, | ||||||||
|
|
@@ -383,7 +398,14 @@ def get_upload_files_from_folder( | |||||||
| ) -> List[str]: | ||||||||
| path = Path(path) | ||||||||
| upload_paths = [] | ||||||||
| for root, _, files in os.walk(path, followlinks=True): | ||||||||
| for root, dirs, files in os.walk(path, followlinks=True, topdown=True): | ||||||||
| # Skip ignored directories to avoid descending into them | ||||||||
| # This significantly improves performance when large ignored folders (e.g., .venv) are present | ||||||||
| dirs[:] = [ | ||||||||
| d for d in dirs | ||||||||
| if not ignore_file.is_file_excluded(Path(root).joinpath(d).as_posix()) | ||||||||
| ] | ||||||||
|
Comment on lines
+401
to
+407
|
||||||||
|
|
||||||||
| upload_paths += list( | ||||||||
| traverse_directory( | ||||||||
| root, | ||||||||
|
|
@@ -922,7 +944,7 @@ def _get_latest( | |||||||
| except StopIteration: | ||||||||
| latest = None | ||||||||
|
|
||||||||
| if latest and isinstance(latest, ModelVersionData): | ||||||||
| if latest and isinstance(latest, ModelVersionResourceArmPaginatedResult): | ||||||||
| # Data list return object doesn't require this since its elements are already DatasetVersionResources | ||||||||
| latest = cast(ModelVersionData, latest) | ||||||||
|
Comment on lines
+947
to
949
|
||||||||
| if latest and isinstance(latest, ModelVersionResourceArmPaginatedResult): | |
| # Data list return object doesn't require this since its elements are already DatasetVersionResources | |
| latest = cast(ModelVersionData, latest) |
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 are trailing spaces in the multi-line
from typing import (...)block (e.g., afterTYPE_CHECKING,/Any,/Dict,etc.). These will trip linters (W291). Please remove the trailing whitespace and keep formatting consistent.