Skip to content

Commit cf48550

Browse files
committed
Initial commit
0 parents  commit cf48550

Some content is hidden

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

53 files changed

+6653
-0
lines changed

.devcontainer/data/library.tgz

5.43 MB
Binary file not shown.

.devcontainer/devcontainer.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/java
3+
{
4+
"name": "MongoDB Query API Java Lab - Dev Container",
5+
"dockerComposeFile": "docker-compose.yml",
6+
"service": "jedee",
7+
"features": {
8+
"ghcr.io/devcontainers/features/java:1": {
9+
"version": "21",
10+
"installMaven": "true",
11+
"mavenVersion": "3.9.10"
12+
}
13+
},
14+
"updateContentCommand": "bash .devcontainer/setup.sh && bash .devcontainer/install-mongodb-db-tools.sh && bash .devcontainer/import.sh",
15+
"postCreateCommand": "",
16+
"postAttachCommand": "",
17+
"postStartCommand": "jupyter trust java/*.ipynb && jupyter notebook java/*.ipynb --allow-root",
18+
"customizations": {
19+
"vscode": {
20+
"extensions": [
21+
"ms-toolsai.jupyter",
22+
"mongodb.mongodb-vscode"
23+
]
24+
}
25+
},
26+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
27+
"forwardPorts": [
28+
8888,
29+
27017
30+
],
31+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}"
32+
// Use 'postCreateCommand' to run commands after the container is created.
33+
// Configure tool-specific properties.
34+
// "customizations": {},
35+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
36+
// "remoteUser": "root"
37+
}

.devcontainer/docker-compose.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: '3.8'
2+
3+
services:
4+
jedee:
5+
image: debian:bookworm-slim
6+
volumes:
7+
- ../..:/workspaces:cached
8+
9+
# Overrides default command so things don't shut down after the process ends.
10+
command: sleep infinity
11+
12+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
13+
network_mode: service:mongodb
14+
15+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
16+
# (Adding the "ports" property to this file will not forward from a Codespace.)
17+
18+
mongodb:
19+
image: mongodb/mongodb-atlas-local:8.0.18
20+
restart: unless-stopped
21+
volumes:
22+
- mongodb-data:/data/db
23+
24+
# Uncomment to change startup options
25+
environment:
26+
- MONGODB_INITDB_ROOT_USERNAME=admin
27+
- MONGODB_INITDB_ROOT_PASSWORD=mongodb
28+
- MONGO_INITDB_DATABASE=library
29+
ports:
30+
- 27017:27017
31+
32+
33+
# Add "forwardPorts": ["27017"] to **devcontainer.json** to forward MongoDB locally.
34+
# (Adding the "ports" property to this file will not forward from a Codespace.)
35+
36+
volumes:
37+
mongodb-data:

