Skip to content

Commit

Permalink
create config for github repository name
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainOfHacks committed Nov 13, 2023
1 parent 1289e20 commit ba99196
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ted_sws/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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:
"""
Expand Down Expand Up @@ -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

0 comments on commit ba99196

Please sign in to comment.