Skip to content

Commit 412f3b7

Browse files
authored
skip apiview generation for local run (#41577)
1 parent c4031e0 commit 412f3b7

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

tools/azure-sdk-tools/packaging_tools/sdk_generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ def main(generate_input, generate_output):
293293
package_entry["isMultiapi"] = is_multiapi_package(readme_python_content)
294294
package_entry["targetReleaseDate"] = data.get("targetReleaseDate", "")
295295
package_entry["allowInvalidNextVersion"] = data.get("allowInvalidNextVersion", False)
296+
package_entry["runInPipeline"] = run_in_pipeline
296297
result[package_name] = package_entry
297298
else:
298299
result[package_name]["path"].append(folder_name)

tools/azure-sdk-tools/packaging_tools/sdk_package.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,34 @@ def main(generate_input, generate_output):
7272
_LOGGER.info(f"[PACKAGE]({package_name})[CHANGELOG]:{md_output}")
7373
# Generate api stub File
7474
folder_name = package["path"][0]
75-
apiview_start_time = time.time()
76-
try:
77-
package_path = Path(sdk_folder, folder_name, package_name)
78-
check_call(
79-
[
80-
"python",
81-
"-m",
82-
"pip",
83-
"install",
84-
"-r",
85-
"../../../eng/apiview_reqs.txt",
86-
"--index-url=https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi"
87-
"/simple/",
88-
],
89-
cwd=package_path,
90-
timeout=600,
91-
)
92-
check_call(["apistubgen", "--pkg-path", "."], cwd=package_path, timeout=600)
93-
for file in os.listdir(package_path):
94-
if "_python.json" in file and package_name in file:
95-
package["apiViewArtifact"] = str(Path(package_path, file))
96-
except Exception as e:
97-
_LOGGER.debug(f"Fail to generate ApiView token file for {package_name}: {e}")
98-
_LOGGER.info(f"apiview generation cost time: {int(time.time() - apiview_start_time)} seconds")
75+
76+
if package["runInPipeline"]:
77+
apiview_start_time = time.time()
78+
try:
79+
package_path = Path(sdk_folder, folder_name, package_name)
80+
check_call(
81+
[
82+
"python",
83+
"-m",
84+
"pip",
85+
"install",
86+
"-r",
87+
"../../../eng/apiview_reqs.txt",
88+
"--index-url=https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi"
89+
"/simple/",
90+
],
91+
cwd=package_path,
92+
timeout=600,
93+
)
94+
check_call(["apistubgen", "--pkg-path", "."], cwd=package_path, timeout=600)
95+
for file in os.listdir(package_path):
96+
if "_python.json" in file and package_name in file:
97+
package["apiViewArtifact"] = str(Path(package_path, file))
98+
except Exception as e:
99+
_LOGGER.debug(f"Fail to generate ApiView token file for {package_name}: {e}")
100+
_LOGGER.info(f"apiview generation cost time: {int(time.time() - apiview_start_time)} seconds")
101+
else:
102+
_LOGGER.info("Skip ApiView generation for package that does not run in pipeline.")
99103

100104
# check generated files and update package["version"]
101105
if package_name.startswith("azure-mgmt-"):

0 commit comments

Comments
 (0)