def __post_init__(self) -> None:
# during entry of project enable logging
_ilog.setLevel(logging.INFO)
self._mode = Stage[
config(BrickflowEnvVars.BRICKFLOW_MODE.value, default=Stage.execute.value)
]
self.entry_point_path = self.entry_point_path or get_caller_info()
deploy_settings = BrickflowProjectDeploymentSettings()
# setup current_project
env_project_name = deploy_settings.brickflow_project_name
self.libraries = self.libraries or []
if deploy_settings.brickflow_auto_add_libraries is True:
_ilog.info("Auto adding brickflow libraries...")
self.libraries = filter_bf_related_libraries(self.libraries)
# here libraries should not be null anymore if this branch is invoked
self.libraries += get_brickflow_libraries()
if (
env_project_name is not None
and self.name is not None
and env_project_name != self.name
):
raise ValueError(
"Project name in config files and entrypoint must be the same"
)
ctx.set_current_project(self.name or env_project_name) # always setup first
# populate bundle info via env vars
self.bundle_obj_name = config(
BrickflowEnvVars.BRICKFLOW_BUNDLE_OBJ_NAME.value,
default=".brickflow_bundles",
)
self.bundle_base_path = config(
BrickflowEnvVars.BRICKFLOW_BUNDLE_BASE_PATH.value,
default="/Users/${workspace.current_user.userName}",
)
self.git_reference = config(
BrickflowEnvVars.BRICKFLOW_GIT_REF.value, default=self.get_git_ref()
)
if (
self._mode == Stage.deploy
and ctx.is_local() is False
and self.git_reference is None
):
raise ValueError(
"git_reference must be set when deploying to non-local envs"
)
self.provider = config(
BrickflowEnvVars.BRICKFLOW_GIT_PROVIDER.value, default=self.provider
)
self.git_repo = config(
BrickflowEnvVars.BRICKFLOW_GIT_REPO.value, default=self.git_repo
)
if self.s3_backend is None:
self.s3_backend = {
"bucket": config("BRICKFLOW_S3_BACKEND_BUCKET", default=None),
"key": config("BRICKFLOW_S3_BACKEND_KEY", default=None),
"region": config("BRICKFLOW_S3_BACKEND_REGION", default=None),
"dynamodb_table": config(
"BRICKFLOW_S3_BACKEND_DYNAMODB_TABLE", default=None
),
}
if all(value is None for value in self.s3_backend.values()):
self.s3_backend = None
deployment_mode = config(
BrickflowEnvVars.BRICKFLOW_DEPLOYMENT_MODE.value, default="cdktf"
)
if deployment_mode == BrickflowDeployMode.CDKTF.value:
self.codegen_mechanism = HashicorpCDKTFGen
elif deployment_mode == BrickflowDeployMode.BUNDLE.value:
self.codegen_mechanism = DatabricksBundleCodegen
if self.codegen_kwargs is None:
self.codegen_kwargs = {}