Skip to content

Commit

Permalink
Merge pull request #389 from meaningfy-ws/feature/MWB12-24
Browse files Browse the repository at this point in the history
feature/MWB12-24
  • Loading branch information
kaleanych authored Jan 31, 2025
2 parents b6c6895 + aa42f13 commit df41d43
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_SCANNER_OPTS: -Dsonar.working.directory=/tmp/sonar -X
SONAR_SCANNER_OPTS: -Dsonar.working.directory=/tmp/sonar

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,11 @@ create-release-tag:
@ git tag -a v$(V) -m "Release version $(V)"
@ git push origin v$(V)
@ echo "Release Tag `v$(V)` was successfully created and pushed."

deploy-app: stop-frontend stop-backend build-backend build-frontend

deploy-prod: deploy-prod-dotenv-file deploy-app
@ echo "Deployed App to PROD"

deploy-staging: deploy-staging-dotenv-file deploy-app
@ echo "Deployed App to STAGING"
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ async def route_task_import_eforms_xsd(
):
return add_task(
tasks.task_import_eforms_xsd,
f"Importing eForms XSD versions: {branch_or_tag_name}",
f"Importing eForms SDK versions: {branch_or_tag_name}",
None,
user.email,
False,
True,
github_repository_url, branch_or_tag_name, Project.link_from_id(project_id)
).task_metadata

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from datetime import datetime
from typing import List, Union

from beanie import Link, Document
from beanie import Link
from dateutil.tz import tzlocal

from mapping_workbench.backend.fields_registry.adapters.github_download import GithubDownloader
Expand All @@ -17,6 +17,9 @@
from mapping_workbench.backend.fields_registry.models.pool import PoolSDKField, PoolSDKFieldsVersionedView
from mapping_workbench.backend.logger.services import mwb_logger
from mapping_workbench.backend.project.models.entity import Project
from mapping_workbench.backend.task_manager.adapters.task_progress import TaskProgress
from mapping_workbench.backend.tasks.models.task_response import TaskResponse, TaskResultData, TaskResultWarning, \
TaskProgressStatus

FIELDS_PATH_NAME = "fields"
FIELDS_JSON_FILE_NAME = "fields.json"
Expand Down Expand Up @@ -232,17 +235,54 @@ async def import_eforms_fields_from_folder_to_pool(
async def import_eforms_xsd(
branch_or_tag_name: str,
github_repository_url: str = None,
project_link: Link[Project] = None
project_link: Link[Project] = None,
task_response: TaskResponse = None
):
if not task_response:
task_response = TaskResponse()

task_progress = TaskProgress(task_response)
versions = [item.strip() for item in branch_or_tag_name.split(',')]

task_progress.start_progress(actions_count=1)
task_progress.start_action(name="Import EForms XSD", steps_count=len(versions))

warnings: List[TaskResultWarning] = []
for version in versions:
if not await import_eforms_fields_from_pool_to_project(project_link=project_link, version=version) \
and github_repository_url:
await import_eforms_fields_from_github_repository(
github_repository_url=github_repository_url,
branch_or_tag_name=version,
project_link=project_link
)
task_progress.start_action_step(name=version)
status: TaskProgressStatus = TaskProgressStatus.FINISHED
if not await import_eforms_fields_from_pool_to_project(project_link=project_link, version=version):
if github_repository_url:
task_progress.update_current_action_step_name(f"{version} (from GitHub)")
await import_eforms_fields_from_github_repository(
github_repository_url=github_repository_url,
branch_or_tag_name=version,
project_link=project_link
)
m = f'{version} eForms SDK imported from GitHub'
warnings.append(TaskResultWarning(
message=m,
type='SDKs imported from GitHub repository (not found in the pool)'
))
else:
task_progress.update_current_action_step_name(f"{version} (not found)")
m = f'{version} eForms SDK not imported'
warnings.append(TaskResultWarning(
message=m,
type='SDKs not imported (not found in the pool and no GitHub repository provided)'
))
mwb_logger.log_all_info(m)
status = TaskProgressStatus.FAILED

task_progress.finish_current_action_step(status=status)

task_progress.finish_current_action()
task_progress.finish_progress()

if task_response:
task_response.update_result(TaskResultData(
warnings=warnings
))


async def import_eforms_fields_from_github_repository(
Expand All @@ -258,8 +298,10 @@ async def import_eforms_fields_from_github_repository(
with tempfile.TemporaryDirectory() as tmp_dir:
temp_dir_path = pathlib.Path(tmp_dir)
mwb_logger.log_all_info(f"Getting fields from {github_repository_url}")
github_downloader.download(result_dir_path=temp_dir_path,
download_resources_filter=[FIELDS_PATH_NAME, NOTICE_TYPES_PATH_NAME])
github_downloader.download(
result_dir_path=temp_dir_path,
download_resources_filter=[FIELDS_PATH_NAME, NOTICE_TYPES_PATH_NAME]
)
mwb_logger.log_all_info(f"Importing fields into the registry")
await import_eforms_fields_from_folder_to_pool(
eforms_fields_folder_path=temp_dir_path
Expand Down
6 changes: 4 additions & 2 deletions mapping_workbench/backend/fields_registry/services/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
from mapping_workbench.backend.fields_registry.services.import_fields_registry import \
import_eforms_xsd
from mapping_workbench.backend.task_manager.services.task_wrapper import run_task
from mapping_workbench.backend.tasks.models.task_response import TaskResponse


def task_import_eforms_xsd(
github_repository_url: str,
branch_or_tag_name: str,
project_link: Link[Document] = None
project_link: Link[Document] = None,
task_response: TaskResponse = None
):
run_task(
import_eforms_xsd,
branch_or_tag_name, github_repository_url, project_link
branch_or_tag_name, github_repository_url, project_link, task_response
)
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ def start_action_step(self, name: str = None):
))
self.update_task_response()

def finish_current_action_step(self):
self.update_current_action_step_status(TaskProgressStatus.FINISHED)
def update_current_action_step_name(self, name: str):
if self.get_current_action_step():
self.get_current_action_step().name = name
self.update_task_response()

def finish_current_action_step(self, status: TaskProgressStatus = TaskProgressStatus.FINISHED):
self.update_current_action_step_status(status)
if self.get_current_action_step():
self.get_current_action_step().finished_at = self.current_time()
self.get_current_action_step().duration = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class SpecificTripleMapFragmentsApi extends TripleMapFragmentsApi {
return [ACTION.EDIT, ACTION.DELETE]
}

get

constructor() {
super("specific_triple_map_fragments");
this.hasMappingPackage = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const progressStepColor = (stepStatus, palette) => {
return palette.success.dark
case taskProgressStatus.RUNNING:
return palette.warning.main
case taskProgressStatus.FAILED:
return palette.error.main
default:
return palette.grey[400]
}
Expand Down

0 comments on commit df41d43

Please sign in to comment.