From 3d081563aee4f26f04b574e18b068571fd98bfc0 Mon Sep 17 00:00:00 2001 From: jpitts-uva Date: Wed, 13 Mar 2024 07:31:23 -0400 Subject: [PATCH 1/6] Removed "with app.app_context()" from process_erroring_workflows because it seems to be causing issues. --- crc/services/workflow_service.py | 45 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index 89eb3e9d..e8ead7ee 100755 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -139,31 +139,30 @@ def get_workflow_url(workflow): return workflow_url def process_erroring_workflows(self): - with app.app_context(): - workflows = self.get_erroring_workflows() - if len(workflows) > 0: - workflow_urls = [] - if len(workflows) == 1: - workflow = workflows[0] + workflows = self.get_erroring_workflows() + if len(workflows) > 0: + workflow_urls = [] + if len(workflows) == 1: + workflow = workflows[0] + workflow_url_link = self.get_workflow_url(workflow) + workflow_urls.append(workflow_url_link) + message = 'There is one workflow in an error state.' + message += f'\n You can restart the workflow at {workflow_url_link}.' + else: + message = f'There are {len(workflows)} workflows in an error state.' + message += '\nYou can restart the workflows at these URLs:' + for workflow in workflows: workflow_url_link = self.get_workflow_url(workflow) workflow_urls.append(workflow_url_link) - message = 'There is one workflow in an error state.' - message += f'\n You can restart the workflow at {workflow_url_link}.' - else: - message = f'There are {len(workflows)} workflows in an error state.' - message += '\nYou can restart the workflows at these URLs:' - for workflow in workflows: - workflow_url_link = self.get_workflow_url(workflow) - workflow_urls.append(workflow_url_link) - message += f'\n{workflow_url_link}' - - with push_scope() as scope: - scope.user = {"urls": workflow_urls} - scope.set_extra("workflow_urls", workflow_urls) - # this sends a message through sentry - capture_message(message) - # We return message so we can use it in a test - return message + message += f'\n{workflow_url_link}' + + with push_scope() as scope: + scope.user = {"urls": workflow_urls} + scope.set_extra("workflow_urls", workflow_urls) + # this sends a message through sentry + capture_message(message) + # We return message so we can use it in a test + return message @staticmethod def test_spec(spec_id, validate_study_id=None, test_until=None, required_only=False): From 2f2214581e4061c9bc09f495dc1f823868ff5b4d Mon Sep 17 00:00:00 2001 From: jpitts-uva Date: Thu, 16 May 2024 13:48:04 -0400 Subject: [PATCH 2/6] Added comment to test push ability. --- example_data.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/example_data.py b/example_data.py index 976de79c..c38a7a7f 100644 --- a/example_data.py +++ b/example_data.py @@ -1,3 +1,5 @@ +# example data for testing + import glob import os From 26559f53042aa00e9122fed3962cbc809731bcbb Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Thu, 16 May 2024 08:42:40 -0400 Subject: [PATCH 3/6] add file logging to cr_connect.log --- config/logging.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config/logging.py b/config/logging.py index 964eabbf..b67b96ab 100644 --- a/config/logging.py +++ b/config/logging.py @@ -3,7 +3,7 @@ 'disable_existing_loggers': False, "loggers": { '': { # root logger - 'handlers': ['console'], + 'handlers': ['console', 'file'], 'level': 'INFO', 'propagate': True }, @@ -36,7 +36,7 @@ "root": { "level": "INFO", "handlers": [ - "console", + "console", "file" ] }, "handlers": { @@ -45,6 +45,12 @@ "class": "logging.StreamHandler", "stream": "ext://sys.stdout", "level": "INFO" + }, + "file": { + "level": "INFO", + "formatter": "simple", + "class": "logging.FileHandler", + "filename": "cr_connect.log" } } } From 3a68345ce1de48a6d69155af5aca6b46e01fb634 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Thu, 16 May 2024 08:48:51 -0400 Subject: [PATCH 4/6] action to buid image for test server --- .github/workflows/build-test-image.yml | 98 ++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/build-test-image.yml diff --git a/.github/workflows/build-test-image.yml b/.github/workflows/build-test-image.yml new file mode 100644 index 00000000..2fd9cf5f --- /dev/null +++ b/.github/workflows/build-test-image.yml @@ -0,0 +1,98 @@ +name: build_test_image + +on: + push: + branches: ['test'] + workflow_dispatch: + + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + TESTING: true + PB_ENABLED: false + SQLALCHEMY_DATABASE_URI: "postgresql://postgres:postgres@localhost:5432/crc_test" + PGPASSWORD: postgres + +jobs: + sonarcloud: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@master + with: + args: > + -Dsonar.organization=sartography + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + run_tests: + runs-on: ubuntu-latest + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - uses: browser-actions/setup-chrome@latest + with: + chrome-version: stable + - uses: actions/setup-python@v3 + with: + python-version: '3.9' + architecture: 'x64' + - run: psql -h localhost -c 'create database crc_test;' -U postgres + - run: pip install pipenv + - run: pipenv install --dev + - run: pipenv run coverage run -m pytest + - run: pipenv run coverage xml -i + + build-and-push-image: + needs: + - run_tests + - sonarcloud + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 7301b81d5c128823eead3a7b29d49b24960baab4 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Thu, 16 May 2024 13:23:13 -0400 Subject: [PATCH 5/6] main -> testing --- .github/workflows/build-test-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test-image.yml b/.github/workflows/build-test-image.yml index 2fd9cf5f..a0a27e99 100644 --- a/.github/workflows/build-test-image.yml +++ b/.github/workflows/build-test-image.yml @@ -2,7 +2,7 @@ name: build_test_image on: push: - branches: ['test'] + branches: ['testing'] workflow_dispatch: @@ -67,7 +67,7 @@ jobs: - run_tests - sonarcloud runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/testing' permissions: contents: read packages: write From 4a918c9b4a6e19a68dd0f74842ccd688028bac09 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Fri, 24 May 2024 15:54:18 -0400 Subject: [PATCH 6/6] Ticket 28 - UIDs with capital letters --- crc/services/study_service.py | 1 + 1 file changed, 1 insertion(+) diff --git a/crc/services/study_service.py b/crc/services/study_service.py index 1e33ff57..febd01b3 100755 --- a/crc/services/study_service.py +++ b/crc/services/study_service.py @@ -265,6 +265,7 @@ def update_study_associate(study_id=None, uid=None, role="", send_email=False, a if uid is None: raise ApiError('uid not specified', "This function requires a uva uid parameter") + uid = uid.lower() if not LdapService.user_exists(uid): raise ApiError('trying_to_grant_access_to_user_not_found_in_ldap', "You are trying to grant access to " "%s but they were not found in ldap "