Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import subprocess 

2import os 

3import shutil 

4 

5 

6from spark_etl.deployers import AbstractDeployer 

7from spark_etl import Build 

8 

9 

10class LocalDeployer(AbstractDeployer): 

11 """ 

12 This deployer deploys application to local file system 

13 """ 

14 def __init__(self, config): 

15 super(LocalDeployer, self).__init__(config) 

16 

17 def deploy(self, build_dir, deployment_location): 

18 # directory layout 

19 # deployment_location 

20 # | 

21 # +-- {build_version} 

22 # | 

23 # +-- app.zip 

24 # | 

25 # +-- job_loader.py 

26 # | 

27 # +-- lib 

28 # | 

29 # +-- main.py 

30 # | 

31 # +-- manifest.json 

32 

33 build = Build(build_dir) 

34 

35 # copy artifacts 

36 target_dir = os.path.join(deployment_location, build.version) 

37 if os.path.isdir(target_dir): 

38 shutil.rmtree(target_dir) 

39 os.makedirs(target_dir) 

40 for artifact in build.artifacts: 

41 src = os.path.join(build_dir, artifact) 

42 dst = os.path.join(target_dir, artifact) 

43 print(f"Copy from {src} to {dst}") 

44 shutil.copyfile(src, dst) 

45 

46 src = os.path.join(os.path.dirname(os.path.abspath(__file__)), "job_loader.py") 

47 dst = os.path.join(target_dir, "job_loader.py") 

48 shutil.copyfile(src, dst) 

49 print(f"Copy from {src} to {dst}") 

50 

51 print("Deployment is done") 

52 

53 

54 

55