From f5069b11e9185cbd22b9598c4ae344ab9f0123c5 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Mon, 9 May 2022 14:18:41 +0800 Subject: [PATCH 1/2] add data-plane generation --- tools/azure-sdk-tools/packaging_tools/auto_codegen.py | 3 --- tools/azure-sdk-tools/packaging_tools/auto_package.py | 3 ++- tools/azure-sdk-tools/packaging_tools/sdk_generator.py | 5 ----- tools/azure-sdk-tools/packaging_tools/sdk_package.py | 3 ++- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tools/azure-sdk-tools/packaging_tools/auto_codegen.py b/tools/azure-sdk-tools/packaging_tools/auto_codegen.py index 384ea05f2df2..815d42151108 100644 --- a/tools/azure-sdk-tools/packaging_tools/auto_codegen.py +++ b/tools/azure-sdk-tools/packaging_tools/auto_codegen.py @@ -20,9 +20,6 @@ def main(generate_input, generate_output): result = {} package_total = set() for input_readme in data["relatedReadmeMdFiles"]: - # skip codegen for data-plane temporarily since it is useless now and may block PR - if 'resource-manager' not in input_readme: - continue relative_path_readme = str(Path(spec_folder, input_readme)) _LOGGER.info(f"[CODEGEN]({input_readme})codegen begin") config = generate(CONFIG_FILE, sdk_folder, [], relative_path_readme, spec_folder, force_generation=True) diff --git a/tools/azure-sdk-tools/packaging_tools/auto_package.py b/tools/azure-sdk-tools/packaging_tools/auto_package.py index b359879331b5..bda9eb6f14a6 100644 --- a/tools/azure-sdk-tools/packaging_tools/auto_package.py +++ b/tools/azure-sdk-tools/packaging_tools/auto_package.py @@ -43,7 +43,8 @@ def main(generate_input, generate_output): "lite": f"pip install {package_name}", } # to distinguish with track1 - package["packageName"] = "track2_" + package["packageName"] + if 'azure-mgmt-' in package_name: + package["packageName"] = "track2_" + package["packageName"] result["packages"].append(package) with open(generate_output, "w") as writer: diff --git a/tools/azure-sdk-tools/packaging_tools/sdk_generator.py b/tools/azure-sdk-tools/packaging_tools/sdk_generator.py index 3397a4c6ddbe..5ec40df71e62 100644 --- a/tools/azure-sdk-tools/packaging_tools/sdk_generator.py +++ b/tools/azure-sdk-tools/packaging_tools/sdk_generator.py @@ -21,11 +21,6 @@ def main(generate_input, generate_output): package_total = set() input_readme = data["relatedReadmeMdFile"] - # skip codegen for data-plane temporarily since it is useless now and may block PR - if 'resource-manager' not in input_readme: - #continue - _LOGGER.error(f"[CODEGEN]({input_readme}) 'resource-manager' not in [relatedReadmeMdFile]") - return relative_path_readme = str(Path(spec_folder, input_readme)) _LOGGER.info(f"[CODEGEN]({input_readme})codegen begin") config = generate(CONFIG_FILE, sdk_folder, [], relative_path_readme, spec_folder, force_generation=True) diff --git a/tools/azure-sdk-tools/packaging_tools/sdk_package.py b/tools/azure-sdk-tools/packaging_tools/sdk_package.py index 3b2bb63e104b..f3f8ca5cbb4b 100644 --- a/tools/azure-sdk-tools/packaging_tools/sdk_package.py +++ b/tools/azure-sdk-tools/packaging_tools/sdk_package.py @@ -39,7 +39,8 @@ def main(generate_input, generate_output): package["artifacts"] = [str(dist_path / package_file) for package_file in os.listdir(dist_path)] package["result"] = "succeeded" # to distinguish with track1 - package["packageName"] = "track2_" + package["packageName"] + if 'azure-mgmt-' in package_name: + package["packageName"] = "track2_" + package["packageName"] package["packageFolder"] = package["path"][0] result["packages"].append(package) From eb61f6766b51612e055ec3ff24bbb8df00136024 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Mon, 9 May 2022 14:32:30 +0800 Subject: [PATCH 2/2] choose different config file --- swagger_to_sdk_config_dpg.json | 17 +++++++++++++++++ .../packaging_tools/auto_codegen.py | 5 +++-- .../packaging_tools/sdk_generator.py | 5 +++-- .../swaggertosdk/SwaggerToSdkCore.py | 1 + 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 swagger_to_sdk_config_dpg.json diff --git a/swagger_to_sdk_config_dpg.json b/swagger_to_sdk_config_dpg.json new file mode 100644 index 000000000000..4900e744c9e8 --- /dev/null +++ b/swagger_to_sdk_config_dpg.json @@ -0,0 +1,17 @@ +{ + "meta": { + "autorest_options": { + "version": "3.7.2", + "use": ["@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3"], + "python": "", + "sdkrel:python-sdks-folder": "./sdk/.", + "version-tolerant": "" + }, + "advanced_options": { + "create_sdk_pull_requests": true, + "sdk_generation_pull_request_base": "integration_branch" + }, + "repotag": "azure-sdk-for-python", + "version": "0.2.0" + } +} diff --git a/tools/azure-sdk-tools/packaging_tools/auto_codegen.py b/tools/azure-sdk-tools/packaging_tools/auto_codegen.py index 815d42151108..1adcca2750b6 100644 --- a/tools/azure-sdk-tools/packaging_tools/auto_codegen.py +++ b/tools/azure-sdk-tools/packaging_tools/auto_codegen.py @@ -4,7 +4,7 @@ from pathlib import Path from subprocess import check_call -from .swaggertosdk.SwaggerToSdkCore import (CONFIG_FILE,) +from .swaggertosdk.SwaggerToSdkCore import CONFIG_FILE, CONFIG_FILE_DPG from .generate_sdk import generate from .generate_utils import get_package_names, init_new_service, update_servicemetadata @@ -22,7 +22,8 @@ def main(generate_input, generate_output): for input_readme in data["relatedReadmeMdFiles"]: relative_path_readme = str(Path(spec_folder, input_readme)) _LOGGER.info(f"[CODEGEN]({input_readme})codegen begin") - config = generate(CONFIG_FILE, sdk_folder, [], relative_path_readme, spec_folder, force_generation=True) + config_file = CONFIG_FILE if 'resource-manager' in input_readme else CONFIG_FILE_DPG + config = generate(config_file, sdk_folder, [], relative_path_readme, spec_folder, force_generation=True) package_names = get_package_names(sdk_folder) _LOGGER.info(f"[CODEGEN]({input_readme})codegen end. [(packages:{str(package_names)})]") diff --git a/tools/azure-sdk-tools/packaging_tools/sdk_generator.py b/tools/azure-sdk-tools/packaging_tools/sdk_generator.py index 5ec40df71e62..37989986e33c 100644 --- a/tools/azure-sdk-tools/packaging_tools/sdk_generator.py +++ b/tools/azure-sdk-tools/packaging_tools/sdk_generator.py @@ -4,7 +4,7 @@ from pathlib import Path from subprocess import check_call -from .swaggertosdk.SwaggerToSdkCore import (CONFIG_FILE) +from .swaggertosdk.SwaggerToSdkCore import CONFIG_FILE, CONFIG_FILE_DPG from .generate_sdk import generate from .generate_utils import get_package_names, init_new_service, update_servicemetadata @@ -23,7 +23,8 @@ def main(generate_input, generate_output): input_readme = data["relatedReadmeMdFile"] relative_path_readme = str(Path(spec_folder, input_readme)) _LOGGER.info(f"[CODEGEN]({input_readme})codegen begin") - config = generate(CONFIG_FILE, sdk_folder, [], relative_path_readme, spec_folder, force_generation=True) + config_file = CONFIG_FILE if 'resource-manager' in input_readme else CONFIG_FILE_DPG + config = generate(config_file, sdk_folder, [], relative_path_readme, spec_folder, force_generation=True) package_names = get_package_names(sdk_folder) _LOGGER.info(f"[CODEGEN]({input_readme})codegen end. [(packages:{str(package_names)})]") diff --git a/tools/azure-sdk-tools/packaging_tools/swaggertosdk/SwaggerToSdkCore.py b/tools/azure-sdk-tools/packaging_tools/swaggertosdk/SwaggerToSdkCore.py index 802d10013b2d..f700bd3e668d 100644 --- a/tools/azure-sdk-tools/packaging_tools/swaggertosdk/SwaggerToSdkCore.py +++ b/tools/azure-sdk-tools/packaging_tools/swaggertosdk/SwaggerToSdkCore.py @@ -22,6 +22,7 @@ _LOGGER = logging.getLogger(__name__) CONFIG_FILE = "swagger_to_sdk_config_autorest.json" +CONFIG_FILE_DPG = "swagger_to_sdk_config_dpg.json" DEFAULT_COMMIT_MESSAGE = "Generated from {hexsha}"