-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_assets.py
56 lines (41 loc) · 1.43 KB
/
get_assets.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
45
46
47
48
49
50
51
52
53
54
55
56
import sys
import os
# Get the root of the repository
script_dir = os.path.dirname(os.path.abspath(__file__))
repo_root = os.path.abspath(os.path.join(script_dir, ".."))
sys.path.insert(0, repo_root)
import logging
import hydra
from cmbml.core import PipelineContext, LogMaker
from cmbml.get_data.stage_executors.A_get_assets import GetAssetsExecutor
logger = logging.getLogger(__name__)
@hydra.main(version_base=None, config_path="../cfg", config_name="config_sim")
def main(cfg):
"""
Gets assets.
Args:
cfg: The hydra configuration object. Provided by the @hydra.main decorator.
Raises:
Exception: If an exception occurs during the pipeline execution.
"""
logger.debug(f"Running {__name__} in {__file__}")
log_maker = LogMaker(cfg)
log_maker.log_procedure_to_hydra(source_script=__file__)
pipeline_context = PipelineContext(cfg, log_maker)
pipeline_context.add_pipe(GetAssetsExecutor)
pipeline_context.prerun_pipeline()
had_exception = False
try:
pipeline_context.run_pipeline()
except Exception as e:
had_exception = True
logger.exception("An exception occurred during the pipeline.", exc_info=e)
raise e
finally:
if had_exception:
logger.error("Pipeline failed.")
else:
logger.info("Pipeline completed.")
log_maker.copy_hydra_run_to_dataset_log()
if __name__ == "__main__":
main()