Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update Dockerfile for IFTPipeline.jl #174

Open
wants to merge 45 commits into
base: jghrefactor/A-gather-julia-package-in-new-directory
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3797150
move cli file to src directory
hollandjg Oct 25, 2024
bd4ea2a
update dockerfile to use the new path to CLI file
hollandjg Oct 25, 2024
5c299cf
re-add shell
hollandjg Oct 25, 2024
72d9835
quote variables in entrypoint
hollandjg Oct 25, 2024
ce51c79
reorder dockerfile to reduce time taken to rerun
hollandjg Oct 25, 2024
529bb5b
update comments
hollandjg Oct 25, 2024
597a143
update dockerfile
hollandjg Oct 25, 2024
202f51b
broken setup of Dockerfile – libcurl doesn't work when loading pycall…
hollandjg Oct 25, 2024
c892048
add missing serialization dependency
hollandjg Oct 25, 2024
c8e316c
update dockerfile to include installing conda from an environment file
hollandjg Oct 25, 2024
3b4d7e4
move sample tracker params into test directory
hollandjg Oct 26, 2024
4ca166e
fix crash on testing when we're not running cli.jl directly
hollandjg Oct 26, 2024
d8a6afd
move cli-config code into cli
hollandjg Oct 26, 2024
db2f3d3
remove commented code in dockerfile
hollandjg Oct 26, 2024
43f4187
make a setup-python script which handles setting up the python enviro…
hollandjg Oct 26, 2024
998a1d4
remove extra newline
hollandjg Oct 26, 2024
5201494
Revert "make a setup-python script which handles setting up the pytho…
hollandjg Oct 26, 2024
7954d0e
add entrypoint to go straight to IFT
hollandjg Oct 26, 2024
c76c250
simplify the python setup using an additional little package
hollandjg Oct 26, 2024
5dea3b9
update dockerfile to test the package in a separate step
hollandjg Oct 26, 2024
b616969
remove extra ARGS variable not working in Docker
hollandjg Oct 26, 2024
9f46fdb
fix julia call at Entrypoign
hollandjg Oct 26, 2024
da9da46
delete unneeded requirements.txt
hollandjg Oct 26, 2024
541b802
fix passing arguments directly to entrypoint
hollandjg Oct 26, 2024
9f0b18d
remove variables which don't always work
hollandjg Oct 26, 2024
f08a755
remove additional installs, not required for tests to pass
hollandjg Oct 26, 2024
4c634e7
remove updates – just go straight to the base image for reproducible …
hollandjg Oct 26, 2024
5259d4b
update testing script to set up python correctly
hollandjg Oct 26, 2024
a6f7ec1
switch soit to running under pipx
hollandjg Oct 26, 2024
974817e
remove some unneeded dependencies from the Python environment
hollandjg Oct 26, 2024
0dc490c
add missing line-end
hollandjg Oct 28, 2024
4c31827
add missing newline
hollandjg Oct 28, 2024
87d31ee
Merge branch 'jghrefactor/A-gather-julia-package-in-new-directory' in…
hollandjg Oct 28, 2024
cd53c53
Merge branch 'jghrefactor/A-gather-julia-package-in-new-directory' in…
hollandjg Oct 28, 2024
2393717
Merge branch 'jghrefactor/A1-update-dockerfile' of https://github.com…
hollandjg Oct 28, 2024
7b4e7f1
Merge branch 'jghrefactor/A-gather-julia-package-in-new-directory' in…
hollandjg Oct 29, 2024
4879887
back-out changes made to soit
hollandjg Oct 29, 2024
2311c74
Merge branch 'jghrefactor/A1-update-dockerfile' of https://github.com…
hollandjg Oct 29, 2024
5298c69
add missing import
hollandjg Oct 29, 2024
c3b9790
back-out removal of requirements.txt (moved to new PR)
hollandjg Oct 29, 2024
c8b9a59
Merge branch 'jghrefactor/D-update-conda-environment-setup' into jghr…
hollandjg Oct 30, 2024
504eea4
remove duplicate python setup package
hollandjg Oct 30, 2024
b0542f8
use updated python setup package name in docker and workflows
hollandjg Oct 30, 2024
c3636cb
add IFT from main branch rather than from registry for Docker build
tdivoll Nov 6, 2024
5d69bc0
Merge branch 'jghrefactor/A-gather-julia-package-in-new-directory' in…
hollandjg Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,18 @@ jobs:
arch: x64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: update pip
run: python -m pip install -U pip
- name: install python deps
run: python -m pip install -U -r requirements.txt
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v2
- run: julia --project=PythonSetupForIFTPipeline.jl PythonSetupForIFTPipeline.jl/setup.jl
- uses: julia-actions/julia-buildpkg@v1
with:
project: IFTPipeline.jl
env:
PYTHON: python
- uses: julia-actions/julia-runtest@v1
with:
project: IFTPipeline.jl
env:
PYTHON: python
- uses: julia-actions/julia-processcoverage@v1
with:
directories: IFTPipeline.jl/src
Expand Down
38 changes: 17 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
FROM julia:1.9-bookworm
ENV TERM=xterm
ENV JULIA_PROJECT=/opt/ice-floe-tracker-pipeline
ENV JULIA_DEPOT_PATH=/opt/julia
ENV JULIA_PKGDIR=/opt/julia
ENV JULIA_BUILD='ENV["PYTHON"]=""; using Pkg; Pkg.build()'
ENV IFTPIPELINE_REPO='https://github.com/WilhelmusLab/ice-floe-tracker-pipeline.git'
ENV LOCAL_PATH_TO_IFT_CLI='/usr/local/bin/ice-floe-tracker.jl'

