|
| 1 | +import sys |
1 | 2 | from typing import List, Dict, Any |
2 | 3 | import argparse |
3 | 4 | import json |
|
35 | 36 | ) |
36 | 37 | from .conf import CONF_NAME |
37 | 38 |
|
| 39 | +logging.basicConfig( |
| 40 | + stream=sys.stdout, |
| 41 | + format="%(asctime)s [%(levelname)s] %(message)s", |
| 42 | + datefmt="%Y-%m-%d %X", |
| 43 | +) |
38 | 44 | _LOGGER = logging.getLogger(__name__) |
39 | 45 |
|
40 | 46 |
|
@@ -275,25 +281,37 @@ def main(generate_input, generate_output): |
275 | 281 |
|
276 | 282 | for input_readme in readme_files: |
277 | 283 | _LOGGER.info(f"[CODEGEN]({input_readme})codegen begin") |
278 | | - if "resource-manager" in input_readme: |
279 | | - relative_path_readme = str(Path(spec_folder, input_readme)) |
280 | | - update_metadata_for_multiapi_package(spec_folder, input_readme) |
281 | | - del_outdated_files(relative_path_readme) |
282 | | - config = generate( |
283 | | - CONFIG_FILE, |
284 | | - sdk_folder, |
285 | | - [], |
286 | | - relative_path_readme, |
287 | | - spec_folder, |
288 | | - force_generation=True, |
289 | | - python_tag=python_tag, |
290 | | - ) |
291 | | - elif "data-plane" in input_readme: |
292 | | - config = gen_dpg(input_readme, data.get("autorestConfig", ""), dpg_relative_folder(spec_folder)) |
293 | | - else: |
294 | | - del_outdated_generated_files(str(Path(spec_folder, input_readme))) |
295 | | - config = gen_typespec(input_readme, spec_folder, data["headSha"], data["repoHttpsUrl"]) |
296 | | - package_names = get_package_names(sdk_folder) |
| 284 | + try: |
| 285 | + if "resource-manager" in input_readme: |
| 286 | + relative_path_readme = str(Path(spec_folder, input_readme)) |
| 287 | + update_metadata_for_multiapi_package(spec_folder, input_readme) |
| 288 | + del_outdated_files(relative_path_readme) |
| 289 | + config = generate( |
| 290 | + CONFIG_FILE, |
| 291 | + sdk_folder, |
| 292 | + [], |
| 293 | + relative_path_readme, |
| 294 | + spec_folder, |
| 295 | + force_generation=True, |
| 296 | + python_tag=python_tag, |
| 297 | + ) |
| 298 | + elif "data-plane" in input_readme: |
| 299 | + config = gen_dpg(input_readme, data.get("autorestConfig", ""), dpg_relative_folder(spec_folder)) |
| 300 | + else: |
| 301 | + del_outdated_generated_files(str(Path(spec_folder, input_readme))) |
| 302 | + config = gen_typespec(input_readme, spec_folder, data["headSha"], data["repoHttpsUrl"]) |
| 303 | + package_names = get_package_names(sdk_folder) |
| 304 | + except Exception as e: |
| 305 | + _LOGGER.error(f"fail to generate sdk for {input_readme}: {str(e)}") |
| 306 | + for hint_message in [ |
| 307 | + "======================================= Whant Can I do ========================================================================", |
| 308 | + "If you are from service team, please first check if the failure happens only to Python automation, or for all SDK automations. ", |
| 309 | + "If it happens for all SDK automations, please double check your Swagger / Typespec, and check whether there is error in ModelValidation and LintDiff. ", |
| 310 | + "If it happens to Python alone, you can open an issue to https://github.com/Azure/autorest.python/issues. Please include the link of this Pull Request in the issue.", |
| 311 | + "===============================================================================================================================", |
| 312 | + ]: |
| 313 | + _LOGGER.error(hint_message) |
| 314 | + raise e |
297 | 315 | _LOGGER.info(f"[CODEGEN]({input_readme})codegen end. [(packages:{str(package_names)})]") |
298 | 316 |
|
299 | 317 | # folder_name: "sdk/containerservice"; package_name: "azure-mgmt-containerservice" |
@@ -330,7 +348,7 @@ def main(generate_input, generate_output): |
330 | 348 | input_readme, |
331 | 349 | ) |
332 | 350 | except Exception as e: |
333 | | - _LOGGER.info(f"fail to update meta: {str(e)}") |
| 351 | + _LOGGER.error(f"fail to update meta: {str(e)}") |
334 | 352 |
|
335 | 353 | # Setup package locally |
336 | 354 | check_call( |
|
0 commit comments