diff --git a/SwanCustomEnvironments/swancustomenvironments/scripts/builders/accpy.sh b/SwanCustomEnvironments/swancustomenvironments/scripts/builders/accpy.sh index c7d6b008..459ad1cb 100644 --- a/SwanCustomEnvironments/swancustomenvironments/scripts/builders/accpy.sh +++ b/SwanCustomEnvironments/swancustomenvironments/scripts/builders/accpy.sh @@ -11,4 +11,4 @@ eval "${ACTIVATE_ENV_CMD}" # Install packages in the environment and the same ipykernel that the Jupyter server uses _log "Installing packages from ${REQ_PATH}..." -pip install -r "${REQ_PATH}" "ipykernel==${IPYKERNEL_VERSION}" | tee -a ${LOG_FILE} +pip install -r "${REQ_PATH}" "ipykernel==${IPYKERNEL_VERSION}" ${SPARKCONNECTOR} ${SPARKMONITOR} ${NXCALS} | tee -a ${LOG_FILE} diff --git a/SwanCustomEnvironments/swancustomenvironments/scripts/makenv.sh b/SwanCustomEnvironments/swancustomenvironments/scripts/makenv.sh index 3bb38db1..fa5277c3 100755 --- a/SwanCustomEnvironments/swancustomenvironments/scripts/makenv.sh +++ b/SwanCustomEnvironments/swancustomenvironments/scripts/makenv.sh @@ -42,12 +42,13 @@ define_repo_path() { # Function for printing the help page print_help() { - _log "Usage: makenv --repo REPOSITORY --repo_type TYPE --builder BUILDER --builder_version VERSION [--help/-h]" + _log "Usage: makenv --repo REPOSITORY --repo_type TYPE --builder BUILDER --builder_version VERSION --nxcals [--help/-h]" _log "Options:" _log " --repo REPOSITORY Path or http link for a public repository" _log " --repo_type TYPE Type of repository (git or eos)" _log " --builder BUILDER Builder to create the environment" _log " --builder_version VERSION Version of the builder to use (optional)" + _log " --nxcals Install NXCALS package and Spark extensions in the environment (optional)" _log " -h, --help Print this help page" } @@ -101,6 +102,10 @@ while [ $# -gt 0 ]; do shift shift ;; + --nxcals) + INSTALL_NXCALS=true + shift + ;; --help|-h) print_help exit 0 @@ -177,6 +182,13 @@ ENV_PATH="/home/$USER/${ENV_NAME}" REQ_PATH="${REPO_PATH}/requirements.txt" IPYKERNEL_VERSION=$(python -c "import ipykernel; print(ipykernel.__version__)") +# Libraries need to be installed and not linked, due to their dependencies +if [ -n "${INSTALL_NXCALS}" ]; then + SPARKCONNECTOR="sparkconnector==$(python3 -c 'import sparkconnector; print(sparkconnector.__version__)')" + SPARKMONITOR="sparkmonitor==$(python3 -c 'import sparkmonitor; print(sparkmonitor.__version__)')" + NXCALS="nxcals" +fi + # Check if requirements.txt exists in the repository if [ ! -f "${REQ_PATH}" ]; then _log "ERROR: Requirements file not found (${REQ_PATH})." diff --git a/SwanCustomEnvironments/swancustomenvironments/serverextension.py b/SwanCustomEnvironments/swancustomenvironments/serverextension.py index 716a2f9c..a32b0574 100644 --- a/SwanCustomEnvironments/swancustomenvironments/serverextension.py +++ b/SwanCustomEnvironments/swancustomenvironments/serverextension.py @@ -21,6 +21,7 @@ def get(self): repo_type (str): The type of repository (git or eos). builder (str): The builder used for creating the environment. builder_version (str): The version of the specified builder. + nxcals (bool): Whether to include NXCALS and Spark extensions in the environment. """ self.set_header("Content-Type", "text/event-stream") @@ -28,10 +29,13 @@ def get(self): repo_type = self.get_query_argument("repo_type", default="") builder = self.get_query_argument("builder", default="") builder_version = self.get_query_argument("builder_version", default="") + nxcals = self.get_query_argument("nxcals", default="") arguments = ["--repo", repository, "--repo_type", repo_type, "--builder", builder] if builder_version: arguments.extend(("--builder_version", builder_version)) + if nxcals: + arguments.append("--nxcals") makenv_process = subprocess.Popen([self.makenv_path, *arguments], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) diff --git a/SwanCustomEnvironments/swancustomenvironments/templates/customenvs.html b/SwanCustomEnvironments/swancustomenvironments/templates/customenvs.html index 0f403957..f4a04799 100644 --- a/SwanCustomEnvironments/swancustomenvironments/templates/customenvs.html +++ b/SwanCustomEnvironments/swancustomenvironments/templates/customenvs.html @@ -153,6 +153,7 @@ var builder = urlParams.get('builder') || ""; var builder_version = urlParams.get('builder_version') || ""; var file = `/${urlParams.get('file') || ""}`; + var nxcals = urlParams.get('nxcals') || ""; // Environment creation elements var outputBox = document.getElementById('output-box'); @@ -242,7 +243,7 @@ } - fetch(`${base_url}api/customenvs?repo=${encodeURIComponent(repository)}&repo_type=${encodeURIComponent(repo_type)}&builder=${encodeURIComponent(builder)}&builder_version=${encodeURIComponent(builder_version)}`, { + fetch(`${base_url}api/customenvs?repo=${encodeURIComponent(repository)}&repo_type=${encodeURIComponent(repo_type)}&builder=${encodeURIComponent(builder)}&builder_version=${encodeURIComponent(builder_version)}&nxcals=${encodeURIComponent(nxcals)}`, { method: 'GET', headers: get_jh_auth_header(), })