WORKDIR /opt
FROM julia:1.11-bookworm

# DEPENDENCIES
#===========================================
RUN apt-get -y update && \
apt-get install -y git python3.10 && \
rm -rf /var/lib/apt/list/*
ENV TERM=xterm

# Julia package build
# Python environment build
#===========================================
COPY ./PythonSetupForIFTPipeline.jl /opt/PythonSetupForIFTPipeline.jl
RUN julia --project="/opt/PythonSetupForIFTPipeline.jl" "/opt/PythonSetupForIFTPipeline.jl/setup.jl"

RUN git clone --single-branch --branch main --depth 1 ${IFTPIPELINE_REPO}
RUN /usr/local/julia/bin/julia --project=${JULIA_PROJECT} -e ${JULIA_BUILD}
RUN /usr/local/julia/bin/julia --project=${JULIA_PROJECT} -e 'using Pkg; Pkg.instantiate()'
COPY workflow/scripts/ice-floe-tracker.jl ${LOCAL_PATH_TO_IFT_CLI}
RUN chmod a+x ${LOCAL_PATH_TO_IFT_CLI}
ENV JULIA_DEPOT_PATH="/usr/local/bin/julia:$JULIA_DEPOT_PATH"
CMD [ "/bin/bash", "-c" ]
# IFT Pipeline package build
#===========================================
COPY ./IFTPipeline.jl /opt/IFTPipeline.jl
RUN julia --project="/opt/IFTPipeline.jl" -e 'using Pkg; Pkg.rm("IceFloeTracker"); Pkg.add(url="https://github.com/WilhelmusLab/IceFloeTracker.jl", rev="main"); Pkg.instantiate()'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to confirm that line 15 indeed gives us python 3.11 and IFT 0.60:
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hollandjg take another look at this.

# Test the package
RUN julia --project="/opt/IFTPipeline.jl" -e 'using Pkg; Pkg.test();'

# CLI setup
#===========================================
SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["julia", "--project=/opt/IFTPipeline.jl", "/opt/IFTPipeline.jl/src/cli.jl" ]
1 change: 1 addition & 0 deletions IFTPipeline.jl/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

[compat]
Expand Down
2 changes: 1 addition & 1 deletion IFTPipeline.jl/src/IFTPipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using Folds
using HDF5
using TOML: parsefile
using Pkg
include("cli-config.jl")
include("cli.jl")
include("soit-parser.jl")
include("landmask.jl")
include("preprocess.jl")
Expand Down
93 changes: 93 additions & 0 deletions IFTPipeline.jl/src/cli-config.jl → IFTPipeline.jl/src/cli.jl
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!/usr/bin/env julia

using ArgParse
using LoggingExtras
using IceFloeTracker
using IFTPipeline
using Serialization

function mkclipreprocess!(settings)
@add_arg_table! settings["preprocess"] begin
"--truedir", "-t"
Expand Down Expand Up @@ -218,3 +226,88 @@ function mkcli!(settings, common_args)
end
return nothing
end


"""
setuplogger(option::Int64, path::String)

Setup logger for the ice floe tracker. If `option` is 0, log to file only. If `option` is 1, log to file and terminal.
"""
function setuplogger(option::Int64, command::Symbol)
output = joinpath(@__DIR__, "..", "report")
cmd = string(command)

filelogger = FileLogger(joinpath(output, "$cmd-logfile.log")) # add command prefix to logfile name

# filter out debug messages
filtlogger = EarlyFilteredLogger(filelogger) do args
r = Logging.Info <= args.level <= Logging.Warn && args._module === IFTPipeline
return r
end

if option == 0
return TeeLogger(filtlogger,
)
elseif option == 1
return TeeLogger(
global_logger(),
filtlogger
)
end
end

function main()

settings = ArgParseSettings(; autofix_names=true)

@add_arg_table! settings begin
"landmask"
help = "Generate land mask images"
action = :command

"preprocess"
help = "Preprocess truecolor/falsecolor images"
action = :command

"extractfeatures"
help = "Extract ice floe features from segmented floe image"
action = :command

"makeh5files"
help = "Make HDF5 files from extracted floe features"
action = :command

"track"
help = "Pair ice floes in day k with ice floes in day k+1"
action = :command
end

command_common_args = [
"--log",
Dict(:help => "Show log on terminal; either 1 or 0", :required => false, :arg_type => Int,
:default => 0, :range_tester => (x -> x == 0 || x == 1)
)]

mkcli!(settings, command_common_args)

parsed_args = parse_args(settings; as_symbols=true)

command = parsed_args[:_COMMAND_]
command_args = parsed_args[command]
command_func = getfield(IFTPipeline, Symbol(command))
logoption = command_args[:log]

# delete log option from command_args so it doesn't get passed to command_func
delete!(command_args, :log)

logger = setuplogger(logoption, command)

with_logger(logger) do
@time command_func(; command_args...)
end
return nothing
end

if abspath(PROGRAM_FILE) == @__FILE__
main()
end
90 changes: 0 additions & 90 deletions workflow/scripts/ice-floe-tracker.jl

This file was deleted.

Loading