-
Notifications
You must be signed in to change notification settings - Fork 43
Store logs on free resources #1782
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9841222
store logs on freeresouces and modify endpoints to get directly from ray
korgan00 4d7672b
added tests
korgan00 280a93a
black formatted
korgan00 fd67d9a
Merge branch 'feat/logs-refactor' into store-logs-on-free-resources
avilches 53fef58
improve test
korgan00 5ec3891
Merge remote-tracking branch 'origin/store-logs-on-free-resources' in…
korgan00 9bf370f
improve legibility
korgan00 2c771cd
improve test
korgan00 8f1a19b
improve tests
korgan00 4c063f1
apply changes
korgan00 b04e3a6
black
korgan00 e11e400
fix lint
korgan00 037ed50
change import
korgan00 2302126
Merge branch 'feat/logs-refactor' into store-logs-on-free-resources
korgan00 86d18eb
Merge branch 'feat/logs-refactor' into store-logs-on-free-resources
korgan00 5e5e6c5
fix ray file
korgan00 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 hidden or 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,17 @@ | ||
| """Methods for filtering job logs.""" | ||
| import re | ||
|
|
||
|
|
||
| def extract_public_logs(text: str) -> str: | ||
| """ | ||
| This filter the logs to get the public ones only. | ||
|
|
||
| Args: | ||
| text: str | ||
|
|
||
| Return: | ||
| str -> The log filtered out | ||
| """ | ||
| pattern = re.compile(r"^\[PUBLIC\]", re.IGNORECASE) | ||
| lines = [line[9:] for line in text.splitlines() if pattern.match(line)] | ||
| return "\n".join(lines) + "\n" if lines else "" |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
File renamed without changes.
File renamed without changes.
This file contains hidden or 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,49 @@ | ||
| """Tests for filter_logs.""" | ||
|
|
||
| from rest_framework.test import APITestCase | ||
|
|
||
| from api.domain.function.filter_logs import extract_public_logs | ||
|
|
||
|
|
||
| class TestFilterLogs(APITestCase): | ||
| """Tests for filter_logs.""" | ||
|
|
||
| def test_extract_public_logs(self): | ||
| """Tests compute resource creation command.""" | ||
|
|
||
| log = """ | ||
|
|
||
| third_party.run_function:INFO:2024-11-15 11:30:32,124: third party setting up... | ||
| system 1 up... | ||
| system 2 up... | ||
| Setup complete! | ||
| [PUBLIC] sim_entrypoint.run_function:INFO:2024-10-15 11:30:32,123: Starting application | ||
| [private] sim_entrypoint.run_function:INFO:2024-10-15 11:30:32,123: Mapping | ||
| [PUBLIC] sim_entrypoint.run_function:INFO:2024-11-15 11:30:32,124: Backend = { | ||
| [PUBLIC] "name": "ibm_123" | ||
| [PUBLIC] } | ||
| third_party.run_function:INFO:2024-11-15 11:30:32,124: running_options = { | ||
| "options_group": { | ||
| "important": true, | ||
| "very_important": true, | ||
| "more_options": { | ||
| "gigabytes": 512, | ||
| "also_gigabytes": 512 | ||
| } | ||
| }, | ||
| } | ||
| [puBLic] sim_entrypoint.run_function:INFO:2024-11-15 11:30:32,124: Starting | ||
| [PRIVATE] sim_entrypoint.run_function:INFO:2024-11-15 11:30:32,124: Private information | ||
|
|
||
| """ | ||
|
|
||
| expected_output = """sim_entrypoint.run_function:INFO:2024-10-15 11:30:32,123: Starting application | ||
| sim_entrypoint.run_function:INFO:2024-11-15 11:30:32,124: Backend = { | ||
| "name": "ibm_123" | ||
| } | ||
| sim_entrypoint.run_function:INFO:2024-11-15 11:30:32,124: Starting | ||
| """ | ||
|
|
||
| output_log = extract_public_logs(log) | ||
|
|
||
| self.assertEquals(output_log, expected_output) |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
good catch @korgan00 ! If we trim the logs, how can we will know later if the no_resources_log message is in the logs? :)