Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: librarian time check #594

Merged
merged 11 commits into from
Aug 12, 2024
29 changes: 20 additions & 9 deletions scripts/build_twilio_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ def generate(spec_folder: str, spec_files: List[str], output_path: str, language
if language in generateForLanguages.get(spec_file):
generate_domain_for_language(spec_file, config_path, spec_folder, output_path, language, parent_dir)
else: generate_domain_for_language(spec_file, config_path, spec_folder, output_path, language, parent_dir)
if spec_files[0] in generateForLanguages and language in generateForLanguages.get(spec_files[0]):
print(f'Generating {output_path} from {spec_folder}')
run_openapi_generator(parent_dir, language)
print(f'Code generation completed at {output_path}')
elif spec_files[0] not in generateForLanguages:
print(f'Generating {output_path} from {spec_folder}')
run_openapi_generator(parent_dir, language)
print(f'Code generation completed at {output_path}')
if language in CLEANUP_IMPORT_LANGUAGES:
remove_unused_imports(output_path, language)
if language in REMOVE_DUPLICATE_IMPORT_LANGUAGES:
remove_duplicate_imports(output_path, language)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to create a different PR which has less commits. This PR has 9 commits.
Changes looks good, I have tested code is getting generated within 20 seconds.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It takes 20 seconds because we are passing directory, If file is passed it takes more time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get approval from @AsabuHere as well.

def generate_domain_for_language(spec_file: str, config_path: str, spec_folder: str, output_path: str, language: str, parent_dir: str) -> None:
full_path = os.path.join(spec_folder, spec_file)
Expand All @@ -62,18 +74,17 @@ def generate_domain_for_language(spec_file: str, config_path: str, spec_folder:
'arrayItemSuffix': ''
},
}

# print(config)
with open(full_config_path, 'w') as f:
Copy link
Contributor

@sbansla sbansla Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print can be removed.

f.write(json.dumps(config))

print(f'Generating {output_path} from {spec_folder}')
run_openapi_generator(parent_dir, language)
print(f'Code generation completed at {output_path}')

if language in CLEANUP_IMPORT_LANGUAGES:
remove_unused_imports(output_path, language)
if language in REMOVE_DUPLICATE_IMPORT_LANGUAGES:
remove_duplicate_imports(output_path, language)
# print(f'Generating {output_path} from {spec_folder}')
# run_openapi_generator(parent_dir, language)
# print(f'Code generation completed at {output_path}')
# if language in CLEANUP_IMPORT_LANGUAGES:
# remove_unused_imports(output_path, language)
# if language in REMOVE_DUPLICATE_IMPORT_LANGUAGES:
# remove_duplicate_imports(output_path, language)

def run_openapi_generator(parent_dir: Path, language: str) -> None:
properties = '-DapiTests=false'
Expand Down
Loading