generated from dataforgoodfr/d4g-project-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tasks.py
44 lines (32 loc) · 978 Bytes
/
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
import contextlib
import os
from collections.abc import Generator
from pathlib import Path
from typing import Any
from invoke import Context, task
# context manager that make sure subsequent
# commands are run in the specified directory
@contextlib.contextmanager
def cwd(rel_path: str) -> Generator[Any, Any, Any]:
prev_cwd = Path.cwd()
try:
os.chdir(Path(__file__).parent / rel_path)
yield
finally:
os.chdir(prev_cwd)
@task
def dev(c: Context) -> None:
with cwd("observable"):
c.run("yarn dev")
@task
def update_movies_dataset(c: Context) -> None:
c.run("python -m observatoire.tmdb.movies")
@task
def update_series_dataset(c: Context) -> None:
c.run("python -m observatoire.tmdb.movies")
@task
def clean_branches(c: Context) -> None:
c.run("git branch --merged | grep -v '\\*\\|main' | xargs -n 1 git branch -d")
@task
def streamlit(c: Context) -> None:
c.run("streamlit run app/odi_streamlit.py ")