Skip to content

Commit 81e8156

Browse files
authored
Merge pull request #1 from DevelopmentFinanceObservatory/chore/sync-website-v3.5.13
chore: sync website v3.5.13 for Data Commons Platform 1.1.6
2 parents 1d2c0b8 + ac82fe3 commit 81e8156

175 files changed

Lines changed: 3114 additions & 10504 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.dfo-protected-paths‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@ build/cdc_services/Dockerfile
1010
build/cdc_services/run.sh
1111
build/cdc_services/nginx.conf
1212

13-
# Repo-level DFO files
13+
# Repo-level DFO files. Every upstream-tracked file DFO modifies, adds, or
14+
# deletes belongs here, or a conflict on it silently takes upstream's side.
1415
justfile
1516
.dockerignore
1617
.gcloudignore
1718
.dfo-protected-paths
1819
.dfo-overridden-files
20+
.gitattributes
21+
.gitignore
22+
README.md
23+
package-lock.json
24+
pyproject.toml
25+
CONTRIBUTING-DFO.md
26+
# Deleted in this fork; a conflict here means upstream changed it.
27+
.github/CODEOWNERS
1928

2029
# CI/deploy workflows and deploy docs are DFO-owned even though they live
2130
# under upstream-owned directories (.github/, deploy/); an upstream file

‎.dockerignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import/simple/sample/
1616
**/.data
1717
**/testdata
1818
**/test_data
19+
import/simple/tests/
1920

2021
# ONE/DFO: exclude build artifacts from the Docker build context; keep source.
2122
**/.next

‎.gcloudignore‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
# $ gcloud topic gcloudignore
88
#
99
.gcloudignore
10-
# If you would like to upload your .git directory, .gitignore file or files
11-
# from your .gitignore file, remove the corresponding line
12-
# below:
1310
.git
1411
.gitignore
1512
#!include:.gitignore
@@ -23,13 +20,11 @@
2320
# Ignored by the build system
2421
/setup.cfg
2522

26-
static/node_modules/
23+
**/node_modules/
2724

2825
server/dist/
2926

30-
**/.venv/
31-
**/.venv_website/
32-
**/.venv_nl/
27+
**/.venv*/
3328

3429
# ONE/DFO: exclude build artifacts from Cloud Build context; keep source.
3530
# (.dockerignore above already propagates these via #!include, but listed explicitly for parity.)

‎.gitattributes‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Keep DFO-owned copies of upstream-tracked files across `git merge upstream/master`.
22
# `merge=ours` makes git keep our version and discard upstream's changes to these paths.
3-
# The driver is registered per-clone by `just setup` (git config merge.ours.driver true);
3+
# `just sync` and `just setup` register the driver per clone (git config merge.ours.driver true);
44
# without it git falls back to a normal 3-way merge.
55
README.md merge=ours

‎.github/workflows/build-and-pin.yml‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,12 @@ jobs:
110110
fi
111111
112112
- name: Free disk space
113-
# ubuntu-latest has ~14 GB usable, and this build pulls large NL
114-
# model/embedding files, installs torch CPU wheels, and exports every
115-
# intermediate layer via mode=max cache-to. Removing the runner's
116-
# preinstalled Android SDK, .NET, and GHC toolchains buys back room
117-
# without a third-party action.
113+
# ubuntu-latest has ~14 GB usable. The build holds four stages at
114+
# once (Go toolchain and module cache, the website's Python venv,
115+
# and two Node installs with their builds) on top of the runtime
116+
# base, and mode=max cache-to exports every intermediate layer.
117+
# Removing the runner's preinstalled Android SDK, .NET, and GHC
118+
# toolchains buys back room without a third-party action.
118119
run: |
119120
sudo rm -rf /usr/local/lib/android
120121
sudo rm -rf /usr/share/dotnet

‎.github/workflows/ci.yml‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ name: CI
88
# tree before it builds.
99
#
1010
# Does not build the Docker image. build/cdc_services/Dockerfile compiles
11-
# the Go mixer, builds two Python venvs, and runs a Next.js production
12-
# build across four stages -- several minutes even with cache, so it only
13-
# runs on push to a deploy branch, in deploy-dev.yml and deploy-prod.yml,
14-
# with a registry-backed cache to keep that path fast.
11+
# the Go mixer, installs the website's Python venv, builds the website's
12+
# static assets, and runs a Next.js production build, in four build stages
13+
# -- several minutes even with cache, so it only runs on push to a deploy
14+
# branch, in deploy-dev.yml and deploy-prod.yml, with a registry-backed
15+
# cache to keep that path fast.
1516

1617
on:
1718
pull_request:

‎CONTRIBUTING-DFO.md‎

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The DFO's Data Commons instance, meaning the mixer and the graph-serving layer u
99
Two kinds of code live here, and they behave differently.
1010

