From d1a895c4c59c4fca4b6d97760f8e58bcb91d26e3 Mon Sep 17 00:00:00 2001 From: Glauber Costa Vila-Verde Date: Thu, 8 Feb 2024 12:52:17 -0300 Subject: [PATCH] Added env.sh to bashrc and check if bsp and leap second files exists in first run (#824) --- .devcontainer/devcontainer.json | 89 ++++++++++++++----------------- predict_occultation/Dockerfile | 22 +++++--- predict_occultation/entrypoint.sh | 31 +++++++++++ predict_occultation/src/env.sh | 1 + predict_occultation/src/rerun.sh | 2 +- 5 files changed, 89 insertions(+), 56 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8297bc2a2..1006be7e4 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,52 +1,44 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose { - "name": "TNO Devcontainer", - - // Update the 'dockerComposeFile' list if you have more compose files or use different names. - // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. - "dockerComposeFile": [ - "../docker-compose-development-template.yml", - "docker-compose.yml" - ], - - // The 'service' property is the name of the service for the container that VS Code should - // use. Update this value and .devcontainer/docker-compose.yml to the real service name. - "service": "vscode", - - // The optional 'workspaceFolder' property is the path VS Code should open by default when - // connected. This is typically a file mount in .devcontainer/docker-compose.yml - "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - - // Features to add to the dev container. More info: https://containers.dev/features. - "features": { - "ghcr.io/devcontainers/features/common-utils:2": {}, - // "ghcr.io/devcontainers-contrib/features/black:2": {}, - // "ghcr.io/devcontainers-contrib/features/coverage-py:2": {}, - // "ghcr.io/devcontainers-contrib/features/isort:2": {}, - "ghcr.io/devcontainers-contrib/features/pre-commit:2": {}, - "ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {}, - "ghcr.io/stuartleeks/dev-container-features/shell-history:0": {}, - "ghcr.io/guiyomh/features/vim:0": {}, - "ghcr.io/devcontainers/features/node:1":{}, - "ghcr.io/devcontainers-contrib/features/act:1":{}, - "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, - "ghcr.io/devcontainers/features/github-cli:1": {} - }, - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - // Uncomment the next line if you want start specific services in your Docker Compose config. - // "runServices": [], - - // Uncomment the next line if you want to keep your containers running after VS Code shuts down. - // "shutdownAction": "none", - - // Uncomment the next line to run commands after the container is created. - // "postCreateCommand": "cat /etc/os-release", - - // Configure tool-specific properties. + "name": "TNO Devcontainer", + // Update the 'dockerComposeFile' list if you have more compose files or use different names. + // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. + "dockerComposeFile": [ + "../docker-compose-development-template.yml", + "../docker-compose.yml", + "docker-compose.yml" + ], + // The 'service' property is the name of the service for the container that VS Code should + // use. Update this value and .devcontainer/docker-compose.yml to the real service name. + "service": "vscode", + // The optional 'workspaceFolder' property is the path VS Code should open by default when + // connected. This is typically a file mount in .devcontainer/docker-compose.yml + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/devcontainers/features/common-utils:2": {}, + // "ghcr.io/devcontainers-contrib/features/black:2": {}, + // "ghcr.io/devcontainers-contrib/features/coverage-py:2": {}, + // "ghcr.io/devcontainers-contrib/features/isort:2": {}, + "ghcr.io/devcontainers-contrib/features/pre-commit:2": {}, + "ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {}, + "ghcr.io/stuartleeks/dev-container-features/shell-history:0": {}, + "ghcr.io/guiyomh/features/vim:0": {}, + "ghcr.io/devcontainers/features/node:1": {}, + "ghcr.io/devcontainers-contrib/features/act:1": {}, + "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Uncomment the next line if you want start specific services in your Docker Compose config. + // "runServices": [], + // Uncomment the next line if you want to keep your containers running after VS Code shuts down. + // "shutdownAction": "none", + // Uncomment the next line to run commands after the container is created. + // "postCreateCommand": "cat /etc/os-release", + // Configure tool-specific properties. "customizations": { "vscode": { "settings": { @@ -91,7 +83,6 @@ ] } } - - // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "devcontainer" + // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "devcontainer" } diff --git a/predict_occultation/Dockerfile b/predict_occultation/Dockerfile index 813f4713c..45ddce489 100644 --- a/predict_occultation/Dockerfile +++ b/predict_occultation/Dockerfile @@ -71,16 +71,19 @@ ENV PYTHONDONTWRITEBYTECODE=1 # This option has no effect on the stdin stream. ENV PYTHONUNBUFFERED=1 +ENV BSP_PLANETARY_NAME=de440.bsp +ENV LEAP_SECOND_NAME=naif0012.tls + # Download da BSP planetary # OBS. o Download demora bastante! RUN wget --no-verbose --show-progress \ --progress=bar:force:noscroll \ - https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de440.bsp + https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/$BSP_PLANETARY_NAME # Download Leap Second RUN wget --no-verbose --show-progress \ --progress=bar:force:noscroll \ - https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/naif0012.tls + https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/$LEAP_SECOND_NAME # PRAIA OCC binaries COPY --from=praia_occ /tmp/praia_occ/* /usr/local/bin @@ -138,20 +141,27 @@ COPY --chown=${USERNAME}:ton --chmod=775 entrypoint.sh ${APP_HOME} RUN chmod =2775 ${PIPELINE_ROOT} \ && chmod =2775 ${APP_HOME} \ - && mv de440.bsp ${PIPELINE_PATH}/de440.bsp \ - && mv naif0012.tls ${PIPELINE_PATH}/naif0012.tls + && mv de440.bsp ${PIPELINE_PATH}/$BSP_PLANETARY_NAME \ + && mv naif0012.tls ${PIPELINE_PATH}/$LEAP_SECOND_NAME WORKDIR ${APP_HOME} USER apptno +# RUN /bin/bash --login -c "conda init bash \ +# && echo 'conda activate py3' >> ~/.bashrc \ +# && source ~/.bashrc" RUN /bin/bash --login -c "conda init bash \ - && echo 'conda activate py3' >> ~/.bashrc \ + && echo 'source /app/src/env.sh' >> ~/.bashrc \ && source ~/.bashrc" ENV PATH=${PATH}:/home/apptno/.local/bin +# USER ${USERNAME} +# RUN /bin/bash --login -c "conda init bash \ +# && echo 'conda activate py3' >> ~/.bashrc \ +# && source ~/.bashrc" USER ${USERNAME} RUN /bin/bash --login -c "conda init bash \ - && echo 'conda activate py3' >> ~/.bashrc \ + && echo 'source /app/src/env.sh' >> ~/.bashrc \ && source ~/.bashrc" ENV PATH=${PATH}:/home/${USERNAME}/.local/bin diff --git a/predict_occultation/entrypoint.sh b/predict_occultation/entrypoint.sh index 6b634fd99..29a641987 100755 --- a/predict_occultation/entrypoint.sh +++ b/predict_occultation/entrypoint.sh @@ -3,4 +3,35 @@ echo "Running Rsync: ${PIPELINE_PREDIC_OCC}" rsync -r /app/src/predict_occultation/ ${PIPELINE_PREDIC_OCC}/ + +# Baixa os arquivos bsp planetary e leap_second caso não existam. +# No build da imagem eles são baixados, mas para os devs, +# Na primeira execução eles serão sobrescritos por isso +# Essa checagem adicional. +bsp_planetary="${PIPELINE_PATH}/$BSP_PLANETARY_NAME" +if [ ! -f $bsp_planetary ]; +then + echo "BSP Planetary $BSP_PLANETARY_NAME does not exist in the pipeline path."; + echo "Downloading $BSP_PLANETARY_NAME."; + wget --no-verbose --show-progress \ + --progress=bar:force:noscroll \ + https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/$BSP_PLANETARY_NAME \ + -O $bsp_planetary + echo "BSP Planetary Downloaded to: $bsp_planetary" +fi + +leap_second="${PIPELINE_PATH}/$LEAP_SECOND_NAME" +if [ ! -f $leap_second ]; +then + echo "Leap Second $LEAP_SECOND_NAME does not exist in the pipeline path."; + echo "Downloading $LEAP_SECOND_NAME."; + wget --no-verbose --show-progress \ + --progress=bar:force:noscroll \ + https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/$LEAP_SECOND_NAME \ + -O $leap_second + echo "Leap Second Downloaded to: $leap_second" +fi + +echo "Enviroment ${PARSL_ENV} is ready!" + exec "$@" diff --git a/predict_occultation/src/env.sh b/predict_occultation/src/env.sh index 13d01d047..93f5807da 100755 --- a/predict_occultation/src/env.sh +++ b/predict_occultation/src/env.sh @@ -3,6 +3,7 @@ echo "Activating py3 environment" conda activate py3 +echo "Setup PYTHONPATH" export PYTHONPATH=${PYTHONPATH}:${PIPELINE_ROOT}:${PIPELINE_PREDIC_OCC}:${PIPELINE_PATH} if [[ "$PARSL_ENV" = "linea" ]] diff --git a/predict_occultation/src/rerun.sh b/predict_occultation/src/rerun.sh index 5d7543469..00ffe7fd0 100755 --- a/predict_occultation/src/rerun.sh +++ b/predict_occultation/src/rerun.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash --login set -o errexit set -o pipefail