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

await_spi_available added, add retry to get_region, and repackage logger #31

Merged
merged 1 commit into from
Oct 21, 2021

Conversation

marvinmarnold
Copy link
Contributor

This was previously in a utils module that was not being used for other
tools. It was also missing an init.py and was not being properly
exported. This pattern is slightly less verbose.

@marvinmarnold marvinmarnold force-pushed the marvinmarnold/fix-logger-packaging branch from 814b060 to cf1910a Compare October 18, 2021 21:38
@marvinmarnold marvinmarnold changed the title refactor: repackage logger await_spi_available added, add retry to get_region, and repackage logger Oct 18, 2021
@marvinmarnold marvinmarnold force-pushed the marvinmarnold/fix-logger-packaging branch from cf1910a to 001bdf5 Compare October 18, 2021 21:43
@marvinmarnold
Copy link
Contributor Author

@NebraLtd/developers this should be re-reviewed. I've added net new logic.

@shawaj shawaj requested review from robputt and a team October 20, 2021 05:35
@marvinmarnold marvinmarnold force-pushed the marvinmarnold/fix-logger-packaging branch 3 times, most recently from 97ac2c6 to 974cad6 Compare October 20, 2021 15:45
README.md Outdated Show resolved Hide resolved

logger.debug("No REGION_OVERRIDE defined, will retrieve from miner.")
with open(REGION_FILEPATH) as region_file:
LOGGER.debug("No region override set (value = %s), will retrieve from miner." % region_override) # noqa: E501
Copy link
Member

Choose a reason for hiding this comment

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

Is the idea here that we can pass other values to the retry_get_region command for different services should we need to?

Rather than hard coding it with the REGION_OVERRIDE and REGION_FILEPATH env variables?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Portability to other services is one reason. The bigger reason is I think its hard to maintain services with environment variables that are read in the depths of the code. I prefer to parameterize everything and make it up to the caller to decide where those parameters come from. Both in hm-config and hm-pktfwd refactors, __main__.py acts as a single entry point where the environment is read (eg: https://github.com/NebraLtd/hm-pktfwd/pull/59/files#diff-a6ac805adb62e68e9273e1c2fc120902571d800d5596a1df4dcb316b303d520aR30).

So if we decided to read all these values from a .env file in the future instead of the actual environment, we can just change the main function without having to dig through the code to find all the places the environment is read.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense. Looks like we don't actually use retry_get_region anywhere yet in any case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only in the upcoming refactor of hm-pktfwd.

setup.py Outdated
@@ -3,7 +3,7 @@

setup(
name='hm_pyhelper',
version='0.8.4',
version='0.8.6',
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 will bump this after a final review. Otherwise it will result in several unnecessary bumps, see: #20

@marvinmarnold marvinmarnold force-pushed the marvinmarnold/fix-logger-packaging branch from 9d7c921 to 7000d7b Compare October 21, 2021 14:45
- repackage logger from hm_pyhelper.utils to hm_pyhelper.logger
- LOGGER should be instantiated as uppercase by convention
- add tests
- add retry logic to get_region
- create await_spi_available helper
- fix override logic
@marvinmarnold marvinmarnold force-pushed the marvinmarnold/fix-logger-packaging branch from 83fc98d to fbc8817 Compare October 21, 2021 17:40
@marvinmarnold marvinmarnold merged commit 7930aa2 into master Oct 21, 2021
@marvinmarnold marvinmarnold deleted the marvinmarnold/fix-logger-packaging branch October 21, 2021 18:28
@marvinmarnold marvinmarnold restored the marvinmarnold/fix-logger-packaging branch October 21, 2021 19:39
@shawaj shawaj deleted the marvinmarnold/fix-logger-packaging branch October 21, 2021 21:47
@shawaj shawaj restored the marvinmarnold/fix-logger-packaging branch October 21, 2021 21:48
@shawaj shawaj deleted the marvinmarnold/fix-logger-packaging branch November 4, 2021 12:46
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.

3 participants