Skip to content

Commit 0e4a03b

Browse files
authored
Fix CI Analyze Step for azure-ai-inference and get_version_py bug (#43947)
* sanity * attempt fix * try adding pre flag * add uv case * remove unnecessary * add back req * format * refactor directory skipping * minor doc edit * add egg info condition * remove doc and format * remove tests condition since it's in exclude * format
1 parent 3e5b654 commit 0e4a03b

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

eng/tools/azure-sdk-tools/ci_tools/parsing/parse_functions.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@ def _add_optional_fields(pkg_info, metadata: Dict[str, Any]) -> None:
192192
metadata[field] = value
193193

194194

195+
def get_dirs_to_skip(subdirs: List[str]) -> List[str]:
196+
"""
197+
Given a list of subdirectories, return those that are not part of the package source and should be skipped.
198+
199+
:param List[str] subdirs: List of subdirectory names
200+
:rtype: List[str]
201+
:return: Filtered list of subdirectory names to skip
202+
"""
203+
return [x for x in subdirs if (x.startswith(("_", ".")) or x == "build" or x in EXCLUDE or x.endswith(".egg-info"))]
204+
205+
195206
def discover_namespace(package_root_path: str) -> Optional[str]:
196207
"""
197208
Discover the true namespace of a package by walking through its directory structure
@@ -207,11 +218,7 @@ def discover_namespace(package_root_path: str) -> Optional[str]:
207218
namespace = None
208219

209220
for root, subdirs, files in os.walk(package_root_path):
210-
# Ignore any modules with name starts with "_"
211-
# For e.g. _generated, _shared etc
212-
# Ignore build, which is created when installing a package from source.
213-
# Ignore tests, which may have an __init__.py but is not part of the package.
214-
dirs_to_skip = [x for x in subdirs if x.startswith(("_", ".", "test", "build")) or x in EXCLUDE]
221+
dirs_to_skip = get_dirs_to_skip(subdirs)
215222
for d in dirs_to_skip:
216223
logging.debug("Dirs to skip: {}".format(dirs_to_skip))
217224
subdirs.remove(d)
@@ -695,7 +702,8 @@ def get_version_py(setup_path: str) -> Optional[str]:
695702

696703
# Find path to _version.py recursively
697704
for root, dirs, files in os.walk(file_path):
698-
dirs[:] = [d for d in dirs if d not in EXCLUDE and not d.endswith(".egg-info") and not d.startswith(".")]
705+
dirs_to_skip = get_dirs_to_skip(dirs)
706+
dirs[:] = [d for d in dirs if d not in dirs_to_skip]
699707

700708
if VERSION_PY in files:
701709
return os.path.join(root, VERSION_PY)

sdk/ai/azure-ai-inference/dev_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
../../core/azure-core
33
../../core/azure-core-tracing-opentelemetry
44
../../monitor/azure-monitor-opentelemetry
5+
../../monitor/azure-monitor-opentelemetry-exporter
56
aiohttp
67
opentelemetry-sdk
78
types-pyyaml

0 commit comments

Comments
 (0)