-
Notifications
You must be signed in to change notification settings - Fork 5
/
tasks.py
46 lines (30 loc) · 1.13 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from inspect import ArgSpec, getfullargspec
from unittest.mock import patch
import invoke
import seutil as su
from invoke import Collection
from teco.macros import Macros
logger = su.log.get_logger(__name__, su.log.INFO)
su.log.setup(Macros.log_file)
# ========================================
# fix invoke library not working well with type annotations
# monkeypatch.py
def fix_annotations():
"""
Pyinvoke doesnt accept annotations by default, this fix that
Based on: https://github.com/pyinvoke/invoke/pull/606
"""
def patched_inspect_getargspec(func):
spec = getfullargspec(func)
return ArgSpec(*spec[0:4])
org_task_argspec = invoke.tasks.Task.argspec
def patched_task_argspec(*args, **kwargs):
with patch(target="inspect.getargspec", new=patched_inspect_getargspec):
return org_task_argspec(*args, **kwargs)
invoke.tasks.Task.argspec = patched_task_argspec
fix_annotations()
# ========================================
from teco.tasks import data, exp
ns = Collection()
ns.add_collection(Collection.from_module(data))
ns.add_collection(Collection.from_module(exp))