Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -21,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 .
docker build -t $REPO:$BRANCH --build-arg BRANCH=$RAW_BRANCH_NAME .

# Add 'latest' tag to 'main' image
if [[ $BRANCH == 'main' ]]; then
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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

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 development

RUN pip install --no-cache-dir .
RUN git log --oneline
CMD ["uvicorn", "image_viewer.app:app", "--reload"]
18 changes: 18 additions & 0 deletions image_viewer/__init__.py
Original file line number Diff line number Diff line change
@@ -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:
Copy link

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch assumes that self.auth exists and is valid. Consider adding a check to ensure self.auth is not None before assigning it, or handle the case where it might not be available.

Suggested change
if 'auth' not in kwargs:
if 'auth' not in kwargs:
if self.auth is None:
raise ValueError("self.auth is not set. Ensure it is initialized before calling _get.")

Copilot uses AI. Check for mistakes.
kwargs['auth'] = self.auth
return original__get(self, *args, **kwargs)

indexclient.client.IndexClient._get = patched__get


# main
monkey_patch_indexclient__get()
5 changes: 0 additions & 5 deletions image_viewer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <token>"
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:
Expand Down