From 1fc10fe990571567fe652f2b0c52768136988c95 Mon Sep 17 00:00:00 2001 From: Brian Walsh Date: Mon, 21 Jul 2025 20:20:32 -0700 Subject: [PATCH 1/8] patches call to indexclient --- image_viewer/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/image_viewer/__init__.py b/image_viewer/__init__.py index e69de29..0e19899 100644 --- a/image_viewer/__init__.py +++ b/image_viewer/__init__.py @@ -0,0 +1,18 @@ +import indexclient.client + + +def monkey_patch_indexclient__get(): + """Monkey patch IndexClient._get to ensure 'auth' is set and log calls.""" + original__get = indexclient.client.IndexClient._get + + def patched__get(self, *args, **kwargs): + """Patch to ensure 'auth' is set and log the call.""" + if 'auth' not in kwargs: + kwargs['auth'] = self.auth + return original__get(self, *args, **kwargs) + + indexclient.client.IndexClient._get = patched__get + + +# main +monkey_patch_indexclient__get() From 29221a90da00f6e7da9e93547dd07ee6da1d582b Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 23 Jul 2025 11:52:50 -0700 Subject: [PATCH 2/8] fix: checkout BRANCH --- .github/workflows/build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 906a403..14ef323 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -10,7 +10,8 @@ jobs: steps: - name: Check out code uses: actions/checkout@v2 - + with: + ref: ${{ github.ref }} - name: Login to Quay.io uses: docker/login-action@v2 with: From c8ae9085aad7eab644b6bb8fbcec8ab431b38347 Mon Sep 17 00:00:00 2001 From: Brian Walsh Date: Wed, 23 Jul 2025 12:21:19 -0700 Subject: [PATCH 3/8] docker build branch --- .github/workflows/build.yaml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 14ef323..6957375 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ jobs: # Login to Quay.io and build image docker login quay.io - docker build -t $REPO:$BRANCH . + docker build -t $REPO:$BRANCH --build-arg BRANCH=$BRANCH . # Add 'latest' tag to 'main' image if [[ $BRANCH == 'main' ]]; then diff --git a/Dockerfile b/Dockerfile index 23a3ff6..d623620 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM python:3.12 - +ARG BRANCH=development WORKDIR /app ADD "https://api.github.com/repos/ACED-IDP/image_viewer/commits?per_page=1" latest_commit From e06cdcc63ab22fe9acd37bb6406791467a44245d Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 23 Jul 2025 12:57:38 -0700 Subject: [PATCH 4/8] fix: build $BRANCH --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d623620..13a618f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ ADD "https://api.github.com/repos/ACED-IDP/image_viewer/commits?per_page=1" late RUN git clone https://github.com/ACED-IDP/image_viewer WORKDIR /app/image_viewer -RUN git checkout development +RUN git checkout $BRANCH RUN pip install --no-cache-dir . RUN git log --oneline CMD ["uvicorn", "image_viewer.app:app", "--reload"] From dd0dd27102f78136ae1f7e71a6bc3ad899dcb86f Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 23 Jul 2025 13:16:42 -0700 Subject: [PATCH 5/8] fix: RAW_BRANCH_NAME --- .github/workflows/build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6957375..90f2f4a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -22,13 +22,14 @@ jobs: - name: Build and push image run: | # Set Image tag to the branch name + RAW_BRANCH_NAME=$(echo ${GITHUB_REF#refs/*/}) BRANCH=$(echo ${GITHUB_REF#refs/*/} | tr / _) REPO=quay.io/ohsu-comp-bio/gen3-image-viewer echo "Setting image tag to $REPO:$BRANCH" # Login to Quay.io and build image docker login quay.io - docker build -t $REPO:$BRANCH --build-arg BRANCH=$BRANCH . + docker build -t $REPO:$BRANCH --build-arg BRANCH=$RAW_BRANCH_NAME . # Add 'latest' tag to 'main' image if [[ $BRANCH == 'main' ]]; then From 22f8633ddb828fc547a4684b2bd1a7d7054a91af Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 23 Jul 2025 17:24:05 -0700 Subject: [PATCH 6/8] add git pull --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 13a618f..fed6aa7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ ADD "https://api.github.com/repos/ACED-IDP/image_viewer/commits?per_page=1" late RUN git clone https://github.com/ACED-IDP/image_viewer WORKDIR /app/image_viewer RUN git checkout $BRANCH +RUN git pull origin $BRANCH RUN pip install --no-cache-dir . RUN git log --oneline CMD ["uvicorn", "image_viewer.app:app", "--reload"] From 3a2e0b0ae4b55f507bccf92139ecbb25a2b18acd Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 23 Jul 2025 17:30:25 -0700 Subject: [PATCH 7/8] clone only branch --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index fed6aa7..1de2a3e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,10 +4,11 @@ WORKDIR /app ADD "https://api.github.com/repos/ACED-IDP/image_viewer/commits?per_page=1" latest_commit -RUN git clone https://github.com/ACED-IDP/image_viewer +# Clone the specific branch +RUN git clone --branch $BRANCH https://github.com/ACED-IDP/image_viewer.git + WORKDIR /app/image_viewer -RUN git checkout $BRANCH -RUN git pull origin $BRANCH + RUN pip install --no-cache-dir . RUN git log --oneline CMD ["uvicorn", "image_viewer.app:app", "--reload"] From e894aac541d5406b7662a6bbcbbd9770ffe2917d Mon Sep 17 00:00:00 2001 From: Brian Walsh Date: Wed, 23 Jul 2025 17:47:29 -0700 Subject: [PATCH 8/8] remove debug statements --- image_viewer/app.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/image_viewer/app.py b/image_viewer/app.py index 4f05940..6c8fb89 100644 --- a/image_viewer/app.py +++ b/image_viewer/app.py @@ -48,22 +48,17 @@ async def view_object(object_id: str, authorization: str = Header(None), access_ token = None - logger.error("in view object") - if authorization and authorization.startswith("Bearer "): token = authorization.split(" ")[1] # Extract token from "Bearer " elif access_token: token = access_token - logger.error(f"in view object token {token}") # If no token is found, raise a 404 Not Found error if not token: raise HTTPException(status_code=404, detail="Token not found") try: - logger.error(f"in view object {object_id} {settings.base_url}") redirect_url = aviator_url(object_id, token, settings.base_url) - logger.error(f"in view object {redirect_url}") return RedirectResponse(url=redirect_url) except HTTPException as e: