-
Notifications
You must be signed in to change notification settings - Fork 188
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
Enhanced API generator to generate imports and headers #444
Conversation
Signed-off-by: saimedhi <saimedhi@amazon.com>
Signed-off-by: Sai Medhini Reddy Maryada <117196660+saimedhi@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## main #444 +/- ##
=======================================
Coverage 71.49% 71.49%
=======================================
Files 81 81
Lines 7668 7668
=======================================
Hits 5482 5482
Misses 2186 2186 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is way too hacky ;) Suggestions below?
@@ -15,7 +15,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) | |||
- Added `Search#collapse` ([#409](https://github.com/opensearch-project/opensearch-py/issues/409)) | |||
- Added support for the ISM API ([#398](https://github.com/opensearch-project/opensearch-py/pull/398)) | |||
- Added `trust_env` to `AIOHttpConnection` ([#398](https://github.com/opensearch-project/opensearch-py/pull/438)) | |||
|
|||
- Enhanced API generator to generate imports and headers ([#444](https://github.com/opensearch-project/opensearch-py/pull/444)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to "Added generating imports and headers to API generator"
|
||
# "CODE IS GENERATED" header is added below the license header in each generated module | ||
|
||
header_separator = "# -----------------------------------------------------" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand what's going on here ;) If it's a license header, just load it from a file and add it? There are only 2 possible license headers: new files with SPDX only, existing files with ES license grant.
with open(self.filepath, "w") as f: | ||
f.write(self.header) | ||
if update_header is True: | ||
f.write(self.header[:License_position]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Load this from a file and write it.
for api in self._apis: | ||
f.write(api.to_python()) | ||
|
||
# Added "delete point in time" API manually to prevent breaking changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes, this seems like a huge hack. We need to find a better way, for example by putting generated APIs into generated/
and adding patches/
folder that includes those APIs that should not be generated. You can use file names to decide which one needs to be which.
Description
Enhanced API generator to generate imports and headers
Issues Resolved
Closes #348
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.