chore: Move to the mono repo layout

This commit is contained in:
Quentin Bourgerie
2023-03-08 11:23:21 +01:00
parent 4fb476aaec
commit ce7eddc22d
201 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
FROM ubuntu:22.04
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Replace default archive.ubuntu.com with fr mirror
# original archive showed performance issues and is farther away
RUN sed -i 's|^deb http://archive|deb http://fr.archive|g' /etc/apt/sources.list
COPY ./script/make_utils/setup_os_deps.sh ./setup_os_deps.sh
RUN ./setup_os_deps.sh --linux-install-python && rm ./setup_os_deps.sh
ENV SRC_DIR=/src
# Default to Ubuntu default uid for first user
ARG BUILD_GID=1000
ARG BUILD_UID=1000
# Get sudo for our future user
RUN apt-get update && \
apt-get install --no-install-recommends -y sudo && \
rm -rf /var/lib/apt/lists/*
# From https://dev.to/emmanuelnk/using-sudo-without-password-prompt-as-non-root-docker-user-52bg
# Create dev_user and add it to relevant groups
# Create /src and make the dev user own it
# Ensure sudo group users are not asked for a password when using
# sudo command by ammending sudoers file
RUN groupadd -g "${BUILD_GID}" dev_user && \
adduser --disabled-password \
--uid "${BUILD_UID}" --gid "${BUILD_GID}" --shell /bin/bash --gecos "" dev_user && \
usermod -aG sudo dev_user && \
mkdir -p "${SRC_DIR}" && \
chown dev_user "${SRC_DIR}" && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# Now switch to the newly created user
USER dev_user
RUN echo "source ~/dev_venv/bin/activate" >> ~/.bashrc && \
echo "if [[ \"\$?\" != \"0\" ]]; then" >> ~/.bashrc && \
echo " python3 -m venv ~/dev_venv" >> ~/.bashrc && \
echo " source ~/dev_venv/bin/activate" >> ~/.bashrc && \
echo " cd ${SRC_DIR}/ && make setup_env" >> ~/.bashrc && \
echo "fi" >> ~/.bashrc && \
echo "export MPLBACKEND=TkAgg" >> ~/.bashrc && \
touch ~/.sudo_as_admin_successful && \
mkdir -p ~/dev_venv && \
mkdir -p ~/.cache
WORKDIR ${SRC_DIR}
CMD ["/bin/bash"]

View File

@@ -0,0 +1 @@
!script/make_utils/setup_os_deps.sh

View File

@@ -0,0 +1,36 @@
FROM ubuntu:22.04
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Replace default archive.ubuntu.com with fr mirror
# original archive showed performance issues and is farther away
RUN sed -i 's|^deb http://archive|deb http://fr.archive|g' /etc/apt/sources.list
RUN mkdir /pkg && mkdir /app
WORKDIR /pkg
COPY docker/release_resources/release_requirements.txt .
COPY ./pkg/*.whl .
RUN apt-get update && apt-get upgrade --no-install-recommends -y && \
apt-get install --no-install-recommends -y \
build-essential \
python3-pip \
python3 \
python3-dev \
python3-tk \
python-is-python3 && \
rm -rf /var/lib/apt/lists/* && \
python3 -m pip install --no-cache-dir --upgrade pip wheel setuptools && \
echo "export MPLBACKEND=TkAgg" >> /root/.bashrc && \
python3 -m pip install --no-cache-dir "$(ls ./*.whl)" && \
python3 -m pip install --no-cache-dir -r release_requirements.txt
WORKDIR /app
COPY docker/release_resources/entry_point.sh ./entry_point.sh
RUN mkdir /data
WORKDIR /data
VOLUME [ "/data" ]
CMD ["/bin/bash", "-i", "/app/entry_point.sh"]

View File

@@ -0,0 +1,6 @@
# Not our sources
!docker/release_resources/entry_point.sh
!docker/release_resources/release_requirements.txt
!pkg/
!pkg/**

View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
CURR_DIR=$(dirname "$0")
DOCKER_BUILDKIT=1 docker build --pull --no-cache -f "$CURR_DIR/Dockerfile.release" \
-t concrete-numpy-release "$CURR_DIR/.."

View File

@@ -0,0 +1,3 @@
#!/bin/bash
python3 -m jupyter notebook --ip=0.0.0.0 --allow-root --no-browser

View File

@@ -0,0 +1 @@
jupyter~=1.0.0

View File

@@ -0,0 +1,41 @@
import random
import concrete.numpy as cnp
def main():
def function_to_compile(x):
return x + 42
n_bits = 3
compiler = cnp.Compiler(
function_to_compile,
{"x": "encrypted"},
)
print("Compiling...")
engine = compiler.compile(range(2 ** n_bits))
inputs = []
labels = []
for _ in range(4):
sample_x = random.randint(0, 2 ** n_bits - 1)
inputs.append([sample_x])
labels.append(function_to_compile(*inputs[-1]))
correct = 0
for idx, (input_i, label_i) in enumerate(zip(inputs, labels), 1):
print(f"Inference #{idx}")
result_i = engine.encrypt_run_decrypt(*input_i)
if result_i == label_i:
correct += 1
print(f"{correct}/{len(inputs)}")
if __name__ == "__main__":
main()