Skip to content

Commit

Permalink
Bundle import tool into RSI docker image; Add website endpoint for RS…
Browse files Browse the repository at this point in the history
…I data load (#3667)
  • Loading branch information
shifucun authored Oct 5, 2023
1 parent 3ab3f7f commit 3a64da5
Show file tree
Hide file tree
Showing 12 changed files with 426 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ experimental/sdg-static/datacommons/nl_interface.min.css

# Custom DC data
data/
dc-data/

# Topic cache
gen_ordered_list_for_topics.mcf
Expand Down
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "mixer"]
path = mixer
url = https://github.com/datacommonsorg/mixer.git
url = https://github.com/datacommonsorg/mixer.git
[submodule "import"]
path = import
url = https://github.com/datacommonsorg/import.git
2 changes: 1 addition & 1 deletion build/python_node_go_protoc_envoy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
FROM python:3.11.4-slim as base

RUN apt update
RUN apt install -y curl zip wget
RUN apt install -y curl zip wget gcc libc6-dev

# Install Node
ENV NODE_VERSION=18.17.1
Expand Down
2 changes: 1 addition & 1 deletion build/python_node_go_protoc_envoy/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

substitutions:
_VERS: "2023-08-19"
_VERS: "2023-10-05"

steps:
- name: "gcr.io/cloud-builders/docker"
Expand Down
9 changes: 8 additions & 1 deletion build/web_compose/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.


FROM gcr.io/datcom-ci/python-node-go-protoc-envoy:2023-08-19
FROM gcr.io/datcom-ci/python-node-go-protoc-envoy:2023-10-05

ARG ENV
ENV ENV=${ENV}
Expand Down Expand Up @@ -48,6 +48,7 @@ RUN GRPC_HEALTH_PROBE_VERSION=v0.4.7 && \
# Build binary
COPY mixer/cmd/ cmd
COPY mixer/esp/ esp
ENV CGO_ENABLED=1
RUN go build -o /go/bin/mixer cmd/main.go

# Flask
Expand All @@ -57,6 +58,8 @@ RUN pip install --upgrade pip
RUN pip install --upgrade setuptools
# --no-cache-dir removes ~/.cache files, which can be a few GB.
RUN pip3 install --no-cache-dir -r /workspace/server/requirements.txt
# Used by Import Tool
RUN pip install pandas

# NPM
WORKDIR /workspace/static
Expand All @@ -72,6 +75,10 @@ RUN npm run-script build
COPY server/. /workspace/server/
COPY shared/. /workspace/shared/

# Import Tool
COPY import/. /workspace/import/

# Env
ENV USE_SQLITE=false
ENV USE_CLOUDSQL=false
ENV REMOTE_MIXER_DOMAIN=https://api.datacommons.org
Expand Down
10 changes: 4 additions & 6 deletions docs/custom_dc.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,21 @@ docker run -it --pull=always \
-e USE_SQLITE=true \
-e SQL_DATA_PATH=/sqlite \
-p 8080:8080 \
-p 8081:8081 \
-v $HOME/dc-data:/sqlite \
gcr.io/datcom-ci/datacommons-website-compose:latest
```

Run `curl -X POST localhost:8080/import/simple/load2sql` to load the data into
database. Whenever there is update on the data, re-run this commands (no need to
restart the container).

If you have your own UI updates and build the docker image locally, replace the
docker image with your locally one in the command.

Now you can access a custom Data Commons site via
[localhost](http://localhost:8080). For example, the data from the sample data
can be viewed in [Timeline Chart](http://localhost:8080/tools/timeline#place=geoId%2F06&statsVar=stat_var_1).

If the CSV files are updated, just run `curl -X POST localhost:8081/import`.
This re-imports the CSV files into the local instance without the need to
restart the container.

## Run in Cloud

Custom Data Commons can be ran on the cloud as a production service. The SQLite
Expand Down Expand Up @@ -148,7 +147,6 @@ docker run -it \
-e GOOGLE_APPLICATION_CREDENTIALS=/gcp/creds.json \
-v $HOME/.config/gcloud/application_default_credentials.json:/gcp/creds.json:ro \
-p 8080:8080 \
-p 8081:8081 \
gcr.io/datcom-ci/datacommons-website-compose:latest
```

Expand Down
1 change: 1 addition & 0 deletions import
Submodule import added at fd9e74
40 changes: 20 additions & 20 deletions server/config/subject_page_pb2.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"USStateQuarterlyIndustryGDP_NAICS_44_45",
"dc/topic/Economy",
"dc/topic/EconomicEquity",
"dc/topic/GDP",
"Amount_EconomicActivity_GrossDomesticProduction_RealValue",
"dc/topic/GDP",
"Amount_EconomicActivity_GrossDomesticProduction_Nominal_AsAFractionOf_Count_Person"
]
}
Loading

0 comments on commit 3a64da5

Please sign in to comment.