Skip to content

Commit

Permalink
Merge branch 'main' into issue-1145-consitent-docker-usernames
Browse files Browse the repository at this point in the history
  • Loading branch information
tejaswarathe authored Dec 6, 2024
2 parents 4bdc47b + 7d0fc83 commit 14b9084
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ jobs:
build-contexts: ${{ matrix.build-contexts }}
build-args: |
SEMANTIC_VERSION=${{ needs.get-image-tag.outputs.image_tag }}
OV_PDM_VERSION=${{ steps.prepare-build-args.outputs.ov_pdm_version }}
CATALOG_PY_VERSION=${{ steps.prepare-build-args.outputs.catalog_py_version }}
CATALOG_AIRFLOW_VERSION=${{ steps.prepare-build-args.outputs.catalog_airflow_version }}
INDEXER_WORKER_PY_VERSION=${{ steps.prepare-build-args.outputs.indexer_worker_py_version }}
Expand Down Expand Up @@ -367,6 +368,7 @@ jobs:
cache-to: type=gha,scope=indexer_worker_dev
build-args: |
INDEXER_WORKER_PY_VERSION=${{ steps.prepare-build-args.outputs.indexer_worker_py_version }}
OV_PDM_VERSION=${{ steps.prepare-build-args.outputs.ov_pdm_version }}
PDM_INSTALL_ARGS=--dev
- name: Run tests
Expand Down Expand Up @@ -484,6 +486,7 @@ jobs:
build-args: |
SEMANTIC_VERSION=${{ needs.get-image-tag.outputs.image_tag }}
API_PY_VERSION=${{ steps.prepare-build-args.outputs.api_py_version }}
OV_PDM_VERSION=${{ steps.prepare-build-args.outputs.ov_pdm_version }}
PDM_INSTALL_ARGS=--dev
- name: Start Catalog
Expand Down
11 changes: 7 additions & 4 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ ARG API_PY_VERSION

FROM docker.io/python:${API_PY_VERSION} AS builder

# Get the version from the main justfile
ARG OV_PDM_VERSION

# Container optimizations
ENV PYTHONUNBUFFERED=1
ENV PIP_NO_CACHE_DIR=1
Expand All @@ -19,11 +22,11 @@ ENV PIP_NO_COLOR=1
# - Create a virtualenv inside `/venv`
# - Install PDM to install Python dependencies
RUN apt-get update \
&& apt-get install -yqq --no-install-recommends \
python3-dev \
&& apt-get install -yqq --no-install-recommends python3-dev \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& pip install pdm~=2.19
&& pip install --upgrade pip \
&& pip install pdm~=$OV_PDM_VERSION

# Copy subpackages from additional build-context 'packages'
# hadolint ignore=DL3022
Expand All @@ -33,7 +36,7 @@ COPY --from=packages openverse-attribution /packages/python/openverse-attributio
COPY pyproject.toml pdm.lock /

# Pass additional arguments when installing Python packages with PDM
ARG PDM_INSTALL_ARGS='--no-editable'
ARG PDM_INSTALL_ARGS="--no-editable"