1111
- **Upstream code.** Everything outside `custom_dc/` tracks datacommonsorg/website and the `mixer` and `import` submodules. We take changes from upstream; we do not write them here.
12-
- **ONE Data code.** Everything under `custom_dc/` is ours (for the DFO). `custom_dc/dfo/prototypes` is the frontend, and `custom_dc/api_server` holds a legacy copy of the Search API that stays until its removal PR lands. Upstream never touches these paths, so an upstream sync cannot conflict with work there.
12+
- **ONE Data code.** Everything under `custom_dc/` is ours (for the DFO). `custom_dc/dfo/prototypes` is the frontend. Upstream never touches these paths, so an upstream sync cannot conflict with work there.
1313

1414
The repo builds one container image. A sibling repo, `infra`, deploys it to Cloud Run. This repo builds and pushes an image, and `infra` runs it.
1515

@@ -25,8 +25,6 @@ feat/* ──► dev ──► main
2525
dfo-dev dfo-prod
2626
```
2727

28-
`customdc_stable` is not a tier. It mirrors upstream's stable release channel and serves as the reference point for `just sync`.
29-
3028
## Where your work goes
3129

3230
The loop is short.
@@ -44,34 +42,39 @@ The loop is short.
4442

4543
## Taking upstream changes
4644

47-
Upstream sync is a step on `dev`, not a separate long-lived branch.
45+
`dev` tracks Data Commons Platform (DCP) releases. `infra` pins a DCP version as `dcp_version` in `infra/stacks/dcp/variables.tf`, and `dev` carries the website and mixer that release was built from. A sync is a merge of that website commit into `dev`, so `dev` shares history with datacommonsorg/website.
4846

4947
```sh
5048
git checkout dev
51-
git fetch upstream
52-
just sync # shows what changed since the last sync
53-
git merge upstream/master
54-
git submodule update --init --recursive
49+
just sync 1.1.6 # merge the website commit DCP 1.1.6 was built from
5550
```
5651

57-
Merging upstream's website also moves the `mixer` and `import` submodule pointers, because upstream pins them. **Website and submodules must move together.**
52+
`just sync` stops on conflicts. `just sync-resolve` takes upstream's side for every path outside `.dfo-protected-paths` and leaves the protected ones for you. After resolving those, `git add` them and run `just sync-finish`. `just sync-abort` drops the merge. Once committed, the recipe checks out the submodules and runs `just check-overrides`, which lists the seam files in `.dfo-overridden-files` that upstream changed across the sync.
5853

5954
### Matching a Data Commons Platform release
6055

61-
`infra` pins a DCP version (`1.1.x`) for the Terraform stack, and the image this repo builds has to match it. A website tag alone will not tell you which mixer that release runs. Google builds the release image from a website tag plus a mixer commit that runs ahead of what the tag pins. DCP 1.1.2 was built from website `v3.5.7` with mixer `79627f8`, while `v3.5.7` itself pins mixer `051d8ff`.
56+
The website and mixer move as a pair, and the pairing comes from the release image. Each image `gcr.io/datcom-ci/datacommons-services:<version>` records its source commits as the `WEBSITE_HASH` and `MIXER_HASH` build args. A website tag pins one mixer, and Google can build a release with a newer one. DCP 1.1.2 was built from website `v3.5.7` with mixer `79627f8`, while `v3.5.7` pins mixer `051d8ff`.
57+
58+
`just dcp-pair <version>` prints the pairing:
59+
60+
```sh
61+
$ just dcp-pair 1.1.6
62+
website=9852134
63+
mixer=8118587
64+
```
6265

63-
That mapping exists only inside the published image, as build args:
66+
It reads the image config from the registry, the same as:
6467

6568
```sh
6669
CFG=$(curl -s -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
67-
https://gcr.io/v2/datcom-ci/datacommons-services/manifests/1.1.2 | jq -r .config.digest)
70+
https://gcr.io/v2/datcom-ci/datacommons-services/manifests/1.1.6 | jq -r .config.digest)
6871
curl -sL https://gcr.io/v2/datcom-ci/datacommons-services/blobs/$CFG \
6972
| jq '.config.Env[] | select(contains("HASH"))'
7073
```
7174

72-
To move to a new DCP release, read `WEBSITE_HASH` and `MIXER_HASH` off that release's image, merge the website commit, then set the `mixer` pointer to `MIXER_HASH`. Taking the mixer the website tag carries instead builds a pairing Google never tested against that release's Terraform stack.
75+
`just sync` merges `WEBSITE_HASH`, sets the `mixer` pointer to `MIXER_HASH`, and sets the `import` pointer to the one the website commit pins. It fails if the image or either build arg is missing. Taking the mixer the website tag carries builds a pairing Google never tested against that release's Terraform stack.
7376

74-
`.github/workflows/codeql-analysis.yml`, `dependabot-approval.yml`, and `submodule-update.yml` are deleted in this fork. All three guard their jobs on `github.repository == 'datacommonsorg/website'`, so they never run here. Upstream re-adds them on every sync that touches them. Keep them deleted rather than resolving the conflict toward upstream's version.
77+
`.github/workflows/` is DFO-owned. A workflow file upstream adds there would run on the fork, so a sync takes nothing from upstream under that directory. `just sync` and `just sync-finish` reset it to the pre-merge version and list every file upstream added, changed, or deleted there. Port one by hand in its own PR if the fork needs it. Upstream's `codeql-analysis.yml`, `dependabot-approval.yml`, and `submodule-update.yml` stay deleted this way.
7578

7679
## Releasing to production
7780

@@ -109,5 +112,6 @@ always reproducible from a committed sha.
109112

110113
- **Commits** follow [Conventional Commits](https://www.conventionalcommits.org): `feat:`, `fix:`, `chore:`, and so on.
111114
- **PRs target `dev`.** Only the release step writes to `main`.
115+
- **PRs into `dev` land as merge commits.** The `dev` ruleset allows only merges. A sync commit's second parent is the upstream website commit, and that parent is what keeps the fork's history shared with datacommonsorg/website. A squash or rebase drops it, and the next sync merges from an older base and replays upstream changes the fork already has as conflicts.
112116
- **Delete merged branches.** Feature branches are short-lived.
113117
- **Keep internal notes out of the repo.** Design docs, plans, and audits stay local. This guide and real reference docs are the exception.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ New here? Read [CONTRIBUTING-DFO.md](./CONTRIBUTING-DFO.md) before opening a bra
66

77
## Layout
88

9-
- **`custom_dc/`** is ONE Data's DFO code. `custom_dc/dfo/prototypes` is the frontend, and `custom_dc/api_server` holds a legacy copy of the Search API that stays until its removal PR lands. The Search API and Datasets API are built in [apis](https://github.com/DevelopmentFinanceObservatory/apis). Upstream never touches these paths.
9+
- **`custom_dc/`** is ONE Data's DFO code. `custom_dc/dfo/prototypes` is the frontend. The Search API and Datasets API are built in [apis](https://github.com/DevelopmentFinanceObservatory/apis). Upstream never touches these paths.
1010
- **Everything else** tracks upstream `datacommonsorg/website`, with the graph server (`mixer`) and ingestion (`import`) as submodules.
1111

1212
## Quickstart

‎build/cdc_data/Dockerfile‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,21 @@ ENV ENV=${ENV}
2020

2121
WORKDIR /workspace
2222

23+
# Apply security patches for OS base packages (OpenSSL, Perl, glibc, pcre2, etc.)
24+
RUN apt-get update && apt-get upgrade -y \
25+
&& apt-get clean \
26+
&& rm -rf /var/lib/apt/lists/*
2327

2428
# Copy simple importer requirements.
2529
COPY import/simple/requirements.txt ./import/simple/requirements.txt
2630

2731
ARG PIP_DISABLE_PIP_VERSION_CHECK=1
2832
ARG PIP_NO_CACHE_DIR=1
2933

30-
# Create a virtual env, add it to path, and install all requirements.
34+
# Create a virtual env, add it to path, upgrade core packaging tools, and install all requirements.
3135
RUN python -m venv /workspace/venv
3236
ENV PATH="/workspace/venv/bin:$PATH"
37+
RUN pip3 install --no-cache-dir --upgrade pip "setuptools<70" wheel
3338

3439
# Install simple importer requirements.
3540
RUN pip3 install -r ./import/simple/requirements.txt
@@ -47,4 +52,4 @@ RUN chmod +x run.sh
4752
ENV PATH="/workspace/venv/bin:$PATH"
4853

4954
# Set the entrypoint to force bash execution
50-
ENTRYPOINT ["/bin/bash", "./run.sh"]
55+
ENTRYPOINT ["/bin/bash", "./run.sh"]

‎build/cdc_services/Dockerfile‎

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ RUN protoc \
4949
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/mixer cmd/main.go
5050

5151

52-
# #### Stage 2: Build python servers (website and NL). ####
52+
# #### Stage 2: Build python servers (website and MCP). ####
5353
FROM --platform=linux/amd64 python:3.11.14-slim as py-servers
5454

5555
ARG PIP_DISABLE_PIP_VERSION_CHECK=1
@@ -61,33 +61,21 @@ WORKDIR /workspace
6161
RUN apt-get update && apt-get -y upgrade && apt-get install -y git
6262

6363
# Copy requirements.
64-
# Copy nl_requirements.txt since it is referenced by embeddings requirements.txt
6564
COPY server/requirements.txt ./server/requirements.txt
66-
COPY nl_server/requirements.txt ./nl_server/requirements.txt
67-
COPY nl_requirements.txt ./nl_requirements.txt
68-
COPY torch_requirements.txt ./torch_requirements.txt
6965

7066
# Create a virtual env and install requirements.
7167
RUN python -m venv ./venv
7268
ENV PATH="/workspace/venv/bin:$PATH"
73-
RUN pip3 install --upgrade pip setuptools \
69+
RUN pip3 install --no-cache-dir --upgrade pip setuptools \
7470
&& pip3 install --no-cache-dir -r /workspace/server/requirements.txt \
75-
&& pip3 install --no-cache-dir -r /workspace/torch_requirements.txt --index-url https://download.pytorch.org/whl/cpu \
76-
&& pip3 install --no-cache-dir -r /workspace/nl_server/requirements.txt \
7771
&& pip3 install --no-cache-dir datacommons-mcp
7872

7973
# Copy website app script.
8074
COPY web_app.py ./web_app.py
8175
# Copy server module.
8276
COPY server/. ./server/
83-
# Copy NL app script.
84-
COPY nl_app.py ./nl_app.py
85-
# Copy nl_server module.
86-
COPY nl_server/. ./nl_server/
8777
# Copy the shared module.
8878
COPY shared/. ./shared/
89-
# Copy yaml files.
90-
COPY deploy/nl/. /datacommons/nl/
9179

9280

9381
# #### Stage 3: Build static website assets. ####
@@ -116,19 +104,6 @@ WORKDIR /workspace/static
116104
RUN npm run-script build
117105

118106

119-
# #### Stage 4: Download base dc model and embeddings from GCS. ####
120-
FROM --platform=linux/amd64 google/cloud-sdk:slim as download
121-
122-
# Remove auth check since these are public buckets and we don't have credentials within the container.
123-
# Copy model and embeddings.
124-
RUN gcloud config set auth/disable_credentials True \
125-
&& mkdir -p /tmp/datcom-nl-models \
126-
&& gcloud storage cp --recursive \
127-
gs://datcom-nl-models/ft_final_v20230717230459.all-MiniLM-L6-v2/ \
128-
gs://datcom-nl-models/embeddings_medium_2024_05_09_18_01_32.ft_final_v20230717230459.all-MiniLM-L6-v2.csv \
129-
/tmp/datcom-nl-models/
130-
131-
132107
# >>> DFO bake-in (custom_dc/dfo) >>>
133108
# ONE/DFO: Build the DFO prototyping Next.js app (custom_dc/dfo/prototypes).
134109
# Isolated stage; upstream never edits this. See custom_dc/dfo/README.md.
@@ -145,7 +120,10 @@ COPY custom_dc/dfo/prototypes/ ./
145120
# Wire /prototype/search to the live Search API. This is a NEXT_PUBLIC_* var, so
146121
# it is inlined into the browser bundle at build time — a runtime env on Cloud Run
147122
# cannot flip it. Set to 0 (--build-arg NEXT_PUBLIC_USE_SEARCH_API=0) to bake a
148-
# fixtures-only image. The engine still needs GEMINI_API_KEY set at runtime.
123+
# fixtures-only image. /api/search is rewritten to dfo-apis and needs no key here.
124+
# GEMINI_API_KEY (or GOOGLE_API_KEY) is read at runtime by /api/similarity, which
125+
# falls back to pseudo-embeddings without it, and by /api/skill-compare
126+
# (lib/skillAgent.ts), which returns an error without it.
149127
ARG NEXT_PUBLIC_USE_SEARCH_API=1
150128
ENV NEXT_PUBLIC_USE_SEARCH_API=${NEXT_PUBLIC_USE_SEARCH_API}
151129
# The website origin that next.config.mjs bakes into the /api/search and
@@ -194,13 +172,10 @@ COPY --from=mixer /workspace/deploy/featureflags deploy/featureflags
194172
COPY --from=mixer /workspace/mixer-grpc.pb .
195173
# nginx.
196174
COPY build/cdc_services/nginx.conf .
197-
# Website and NL servers.
175+
# Website server.
198176
COPY --from=py-servers /workspace/ .
199-
COPY --from=py-servers /datacommons/ /datacommons
200177
# Static website assets.
201178
COPY --from=static /workspace/server ./server
202-
# Downloaded model and embeddings.
203-
COPY --from=download /tmp/datcom-nl-models /tmp/datcom-nl-models
204179

205180
# Copy executable script.
206181
COPY build/cdc_services/run.sh .

0 commit comments

Comments
 (0)