-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathtasks.py
60 lines (46 loc) · 1.47 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import sys
from pathlib import Path
import shutil
from glob import iglob
from invoke import task
if not Path('LICENSE').exists():
sys.exit('Error: Run the command from the root folder (the directory '
'with the LICENSE file).')
@task
def setup(c, create_conda=True):
"""
Setup conda env
"""
cmd = ('eval "$(conda shell.bash hook)"'
' && conda env create --file environment.yml --force'
' && conda activate projects '
' &&') if create_conda else ''
cmd += (' pip install --editable "_pkg[dev]"'
' && pip install --editable templates/python-api/'
' && pip install --editable templates/ml-advanced/'
' && pip install invoke')
c.run(cmd)
c.run('cd templates/spec-api-sql/setup && bash setup.sh')
print('Done! Activate your environment with:\n'
'conda activate projects')
@task
def clear(c):
"""Clears output folders
"""
for f in iglob('*/output'):
print(f'Deleting contents of: {f}')
shutil.rmtree(f)
Path(f).mkdir()
for f in iglob('*/products'):
print(f'Deleting contents of: {f}')
shutil.rmtree(f)
Path(f).mkdir()
for f in iglob('*/*.metadata'):
print(f'Deleting contents of: {f}')
Path(f).unlink()
@task
def build(c, name=None, force=False, log=False):
"""See CONTRIBUTING.md for details
"""
from ploomberutils import nb
nb.build(name=name, force=force, log=log)