Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@diegoferigo
Copy link
Member

No description provided.

@diegoferigo diegoferigo self-assigned this May 17, 2024
@diegoferigo diegoferigo marked this pull request as ready for review May 17, 2024 12:11
@diegoferigo diegoferigo changed the title Update CI/CD Update supported Python versions and update CI/CD May 17, 2024
Copy link
Collaborator

@flferretti flferretti left a comment

Choose a reason for hiding this comment

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

Thanks a lot Diego! LGTM, I left only a couple of minor comments

Comment on lines 54 to 86
def get_default_logging_level(env_var: str) -> logging.LoggingLevel:
"""
Get the default logging level.
Args:
env_var: The environment variable to check.
Returns:
The logging level to set.
"""

import os

try:
return logging.LoggingLevel[os.environ[env_var].upper()]

# Raise if the environment variable is set but the logging level is invalid.
except AttributeError:
msg = f"Invalid logging level defined in {env_var}: '{os.environ[env_var]}'"
raise ValueError(msg)

# If the environment variable is not set, return the logging level depending
# on the installation mode.
except KeyError:
return (
logging.LoggingLevel.DEBUG
if installation_is_editable()
else logging.LoggingLevel.WARNING
)


# Configure the logger with the default logging level.
logging.configure(level=get_default_logging_level(env_var="ROD_LOGGING_LEVEL"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the environment variable can only be ROD_LOGGING_LEVEL, is there a reason why you're passing it as the argument of this function? Can it just be hardcoded?

Suggested change
def get_default_logging_level(env_var: str) -> logging.LoggingLevel:
"""
Get the default logging level.
Args:
env_var: The environment variable to check.
Returns:
The logging level to set.
"""
import os
try:
return logging.LoggingLevel[os.environ[env_var].upper()]
# Raise if the environment variable is set but the logging level is invalid.
except AttributeError:
msg = f"Invalid logging level defined in {env_var}: '{os.environ[env_var]}'"
raise ValueError(msg)
# If the environment variable is not set, return the logging level depending
# on the installation mode.
except KeyError:
return (
logging.LoggingLevel.DEBUG
if installation_is_editable()
else logging.LoggingLevel.WARNING
)
# Configure the logger with the default logging level.
logging.configure(level=get_default_logging_level(env_var="ROD_LOGGING_LEVEL"))
def get_default_logging_level() -> logging.LoggingLevel:
"""
Get the default logging level.
Returns:
The logging level to set.
"""
import os
try:
return logging.LoggingLevel[os.environ["ROD_LOGGING_LEVEL"].upper()]
# Raise if the environment variable is set but the logging level is invalid.
except AttributeError:
msg = f"Invalid logging level defined in 'ROD_LOGGING_LEVEL'"
raise ValueError(msg)
# If the environment variable is not set, return the logging level depending
# on the installation mode.
except KeyError:
return (
logging.LoggingLevel.DEBUG
if installation_is_editable()
else logging.LoggingLevel.WARNING
)
# Configure the logger with the default logging level.
logging.configure(level=get_default_logging_level()

Copy link
Member Author

Choose a reason for hiding this comment

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

Having the environment variable explicitly defined makes it more visible to users rather than hiding it inside the logic of a function. Since we do not have documentation, I valued readability.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It makes sense, thanks for the explanation!

@diegoferigo diegoferigo force-pushed the update_ci branch 2 times, most recently from 37d1227 to 5e96179 Compare May 17, 2024 12:34
Co-authored-by: Filippo Luca Ferretti <[email protected]>
@diegoferigo
Copy link
Member Author

FYI @lorycontixd I had to update your test introduced in #33 to make it work on Windows.

@diegoferigo diegoferigo merged commit 11d2768 into main May 17, 2024
@diegoferigo diegoferigo deleted the update_ci branch May 17, 2024 12:55
@lorycontixd
Copy link

@diegoferigo Yep, no problem.

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.

4 participants