Skip to content

Commit f0e5c06

Browse files
committed
chore: add GitHub download logging for visibility into corner cases
In serious cases where there are problems with the GitHub download there can be unexplained failures, as such situations are not caught due to the use of a CLI command using Python's subproces. Add some logging until the GitHub download is refactored to use a Python client and have better error-handling.
1 parent 3374147 commit f0e5c06

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/ted_sws/mapping_suite_processor/adapters/github_ms_project_downloader.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import tempfile
66
from typing import ClassVar
77
from src.ted_sws import config
8-
8+
from src.ted_sws.event_manager.services.log import log_technical_info
99
# TODO: get from env or config
1010
MAPPINGS_DIR_NAME = "mappings"
1111
MS_CONFIG_DIR_NAME = "config"
@@ -77,11 +77,15 @@ def get_git_head_hash(git_repository_path: pathlib.Path) -> str:
7777
with tempfile.TemporaryDirectory() as tmp_dir:
7878
temp_dir_path = pathlib.Path(tmp_dir)
7979
bash_script = f"cd {temp_dir_path} && git clone --branch {self.branch_or_tag_name} {self.github_repository_url}"
80-
subprocess.run(bash_script, shell=True,
81-
stdout=subprocess.DEVNULL,
82-
stderr=subprocess.STDOUT)
80+
result = subprocess.run(bash_script, shell=True,
81+
capture_output=True, text=True)
82+
log_technical_info(
83+
message=f"Downloaded stdout '{result.stdout}'")
84+
log_technical_info(
85+
message=f"Downloaded stderr '{result.stderr}'")
8386
git_last_commit_hash = get_git_head_hash(
8487
git_repository_path=temp_dir_path / self.repository_name)
8588
downloaded_tmp_project_path = temp_dir_path / self.repository_name
8689
shutil.copytree(downloaded_tmp_project_path, output_project_path, dirs_exist_ok=True)
90+
8791
return git_last_commit_hash

src/ted_sws/mapping_suite_processor/services/mapping_package_processor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ def load_mapping_suite_and_packages_from_github_to_mongo_db(mongodb_client: Mong
101101
"""
102102
branch_or_tag_name = branch_or_tag_name if branch_or_tag_name else DEFAULT_BRANCH_NAME
103103
github_repository_url = github_repository_url if github_repository_url else config.GITHUB_TED_SWS_ARTEFACTS_URL
104-
log_technical_info(
105-
message=f"Downloading mapping suite from GitHub repository '{github_repository_url}' on branch/tag '{branch_or_tag_name}'")
106104
mapping_package_downloader = GitHubMappingSuiteDownloader(
107105
github_repository_url=github_repository_url, branch_or_tag_name=branch_or_tag_name)
108106
mappings_dir_name = mapping_package_downloader.MAPPINGS_DIR_NAME
@@ -116,6 +114,8 @@ def load_mapping_suite_and_packages_from_github_to_mongo_db(mongodb_client: Mong
116114
mappings_dir_path = tmp_dir_path / mappings_dir_name
117115
ms_config_dir_path = tmp_dir_path / ms_config_dir_name
118116
ms_config_file_path = ms_config_dir_path / ms_config_file_name
117+
log_technical_info(
118+
message=f"Downloading mapping suite from GitHub repository '{github_repository_url}' on branch/tag '{branch_or_tag_name}'")
119119
git_last_commit_hash = mapping_package_downloader.download(output_project_path=tmp_dir_path)
120120

121121
# load project config if available

0 commit comments

Comments
 (0)