-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: conditionally run pipelines in debug mode #223
Merged
qgerome
merged 11 commits into
main
from
HEXA-1076-implement-a-way-to-run-pipelines-in-debug-mode
Dec 4, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e616251
Consider the current log_level
YolanFery 2b1a272
Consider the current log_level
YolanFery 545f77a
Unit test
YolanFery a1d3e30
Unit test simplify
YolanFery 3b8b1cc
Dockerfile and small bug fix
YolanFery 5d9c50c
fix env conversion
YolanFery ec8b59b
Simplify Dockerfile
YolanFery 0edc50f
Instructions
YolanFery 4f0e3e7
Merge remote-tracking branch 'origin/main' into HEXA-1076-implement-a…
YolanFery 24abe8f
Renames
YolanFery 9e11310
Renames
YolanFery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM blsq/openhexa-base-environment:latest | ||
|
||
USER root | ||
|
||
WORKDIR /app | ||
COPY . /app | ||
|
||
RUN pip install build | ||
RUN python -m build . | ||
|
||
RUN pip install --no-cache-dir /app/dist/*.tar.gz && rm -rf /app/dist/*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Log levels for the pipeline runs.""" | ||
from enum import IntEnum | ||
|
||
|
||
class LogLevel(IntEnum): | ||
""" | ||
Enum representing different log levels. | ||
|
||
- Attributes: | ||
DEBUG (int): Debug level, value 0. | ||
INFO (int): Info level, value 1. | ||
WARNING (int): Warning level, value 2. | ||
ERROR (int): Error level, value 3. | ||
CRITICAL (int): Critical level, value 4. | ||
|
||
""" | ||
|
||
DEBUG = 0 | ||
INFO = 1 | ||
WARNING = 2 | ||
ERROR = 3 | ||
CRITICAL = 4 | ||
|
||
@classmethod | ||
def parse_log_level(cls, value) -> "LogLevel": | ||
"""Parse a log level from a string or integer.""" | ||
if isinstance(value, int) and 0 <= value <= 4: | ||
return LogLevel(value) | ||
if isinstance(value, str): | ||
if value.isdigit(): | ||
return cls.parse_log_level(int(value)) | ||
value = value.upper() | ||
if hasattr(cls, value): | ||
return getattr(cls, value) | ||
return cls.INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ include-package-data = true | |
[tool.ruff] | ||
line-length = 120 | ||
ignore = ["E501"] | ||
per-file-ignores = { "tests/**/test_*.py" = ["D100","D101","D102", "D103"] } # Ignore missing docstrings in tests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A preference but I am ok spending more time to provide some docstrings if we think it's valuable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm ok for the tests. |
||
|
||
[tool.ruff.lint] | ||
extend-select = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from unittest.mock import ANY, patch | ||
|
||
from openhexa.sdk.pipelines.run import CurrentRun, LogLevel | ||
|
||
|
||
@patch.object(CurrentRun, "_connected", True) | ||
@patch("openhexa.sdk.pipelines.run.graphql") | ||
def test_default_log_level(mock_graphql): | ||
current_run = CurrentRun() | ||
|
||
current_run.log_debug("This is a debug message") | ||
current_run.log_info("This is an info message") | ||
|
||
assert mock_graphql.call_count == 1 | ||
mock_graphql.assert_any_call(ANY, {"input": {"priority": "INFO", "message": "This is an info message"}}) | ||
|
||
|
||
@patch.object(CurrentRun, "_connected", True) | ||
@patch("openhexa.sdk.pipelines.run.graphql") | ||
def test_filtering_log_messages_based_on_settings(mock_graphql, settings): | ||
settings.log_level = LogLevel.ERROR | ||
current_run = CurrentRun() | ||
|
||
current_run.log_warning("This is a warning message") | ||
current_run.log_error("This is an error message") | ||
current_run.log_critical("This is a critical message") | ||
|
||
assert mock_graphql.call_count == 2 | ||
mock_graphql.assert_any_call(ANY, {"input": {"priority": "ERROR", "message": "This is an error message"}}) | ||
mock_graphql.assert_any_call(ANY, {"input": {"priority": "CRITICAL", "message": "This is a critical message"}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not need to check with the new Typing