diff --git a/ted_sws/__init__.py b/ted_sws/__init__.py index ab899116..a8895b01 100644 --- a/ted_sws/__init__.py +++ b/ted_sws/__init__.py @@ -145,6 +145,10 @@ class GitHubArtefacts: def GITHUB_TED_SWS_ARTEFACTS_URL(self, config_value: str) -> str: return config_value + @env_property(config_resolver_class=AirflowAndEnvConfigResolver, default_value="ted-rdf-mapping") + def GITHUB_TED_SWS_ARTEFACTS_REPOSITORY_NAME(self, config_value: str) -> str: + return config_value + class API: @env_property(default_value="localhost") diff --git a/ted_sws/mapping_suite_processor/adapters/github_package_downloader.py b/ted_sws/mapping_suite_processor/adapters/github_package_downloader.py index c7a727bd..51cb418a 100644 --- a/ted_sws/mapping_suite_processor/adapters/github_package_downloader.py +++ b/ted_sws/mapping_suite_processor/adapters/github_package_downloader.py @@ -3,9 +3,9 @@ import shutil import subprocess import tempfile +from ted_sws import config -GITHUB_TED_SWS_ARTEFACTS_REPOSITORY_NAME = "ted-rdf-mapping" -GITHUB_TED_SWS_ARTEFACTS_MAPPINGS_PATH = f"{GITHUB_TED_SWS_ARTEFACTS_REPOSITORY_NAME}/mappings" +MAPPINGS_DIR_NAME = "mappings" class MappingSuitePackageDownloaderABC(abc.ABC): @@ -26,6 +26,7 @@ class GitHubMappingSuitePackageDownloader(MappingSuitePackageDownloaderABC): """ This class downloads mapping_suite_package from GitHub. """ + def __init__(self, github_repository_url: str, branch_or_tag_name: str): """ Option can be branch or tag, not both @@ -34,6 +35,7 @@ def __init__(self, github_repository_url: str, branch_or_tag_name: str): """ self.github_repository_url = github_repository_url self.branch_or_tag_name = branch_or_tag_name + self.repository_name = config.GITHUB_TED_SWS_ARTEFACTS_REPOSITORY_NAME def download(self, output_mapping_suite_package_path: pathlib.Path) -> str: """ @@ -62,7 +64,7 @@ def get_git_head_hash(git_repository_path: pathlib.Path) -> str: stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) git_last_commit_hash = get_git_head_hash( - git_repository_path=temp_dir_path / GITHUB_TED_SWS_ARTEFACTS_REPOSITORY_NAME) - downloaded_tmp_mapping_suite_path = temp_dir_path / GITHUB_TED_SWS_ARTEFACTS_MAPPINGS_PATH + git_repository_path=temp_dir_path / self.repository_name) + downloaded_tmp_mapping_suite_path = temp_dir_path / self.repository_name / MAPPINGS_DIR_NAME shutil.copytree(downloaded_tmp_mapping_suite_path, output_mapping_suite_package_path, dirs_exist_ok=True) return git_last_commit_hash