# Install Python dependencies into a new virtualenv
RUN pdm install --check --frozen-lockfile $PDM_INSTALL_ARGS
Expand Down
1 change: 1 addition & 0 deletions api/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
args: # Automatically inferred from env vars, unless specified
- SEMANTIC_VERSION=${SEMANTIC_VERSION:-v1.0.0}
- API_PY_VERSION
- OV_PDM_VERSION=${OV_PDM_VERSION}
- PDM_INSTALL_ARGS=--dev
image: openverse-api:${API_PDM_HASH:-latest}
pull_policy: never
Expand Down
2 changes: 1 addition & 1 deletion api/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ overrides = [
]
dev = [
"debugpy >= 1.8.9, <2",
"ipython >=8.30.0, <9",
"ipython >=8.30, <9",
"pgcli >=4.1, <5",
"remote-pdb >=2.1.0, <3",
"remote-pdb >=2.1, <3",
"setuptools >=75.6, <76",
# FIXME: Should be removed when Python build issues are resolved,
# FIXME: since we don't explicitly use this library.
Expand Down
4 changes: 2 additions & 2 deletions documentation/general/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ The [WordPress Design team](https://make.wordpress.org/design/) uses
projects. If you are not familiar with designing for WordPress, please carefully
read the [design handbook](https://make.wordpress.org/design/handbook/). Once
you have a [WordPress Slack](https://make.wordpress.org/chat/) account, join the
[#design channel](http://wordpress.slack.com/messages/design/) and ask the team
[#design channel](https://wordpress.slack.com/messages/design/) and ask the team
to set you up with a free Figma account.

This will give you access to
Expand All @@ -132,7 +132,7 @@ file to understand how Openverse has been built, and take a look at the
to get a glance at how design ideas are made. As the design onboarding section
in the design library file is constantly being added to and improved, some
documentation may be missing. If you have doubts, ask on
[#design channel](http://wordpress.slack.com/messages/design/) for
[#design channel](https://wordpress.slack.com/messages/design/) for
clarification. If you discover new information that is yet to be documented,
contributing this information back to the documentation is deeply appreciated.

Expand Down
11 changes: 7 additions & 4 deletions indexer_worker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ ARG INDEXER_WORKER_PY_VERSION

FROM docker.io/python:${INDEXER_WORKER_PY_VERSION} AS builder

# Get the version from the main justfile
ARG OV_PDM_VERSION

# Container optimizations
ENV PYTHONUNBUFFERED=1
ENV PIP_NO_CACHE_DIR=1
Expand All @@ -18,17 +21,17 @@ ENV PIP_NO_COLOR=1
# - Install system packages needed for building Python dependencies
# - Install PDM to install Python dependencies
RUN apt-get update \
&& apt-get install -yqq --no-install-recommends \
python3-dev \
&& apt-get install -yqq --no-install-recommends python3-dev \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& pip install pdm~=2.14
&& pip install --upgrade pip \
&& pip install pdm~=$OV_PDM_VERSION

# Copy the Pipenv files into the container
COPY pyproject.toml pdm.lock /

# Pass additional arguments when installing Python packages with PDM
ARG PDM_INSTALL_ARGS='--no-editable'
ARG PDM_INSTALL_ARGS="--no-editable"

# Install Python dependencies into a new virtualenv
RUN pdm install --check --frozen-lockfile $PDM_INSTALL_ARGS
Expand Down
1 change: 1 addition & 0 deletions indexer_worker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
target: indexer_worker
args: # Automatically inferred from env vars, unless specified
- INDEXER_WORKER_PY_VERSION
- OV_PDM_VERSION=${OV_PDM_VERSION}
- PDM_INSTALL_ARGS=--dev
ports:
- "50282:8003"
Expand Down
2 changes: 2 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ env:
DOCKER_FILE := "-f docker-compose.yml"
EXEC_DEFAULTS := if IS_CI == "" { "" } else { "-T" }

export OV_PDM_VERSION := env_var_or_default("OV_PDM_VERSION", "2.21")
export CATALOG_PY_VERSION := `just catalog/py-version`
export CATALOG_AIRFLOW_VERSION := `just catalog/airflow-version`
export INDEXER_WORKER_PY_VERSION := `just indexer_worker/py-version`
Expand All @@ -247,6 +248,7 @@ export HOST_NETWORK_ADDRESS := if os() == "macos" { "host.docker.internal" } els
versions:
#!/usr/bin/env bash
cat <<EOF
ov_pdm_version=$(echo $OV_PDM_VERSION)
catalog_py_version=$(just catalog/py-version)
catalog_airflow_version=$(just catalog/airflow-version)
api_py_version=$(just api/py-version)
Expand Down
2 changes: 1 addition & 1 deletion packages/js/api-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
"vitest": "^2.1.4"
},
"dependencies": {
"openapi-fetch": "^0.11.2"
"openapi-fetch": "^0.13.0"
}
}
17 changes: 14 additions & 3 deletions packages/js/api-client/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Middleware } from "openapi-fetch"
import type { MiddlewareCallbackParams } from "openapi-fetch"
import type { components } from "./generated/openverse"
import type { OpenverseClient, ClientCredentials } from "./types"

Expand All @@ -11,7 +11,15 @@ type OAuth2Token = components["schemas"]["OAuth2Token"]
const currTimestamp = (): number => Math.floor(Date.now() / 1e3)
export const EXPIRY_THRESHOLD = 5 // seconds

export class OpenverseAuthMiddleware implements Middleware {
type MiddlewareOnRequest = (
options: MiddlewareCallbackParams
) => void | Request | undefined | Promise<Request | undefined | void>

interface OpenverseMiddleware {
onRequest: MiddlewareOnRequest
}

export class OpenverseAuthMiddleware implements OpenverseMiddleware {
/**
* An Openverse REST API client.
*
Expand Down Expand Up @@ -57,7 +65,10 @@ export class OpenverseAuthMiddleware implements Middleware {
this.credentials = credentials
}

onRequest: Middleware["onRequest"] = async ({ schemaPath, request }) => {
onRequest: OpenverseMiddleware["onRequest"] = async ({
schemaPath,
request,
}) => {
if (schemaPath == "/v1/auth_tokens/token/") {
// Do not send auth headers for token generation requests
return request
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 14b9084

Please sign in to comment.