forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.py
More file actions
37 lines (28 loc) · 1023 Bytes
/
base.py
File metadata and controls
37 lines (28 loc) · 1023 Bytes
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
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pathlib import Path
class BaseLocalLambdaLayer(ABC):
def __init__(self, output_dir: Path):
self.output_dir = output_dir / "layer_build"
self.target_dir = f"{self.output_dir}/python"
@abstractmethod
def build(self) -> str:
"""Builds a Lambda Layer locally
Returns
-------
build_path : str
Path where newly built Lambda Layer is
"""
raise NotImplementedError()
def before_build(self):
"""Any step to run before build process begins.
By default, it creates output dir and its parents if it doesn't exist.
"""
if not self.output_dir.exists():
# Create missing parent directories if missing
self.output_dir.mkdir(parents=True, exist_ok=True)
def after_build(self): # noqa: B027
"""Any step after a build succeed"""
...