.devcontainer/import.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
cd .devcontainer/data
4+
5+
# Import Library data WITHOUT embeddings
6+
7+
tar xvfz library.tgz
8+
9+
mongorestore --uri mongodb://localhost:27017/library --username admin --password mongodb --drop --authenticationDatabase=admin library
10+
11+
cd ..
12+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# Install MongoDB command line tools
4+
5+
# We need to download MongoDB Database Tools to import data. In Linux we have two architectures:
6+
# Linux identifies as amd64, in MongoDB the file has ARM64 for Mac M1
7+
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2404-arm64-100.11.0.tgz
8+
# Linux identifies as aarch64, in MongoDB the file has x86_64 for intel
9+
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2404-x86_64-100.11.0.tgz
10+
11+
export MONGO_TOOLS_VERSION=100.11.0
12+
export ARCH=$(dpkg --print-architecture)
13+
if [ $ARCH = "amd64" ]; then export TARGET_ARCH="x86_64"; else export TARGET_ARCH="arm64"; fi
14+
export TARGET="mongodb-database-tools-ubuntu2404-${TARGET_ARCH}-${MONGO_TOOLS_VERSION}.deb"
15+
echo "Installing tools for architecture $ARCH, linux/${TARGET_ARCH}, target file=${TARGET}"
16+
echo "curl https://fastdl.mongodb.org/tools/db/${TARGET}"
17+
curl "https://fastdl.mongodb.org/tools/db/${TARGET}" --output "${TARGET}"
18+
apt-get install -y "./${TARGET}"
19+
rm "./${TARGET}"
20+
21+
# Install mongosh
22+
23+
# https://downloads.mongodb.com/compass/mongosh-2.4.0-linux-x64.tgz
24+
# https://downloads.mongodb.com/compass/mongosh-2.4.0-linux-arm64.tgz
25+
26+
echo "Installing mongosh"
27+
if [ ARCH = "amd64" ]; then export MONGO_SHELL="mongosh-2.4.0-linux-x64"; else export MONGO_SHELL="mongosh-2.4.0-linux-arm64"; fi
28+
curl "https://downloads.mongodb.com/compass/${MONGO_SHELL}.tgz" --output "${MONGO_SHELL}.tgz"
29+
tar xvfz "${MONGO_SHELL}.tgz"
30+
rm "./${MONGO_SHELL}.tgz"
31+
cp mongosh-2.4.0-linux-arm64/bin/* /usr/local/bin/
32+
rm -rf "./${MONGO_SHELL}"

.devcontainer/setup.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
echo ✅ APT GET UPDATE
4+
echo ✅ --------------
5+
apt-get update -y
6+
7+
apt-get install python3.8
8+
9+
echo ✅ Install Jupyter notebook
10+
echo ✅ ------------------------
11+
# Install Jupyter notebook
12+
apt-get install jupyter -y
13+
apt-get clean packages
14+
15+
echo ✅ Install Jupyter Java Kernel
16+
echo ✅ ---------------------------å
17+
# Java Kernel
18+
python3 ijava-1.3.0/install.py
19+
apt-get clean packages
20+
21+
echo ✅ Install cURL
22+
echo ✅ ----------------
23+
apt-get install curl -y
24+
apt-get clean packages

.github/CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# These owners will be the default owners for everything in
2+
# the repo. Unless a later match takes precedence,
3+
# @global-owner1 and @global-owner2 will be requested for
4+
# review when someone opens a pull request.
5+
* @sis0k0 @dfreniche @mrlynn @nestor-daza-mdb
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Description
2+
Briefly describe why this pull request is needed.
3+
4+
## Changes Made
5+
- List the key changes or features added.
6+
7+
## Type of Changes
8+
9+
- [ ] Bug fix
10+
- [ ] New feature
11+
- [ ] Improvement
12+
- [ ] Documentation update
13+
- [ ] Refactoring
14+
- [ ] Other (please specify):
15+
16+
## Does this change require updates to other systems or dependencies?
17+
18+
- [ ] Instruqt
19+
- [ ] Workshop slides
20+
- [ ] Other (please specify):
21+
22+
## Checklist
23+
- [ ] I have tested the changes locally.
24+
- [ ] I have updated the documentation if necessary.
25+
- [ ] I have reviewed my own code for potential issues.
26+
- [ ] The changes are ready for review.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# .github/workflows/clear-notebook-outputs.yml
2+
# This workflow removes the outputs from Jupyter notebooks (.ipynb files)
3+
# whenever changes are pushed to the repository.
4+
# When we run a Notebook locally it generates output that we don't want to commit
5+
name: Remove Notebook Outputs
6+
permissions:
7+
contents: write
8+
9+
on:
10+
push:
11+
push:
12+
branches:
13+
- '**'
14+
pull_request:
15+
branches:
16+
- '**'
17+
18+
19+
jobs:
20+
remove-notebook-outputs:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout source repo
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Git
27+
run: |
28+
git config --global user.name "Clear Notebook Outputs Action"
29+
git config --global user.email "diego.freniche@mongodb.com"
30+
31+
- name: Install prerequisites
32+
run: |
33+
sudo apt-get update -y
34+
35+
sudo apt-get install python3.8 -y
36+
37+
echo ✅ Install Jupyter notebook
38+
echo ✅ ------------------------
39+
# Install Jupyter notebook
40+
sudo apt-get install jupyter -y
41+
42+
- name: Clear Jupyter notebook run outputs
43+
run: |
44+
# Get all notebook files
45+
files=$(git ls-files '*.ipynb')
46+
[ -z "$files" ] && exit 0
47+
48+
for f in $files; do
49+
echo $f
50+
# Clear outputs + execution_count in place
51+
jupyter nbconvert \
52+
--ClearOutputPreprocessor.enabled=True \
53+
--inplace "$f"
54+
55+
# Re-stage cleaned file
56+
git add "$f"
57+
done
58+
59+
if git diff --cached --quiet; then
60+
echo "No staged changes; skipping commit"
61+
exit 0
62+
else
63+
git commit -m "Clear notebook outputs" --no-verify
64+
git push origin HEAD:${{ github.ref_name }}
65+
fi

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.ipynb_checkpoints
2+
.devcontainer/data/library
3+
.devcontainer/data/library_with_embeddings/*.?son
4+
javascript/node_modules

0 commit comments

Comments
 (0)