Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

support.py 1.1 KB

You have to be logged in to leave a comment. Sign In
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
  1. import os
  2. from pathlib import Path
  3. import subprocess as sp
  4. from invoke import task
  5. data_dir = Path('data')
  6. tgt_dir = Path('target')
  7. bin_dir = tgt_dir / 'release'
  8. @task
  9. def build(c, debug=False):
  10. "Compile the Rust support executables"
  11. global bin_dir
  12. if debug:
  13. print('compiling support executables in debug mode')
  14. c.run('cargo build')
  15. bin_dir = tgt_dir / 'debug'
  16. else:
  17. print('compiling support executables')
  18. c.run('cargo build --release')
  19. def pipeline(steps, outfile=None):
  20. last = sp.DEVNULL
  21. if outfile is not None:
  22. outfd = os.open(outfile, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o666)
  23. else:
  24. outfd = None
  25. procs = []
  26. for step in steps[:-1]:
  27. proc = sp.Popen(step, stdin=last, stdout=sp.PIPE)
  28. last = proc.stdout
  29. procs.append(proc)
  30. proc = sp.Popen(steps[-1], stdin=last, stdout=outfd)
  31. procs.append(proc)
  32. for p, s in zip(procs, steps):
  33. rc = p.wait()
  34. if rc != 0:
  35. print(f'{s[0]} exited with code {rc}', file=sys.stderr)
  36. raise RuntimeError('subprocess failed')
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...