10
10
from typing import List , Any , Dict
11
11
from packaging .version import Version
12
12
from ghapi .all import GhApi
13
+ from github import Github
13
14
from azure .storage .blob import BlobServiceClient , ContainerClient
14
15
from datetime import datetime , timedelta
15
16
@@ -237,10 +238,14 @@ def edit_sdk_readme(content: List[str]):
237
238
238
239
modify_file (sdk_readme , edit_sdk_readme )
239
240
241
+ @property
242
+ def readme_python_md_path (self )-> Path :
243
+ return Path (self .spec_repo ) / "specification" / self .spec_readme .split ("specification/" )[- 1 ].replace ("readme.md" , "readme.python.md" )
244
+
240
245
# Use the template to update readme and setup by packaging_tools
241
246
@return_origin_path
242
247
def check_file_with_packaging_tool (self ):
243
- python_md = Path ( self .spec_repo ) / "specification" / self . spec_readme . split ( "specification/" )[ - 1 ]. replace ( "readme.md" , "readme.python.md" )
248
+ python_md = self .readme_python_md_path
244
249
title = ""
245
250
if python_md .exists ():
246
251
with open (python_md , "r" ) as file_in :
@@ -398,6 +403,21 @@ def check_package_size(self):
398
403
if os .path .getsize (package ) > 2 * 1024 * 1024 :
399
404
self .check_package_size_result .append (f'ERROR: Package size is over 2MBytes: { Path (package ).name } !!!' )
400
405
406
+ def check_model_flatten (self ):
407
+ last_version = self .get_last_release_version ()
408
+ if last_version == "" or last_version .startswith ("1.0.0b" ):
409
+ with open (self .readme_python_md_path , 'r' ) as file_in :
410
+ content = file_in .read ()
411
+
412
+ if "flatten-models: false" not in content and self .issue_link :
413
+ api = Github (self .bot_token ).get_repo ("Azure/sdk-release-request" )
414
+ issue_number = int (self .issue_link .split ('/' )[- 1 ])
415
+ issue = api .get_issue (issue_number )
416
+ assignee = issue .assignee .login if issue .assignee else ""
417
+ message = "please set `flatten-models: false` in readme.python.md"
418
+ issue .create_comment (f'@{ assignee } , { message } ' )
419
+ raise Exception (message )
420
+
401
421
def check_file (self ):
402
422
self .check_file_with_packaging_tool ()
403
423
self .check_pprint_name ()
@@ -406,6 +426,7 @@ def check_file(self):
406
426
self .check_changelog_file ()
407
427
self .check_dev_requirement ()
408
428
self .check_package_size ()
429
+ self .check_model_flatten ()
409
430
410
431
def sdk_code_path (self ) -> str :
411
432
return str (Path (f'sdk/{ self .sdk_folder } /azure-mgmt-{ self .package_name } ' ))
0 commit comments