-
Notifications
You must be signed in to change notification settings - Fork 10
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
VSCode Logging #506
base: main
Are you sure you want to change the base?
VSCode Logging #506
Conversation
for more information, see https://pre-commit.ci
…into vscode-integration
for more information, see https://pre-commit.ci
…into vscode-integration
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #506 +/- ##
==========================================
- Coverage 97.80% 97.47% -0.34%
==========================================
Files 106 113 +7
Lines 8710 9411 +701
==========================================
+ Hits 8519 9173 +654
- Misses 191 238 +47
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I added the logging code for the task execution to the hook in live.py, but this seems a bit odd considering the project structure. I could move it to a new implementation of the hook in logging.py that uses |
Hi @mj023, thanks for your effort!
|
src/_pytask/collect.py
Outdated
for task in tasks | ||
] | ||
thread = Thread( | ||
target=send_logging_vscode, |
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.
Check out the daemon
keyword for threads and see whether it might be helpful in our situation.
src/_pytask/live.py
Outdated
@@ -168,6 +171,27 @@ def pytask_execute_task_log_start(self, task: PTask) -> bool: | |||
@hookimpl | |||
def pytask_execute_task_log_end(self, report: ExecutionReport) -> bool: | |||
"""Mark a task as being finished and update outcome.""" | |||
if report.outcome == TaskOutcome.FAIL and report.exc_info is not None: | |||
with console.capture() as capture: |
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.
Check out render_to_string
from console.py
|
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…into vscode-integration
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…into vscode-integration
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
I think everything should be ready now, but I'm having a little trouble writing the tests. I have moved the code to a new vscode.py module, replaced the requests library with the standard urllib and added a guard so the code is only executed if a specific environment variable is set. I then added two new tests, so that almost everything I added is covered, but I'm not sure if I did that correctly. Furthermore the tests on ubuntu 3.12 now failed and I can not figure out why. |
…into vscode-integration
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Update `vscode.py`
Add additional logging for the VSCode Extension.
Changes
The logging information will be in JSON-Format and is sent to a port that is specified by the user, by setting an environment variable. If the environment variable is not set, no logging will happen. The communication happens in a new thread so that pytask is not blocked. Deamon Threads are not used, because we do not want the threads to be killed when the main pytask program ends, as this can result in them not being able to send the info if pytask finishes very quickly.
Info the extension needs
Collection: The ExitCode of the Collection and a list of the collected tasks with the name and path of the task.
Example:
{exitcode: "OK", tasks: [ {name: "task1", path: "C:\Documents\task_task1.py"}, ...]}
Execution: Every time a task finishes, the name, the outcome and if the task failed also the execution info eg. the error message.
Example:
{name: "task1", outcome: "FAIL", exc_info: "Rendered String of Error message"}