Skip to content

Commit

Permalink
Thread Julia options through configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Jul 17, 2020
1 parent 23632d7 commit a091696
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions caliban/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ def generate_docker_args(job_mode: conf.JobMode,
docker_args = {
"extra_dirs": args.get("dir"),
"requirements_path": reqs if os.path.exists(reqs) else None,
"julia_url": conf.caliban_config().get("julia_url", None),
"conda_env_path": conda_env if os.path.exists(conda_env) else None,
"caliban_config": conf.caliban_config(),
"credentials_path": creds_path,
Expand Down
3 changes: 2 additions & 1 deletion caliban/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def expand_image(image: str) -> str:
s.Optional("project_id"): s.And(str, len),
s.Optional("cloud_key"): s.And(str, len),
s.Optional("base_image", default=None): BaseImage,
s.Optional("apt_packages", default=AptPackages.validate({})): AptPackages
s.Optional("apt_packages", default=AptPackages.validate({})): AptPackages,
s.Optional("julia_url", default=None): str
})

# Accessors
Expand Down
18 changes: 10 additions & 8 deletions caliban/docker/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import json
import os
import os.path
import subprocess
from enum import Enum
from pathlib import Path
Expand Down Expand Up @@ -247,17 +248,18 @@ def _dependency_entries(workdir: str,
RUN /bin/bash -c "pip install --no-cache-dir -r {requirements_path}"
"""

julia_url = "https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.0-rc1-linux-x86_64.tar.gz"
if julia_url is not None:
# e.g. "https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.0-rc1-linux-x86_64.tar.gz"
ret += f"""
if os.path.exists("Project.toml"):
ret += f"""
COPY --chown={user_id}:{user_group} *.toml {workdir}/
"""
# TODO: Use /usr/local instead of /tmp for Julia directories
ret += f"""
COPY --chown={user_id}:{user_group} src {workdir}/src
# TODO: Use /usr/local instead of /tmp
ENV JULIA_LOC /tmp/julia
ENV JULIA_DEPOT_PATH /tmp/var/julia_depot
ENV JULIA_PROJECT {workdir}
ENV PATH $PATH:$JULIA_LOC/bin
ENV JULIA_LOC=/tmp/julia
ENV JULIA_DEPOT_PATH=/tmp/var/julia_depot
ENV JULIA_PROJECT={workdir}
ENV PATH=$PATH:$JULIA_LOC/bin
RUN /bin/bash -c "mkdir -p $JULIA_LOC && \
wget -nv {julia_url} && \
tar xzf $(basename {julia_url}) -C $JULIA_LOC --strip-components 1 && \
Expand Down

0 comments on commit a091696

Please sign in to comment.