Skip to content

Commit 4382ee3

Browse files
authored
[Pipeline] add process to call multiapi combiner (Azure#30284)
* update * update * fix install
1 parent aaeb59e commit 4382ee3

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import os
55
import re
6+
from functools import wraps
67

78
from azure_devtools.ci_tools.git_tools import get_add_diff_file_list
89
from pathlib import Path
@@ -27,6 +28,17 @@ def dpg_relative_folder(spec_folder: str) -> str:
2728
return ("../" * 4) + spec_folder + "/"
2829

2930

31+
def return_origin_path(func):
32+
@wraps(func)
33+
def wrapper(*args, **kwargs):
34+
current_path = os.getcwd()
35+
result = func(*args, **kwargs)
36+
os.chdir(current_path)
37+
return result
38+
39+
return wrapper
40+
41+
3042
def get_package_names(sdk_folder):
3143
files = get_add_diff_file_list(sdk_folder)
3244
matches = {_SDK_FOLDER_RE.search(f) for f in files}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from subprocess import check_call
66
import shutil
77
import re
8+
import os
89

910
from .swaggertosdk.SwaggerToSdkCore import (
1011
CONFIG_FILE,
@@ -20,11 +21,18 @@
2021
dpg_relative_folder,
2122
gen_typespec,
2223
update_typespec_location,
24+
return_origin_path,
2325
)
2426

2527
_LOGGER = logging.getLogger(__name__)
2628

2729

30+
@return_origin_path
31+
def multiapi_combiner(sdk_code_path: str):
32+
os.chdir(sdk_code_path)
33+
check_call(f"python {str(Path('../../../tools/azure-sdk-tools/packaging_tools/multiapi_combiner.py'))} --pkg-path={os.getcwd()}", shell=True)
34+
check_call("pip install -e .", shell=True)
35+
2836
def del_outdated_folder(readme: str):
2937
python_readme = Path(readme).parent / "readme.python.md"
3038
if not python_readme.exists():
@@ -114,6 +122,7 @@ def main(generate_input, generate_output):
114122
package_names = get_package_names(sdk_folder)
115123
_LOGGER.info(f"[CODEGEN]({input_readme})codegen end. [(packages:{str(package_names)})]")
116124

125+
# folder_name: "sdk/containerservice"; package_name: "azure-mgmt-containerservice"
117126
for folder_name, package_name in package_names:
118127
if package_name in package_total:
119128
continue
@@ -168,6 +177,11 @@ def main(generate_input, generate_output):
168177
shell=True,
169178
)
170179

180+
# use multiapi combiner to combine multiapi package
181+
if package_name in ("azure-mgmt-network"):
182+
_LOGGER.info(f"start to combine multiapi package: {package_name}")
183+
multiapi_combiner(sdk_code_path)
184+
171185
# remove duplicates
172186
for value in result.values():
173187
value["path"] = list(set(value["path"]))

0 commit comments

Comments
 (0)