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

Hardcode version to avoid import of importlib.metadata. #472

Merged
merged 2 commits into from Apr 16, 2024

Conversation

purple4reina
Copy link
Contributor

What does this PR do?

Hardcodes the __version__ value to avoid import of importlib.metadata.

Motivation

This speeds up cold start time.

Testing Guidelines

Additional Notes

Before
Screenshot 2024-04-15 at 10 06 37 AM

After
Screenshot 2024-04-15 at 10 06 19 AM

Note that the reduction in cold start time is slight, I would expect a speed up of only 4ms.
Screenshot 2024-04-15 at 10 08 25 AM

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)

@purple4reina purple4reina requested a review from a team as a code owner April 15, 2024 17:10
@@ -0,0 +1 @@
__version__ = "5.92.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Now we have to update this every time we do a release, could we add this to the internal docs?

echo

poetry version ${NEW_VERSION}
echo "__version__ = \"${NEW_VERSION}\"" > datadog_lambda/version.py
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, nvm, well done here!

Thanks for automating it.

__version__ = importlib_metadata.version(__name__)


from datadog_lambda.version import __version__ # noqa: E402
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, it looks like the linter is complaining on the GitHub side, since we are not using the variable, why might that be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the noqa: F401 comment to this line as well, should fix the linting issue.

@purple4reina purple4reina merged commit 6483fff into main Apr 16, 2024
36 of 38 checks passed
@purple4reina purple4reina deleted the rey.abolofia/version branch April 16, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants