diff --git a/README.md b/README.md index b6bf2ee46250c2d47de504e7d215a8e8bc9f4657..c60a3d7836b1be9b3320f37128a293fceda5b655 100644 --- a/README.md +++ b/README.md @@ -30,27 +30,24 @@ All folders are isolated projects. `cd` into the folder to run/build them. *Some Project Access Tokens are available and will be provided to members.* ## Local development -### jobs +### jobs and tasks -Jobs are run inside of docker containers. There is a docker build script (`Dockerfile`) and can be run in `dev` mode via `docker run`. Please be aware it can take a while to build the initial image. +Jobs and tasks are run inside of docker containers. There is a docker build script (`Dockerfile`) and can be run in `dev` mode via `docker run`. Please be aware it can take a while to build the initial image. At root directory, to build the image run: - cd jobs bash build/build_image.sh -The image is built now and ready to be used! The tests in the Docker container built from the image can be sanity-checked via (test implementation without minio-s3-parameter transport): +The image is built now and ready to be used! The tests in the Docker container built from the image can be sanity-checked via : - docker run -it --rm git.imp.fu-berlin.de:5000/comp-sci-project/jobs:local python unittests/test_a_job.py + docker run -it --rm git.imp.fu-berlin.de:5000/comp-sci-project/jobs-n-tasks:local python jobs/unittests/test_a_job.py -For live experience (meaning you enter the container), run: - - docker run -it --rm git.imp.fu-berlin.de:5000/comp-sci-project/jobs:local /bin/bash +or for testing a task: -If you change code in `src`, you need to rebuild the image with `bash build/build_image.sh`. The `src` folder can also be mounted in the image, but the assumption is that life is already difficult as it is... + docker run -it --rm git.imp.fu-berlin.de:5000/comp-sci-project/jobs-n-tasks:local python tasks/integration-tests/test_a_task.py -### tasks (! Under construction !) +For live experience (meaning you enter the container), run: -Tasks are python scripts that can spawn jobs which run in docker containers. Before calling a task, make sure you have built the related job-image. + docker run -it --rm git.imp.fu-berlin.de:5000/comp-sci-project/jobs-n-tasks:local /bin/bash - python -B src/a_task.py local --config=docker.yaml --IN0 demo-inputs/system.json --OUT /tmp/test-a-task +If you change code in `src`, you need to rebuild the image with `bash build/build_image.sh`. The `src` folder can also be mounted in the image, but the assumption is that life is already difficult as it is... *Free and open-source software for all souls! Technical support is, unfortunately, only for group members.* \ No newline at end of file diff --git a/jobs/build/Dockerfile b/build/Dockerfile similarity index 91% rename from jobs/build/Dockerfile rename to build/Dockerfile index efb80ba33e21e5f4b8378c484894010c009b7045..f8b0b93706ff6b3bf8849edc6d0ce644a8cf04ec 100644 --- a/jobs/build/Dockerfile +++ b/build/Dockerfile @@ -51,10 +51,10 @@ RUN curl -sSL https://install.python-poetry.org | python - # ------------------------------------------------------------ WORKDIR /usr/src/app -ADD pyproject.toml . +ADD build/pyproject.toml . -ADD src ./src -ADD unittests ./unittests +ADD tasks/ ./tasks +ADD jobs/ ./jobs RUN poetry install --only main --compile -vv @@ -81,7 +81,9 @@ COPY --from=packaging /usr/src/app /usr/src/app WORKDIR /usr/src/app ENV PATH="/usr/src/app/.venv/bin:$PATH" -# Add the src directory to PYTHONPATH -ENV PYTHONPATH="/usr/src/app/src:${PYTHONPATH}" +# Add the src directories to PYTHONPATH +ENV PYTHONPATH="/usr/src/app/jobs/src:${PYTHONPATH}" +ENV PYTHONPATH="/usr/src/app/tasks/src:${PYTHONPATH}" + CMD ["python"] diff --git a/jobs/build/build-image.sh b/build/build-image.sh similarity index 68% rename from jobs/build/build-image.sh rename to build/build-image.sh index 63e02b332c8e481aba3b68980dd241ea80b0eeba..db8fbbbdc2c78e290c586204d16aeb84bd9bf7cb 100644 --- a/jobs/build/build-image.sh +++ b/build/build-image.sh @@ -4,7 +4,9 @@ set -e CWD=$(cd $(dirname $0); pwd) REGISTRY=git.imp.fu-berlin.de:5000/comp-sci-project -IMAGE=${REGISTRY}/jobs:${RELEASE:-local} +# REGISTRY=git.imp.fu-berlin.de:5000/nguyed99/comp-sci-project + +IMAGE=${REGISTRY}/jobs-n-tasks:${RELEASE:-local} BASE_VERSION="3.11.5-slim" echo Building $IMAGE @@ -15,4 +17,6 @@ docker build \ --platform linux/amd64 \ --build-arg BASE_VERSION=$BASE_VERSION \ -t $IMAGE \ - "$CWD/.." \ No newline at end of file + "$CWD/.." + +# docker push $IMAGE \ No newline at end of file diff --git a/jobs/pyproject.toml b/build/pyproject.toml similarity index 100% rename from jobs/pyproject.toml rename to build/pyproject.toml diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 5d6a5422810efdeeaa55244f6b1f1c1800c0d9ab..0000000000000000000000000000000000000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: '3.4' -services: - minio: - image: minio/minio - container_name: minio-s3 - environment: - MINIO_ROOT_USER: minioadmin - MINIO_ROOT_PASSWORD: minioadmin - ports: - - '9000:9000' - - '9001:9001' - command: server /data --console-address ":9001" - volumes: - - minio_data:/data - -# let docker handle persistence of the data directory -volumes: - minio_data: {} \ No newline at end of file diff --git a/jobs/unittests/test_a_job.py b/jobs/unittests/test_a_job.py index 83b0b3b721a5dab962750c50b44fe82a86275cf6..6a846e882edf2cc455fbedbda90b3fbf0f3c72d5 100644 --- a/jobs/unittests/test_a_job.py +++ b/jobs/unittests/test_a_job.py @@ -3,7 +3,7 @@ import unittest import numpy as np -from src.a_job import sigma_x, sigma_y, sigma_z +from jobs.src.a_job import sigma_x, sigma_y, sigma_z logger = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) diff --git a/tasks/docker.yaml b/tasks/docker.yaml deleted file mode 100644 index 63076dceffda35fd549e8dae323130184db0e57e..0000000000000000000000000000000000000000 --- a/tasks/docker.yaml +++ /dev/null @@ -1,31 +0,0 @@ -backend: - name: docker-dev - kind: docker - release: local - transport: - name: minio - kind: s3 - url: s3+http://minioadmin:minioadmin@127.0.0.1:9000/test - remoteUrl: s3+http://minioadmin:minioadmin@127.0.0.1:9000/test - imageSpecs: - "git.imp.fu-berlin.de:5000/comp-sci-project:local": - network_mode: host - volumes: - ../jobs/src: - bind: /usr/src/app/src - mode: ro - defaultSpecs: - network_mode: host - maxCpu: 4 - -plugins: - - kind: logging - - kind: resources - - kind: metrics - name: honeycomb - host: https://api.honeycomb.io - apiKey: 1X7YfLO8iH3zevALRjxL5F - dataset: honeycomb-python-example - - kind: storage - -numJobs: 3 diff --git a/tasks/integration-tests/test_a_task.py b/tasks/integration-tests/test_a_task.py index 93c36b9915a1fb8a3d677b4c80101c326753adcf..8ca451b012d308299d7bc9142beb4ad953f3b2a8 100644 --- a/tasks/integration-tests/test_a_task.py +++ b/tasks/integration-tests/test_a_task.py @@ -3,7 +3,7 @@ import unittest import numpy as np -from src.a_task import swap_gate +from tasks.src.a_task import swap_gate logger = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) diff --git a/tasks/src/a_task.py b/tasks/src/a_task.py index 7a53867f8638f139220c922834d9baa02a370b0f..244563fa452065c69a382c385525976b79b13391 100644 --- a/tasks/src/a_task.py +++ b/tasks/src/a_task.py @@ -11,6 +11,6 @@ from jobs.src.a_job import sigma_x, sigma_y, sigma_z def swap_gate() -> np.ndarray: - swap_matrix = (np.kron(np.identity(2), np.identity(2)) + np.kron(sigma_x(), sigma_x()) + - np.kron(sigma_y(), sigma_y()) + np.kron(sigma_z(), sigma_z())) + swap_matrix = 1 / 2 * (np.kron(np.identity(2), np.identity(2)) + np.kron(sigma_x(), sigma_x()) + + np.kron(sigma_y(), sigma_y()) + np.kron(sigma_z(), sigma_z())) return swap_matrix