Skip to content

Commit bf68005

Browse files
committed
Adapted for pytask 0.4.1
1 parent d4d6fb9 commit bf68005

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ This is a plugin for Pytask. It is needed to use the Pytask VS Code Extension.
55

66
## Installation
77

8-
pytask-vscode is available on [PyPI](https://pypi.org/project/pytask-vscode) and [Anaconda.org](https://anaconda.org/conda-forge/pytask-vscode). Install it with
8+
pytask-vscode is available on [PyPI](https://test.pypi.org/project/pytask-vscode/). Install it with
99

1010
```console
11-
$ pip install pytask-vscode
11+
$ pip install -i https://test.pypi.org/simple/ pytask-vscode
1212

13-
# or
14-
15-
$ conda install -c conda-forge pytask-vscode
1613
```
1714

1815
## Changes

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
- toml
1212

1313
# Package dependencies
14-
- pytask >=0.2
14+
- pytask >=0.4.1
1515
- pytask-parallel >=0.2
1616
- requests
1717

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ project_urls =
2929
packages = find:
3030
install_requires =
3131
click
32-
pytask>=0.2
32+
pytask>=0.4.1
3333
requests
3434
python_requires = >=3.7
3535
include_package_data = True

src/pytask_vscode/execution.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import pytask
22
import json
33
import requests
4+
from contextlib import redirect_stdout
5+
import io
46

57
@pytask.hookimpl(tryfirst=True)
6-
def pytask_collect_log(session: pytask.Session, reports: list[pytask.CollectionReport], tasks: list[pytask.Task]) -> None:
8+
def pytask_collect_log(session: pytask.Session, reports: list[pytask.CollectionReport], tasks: list[pytask.PTask]) -> None:
79
try:
810
if session.config['command'] == 'collect':
9-
result = [{'name' : task.short_name, 'path' : str(task.path)} for task in tasks]
11+
result = [{'name' : task.name.split('/')[-1], 'path' : str(task.path)} if isinstance(task,pytask.PTaskWithPath) else {'name' : task.name, 'path' : ''} for task in tasks]
1012
res = requests.post('http://localhost:6000/pytask', json={"exitcode" : session.exit_code, "tasks": result}, timeout=0.0001)
1113
except requests.exceptions.ReadTimeout:
1214
pass
@@ -17,8 +19,14 @@ def pytask_collect_log(session: pytask.Session, reports: list[pytask.CollectionR
1719
@pytask.hookimpl(tryfirst=True)
1820
def pytask_execute_task_log_end(session: pytask.Session, report: pytask.ExecutionReport) -> None:
1921

20-
try:
21-
result = {'type': 'task', 'name' : report.task.short_name, 'outcome' : str(report.outcome)}
22+
try:
23+
if report.outcome == pytask.TaskOutcome.FAIL:
24+
with pytask.console.capture() as capture:
25+
pytask.console.print(pytask.render_exc_info(report.exc_info[0], report.exc_info[1], report.exc_info[2]))
26+
s = capture.get()
27+
result = {'type': 'task', 'name' : report.task.name.split('/')[-1], 'outcome' : str(report.outcome), 'exc_info' : s}
28+
else:
29+
result = {'type': 'task', 'name' : report.task.name.split('/')[-1], 'outcome' : str(report.outcome)}
2230
res = requests.post('http://localhost:6000/pytask', json=result, timeout=0.00001)
2331
except requests.exceptions.ReadTimeout:
2432
pass

0 commit comments

Comments
 (0)