forked from flyteorg/flyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace raw containers example (flyteorg#492)
* Replace raw containers example Signed-off-by: Eduardo Apolinario <[email protected]> * rename workflow file to raw_container.py Signed-off-by: Eduardo Apolinario <[email protected]> * Remove unnecessary files Signed-off-by: Eduardo Apolinario <[email protected]> * Add makefile Signed-off-by: Eduardo Apolinario <[email protected]> * Add panel Signed-off-by: Eduardo Apolinario <[email protected]> * Test literalinclude outside panel Signed-off-by: Eduardo Apolinario <[email protected]> * Fix path Signed-off-by: Eduardo Apolinario <[email protected]> * Fix typo Signed-off-by: Eduardo Apolinario <[email protected]> * Pass a different path to literalinclude Signed-off-by: Eduardo Apolinario <[email protected]> * Add caveats section and fix references to each panel. Signed-off-by: Eduardo Apolinario <[email protected]> * Remove extraneous literalinclude Signed-off-by: Eduardo Apolinario <[email protected]> * Review feedback Signed-off-by: Eduardo Apolinario <[email protected]> * De-indent literalinclude Signed-off-by: Eduardo Apolinario <[email protected]> * Lint - black Signed-off-by: Eduardo Apolinario <[email protected]> Co-authored-by: Eduardo Apolinario <[email protected]>
- Loading branch information
1 parent
6874282
commit ba07e51
Showing
14 changed files
with
300 additions
and
36 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
cookbook/core/containerization/raw-containers-supporting-files/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.PHONY: build_images | ||
build_images: | ||
ls per-language | xargs -n 1 -I {} docker build ./per-language/{} -f ./per-language/{}/Dockerfile --tag "rawcontainers-{}:v1" |
3 changes: 3 additions & 0 deletions
3
cookbook/core/containerization/raw-containers-supporting-files/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# raw-containers-demo | ||
|
||
This directory holds the Dockerfiles and supporting files needed to run the example described in `raw_container.py`, split by language. |
7 changes: 7 additions & 0 deletions
7
...ook/core/containerization/raw-containers-supporting-files/per-language/haskell/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM haskell:9 | ||
|
||
WORKDIR /root | ||
|
||
COPY calculate-ellipse-area.hs /root | ||
|
||
RUN ghc calculate-ellipse-area.hs |
21 changes: 21 additions & 0 deletions
21
...nerization/raw-containers-supporting-files/per-language/haskell/calculate-ellipse-area.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import System.IO | ||
import System.Environment | ||
import Text.Read | ||
import Text.Printf | ||
|
||
calculateEllipseArea :: Float -> Float -> Float | ||
calculateEllipseArea a b = pi * a * b | ||
|
||
main = do | ||
args <- getArgs | ||
let input_a = args!!0 ++ "/a" | ||
input_b = args!!0 ++ "/b" | ||
a <- readFile input_a | ||
b <- readFile input_b | ||
|
||
let area = calculateEllipseArea (read a::Float) (read b::Float) | ||
|
||
let output_area = args!!1 ++ "/area" | ||
output_metadata = args!!1 ++ "/metadata" | ||
writeFile output_area (show area) | ||
writeFile output_metadata "[from haskell rawcontainer]" |
5 changes: 5 additions & 0 deletions
5
cookbook/core/containerization/raw-containers-supporting-files/per-language/julia/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM julia:1.6.4-buster | ||
|
||
WORKDIR /root | ||
|
||
COPY calculate-ellipse-area.jl /root |
36 changes: 36 additions & 0 deletions
36
...ainerization/raw-containers-supporting-files/per-language/julia/calculate-ellipse-area.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
using Printf | ||
|
||
function calculate_area(a, b) | ||
π * a * b | ||
end | ||
|
||
function read_input(input_dir, v) | ||
open(@sprintf "%s/%s" input_dir v) do file | ||
parse.(Float64, read(file, String)) | ||
end | ||
end | ||
|
||
function write_output(output_dir, output_file, v) | ||
output_path = @sprintf "%s/%s" output_dir output_file | ||
open(output_path, "w") do file | ||
write(file, string(v)) | ||
end | ||
end | ||
|
||
function main(input_dir, output_dir) | ||
a = read_input(input_dir, 'a') | ||
b = read_input(input_dir, 'b') | ||
|
||
area = calculate_area(a, b) | ||
|
||
write_output(output_dir, "area", area) | ||
write_output(output_dir, "metadata", "[from julia rawcontainer]") | ||
end | ||
|
||
# the keyword ARGS is a special value that contains the command-line arguments | ||
# julia arrays are 1-indexed | ||
input_dir = ARGS[1] | ||
output_dir = ARGS[2] | ||
|
||
main(input_dir, output_dir) |
5 changes: 5 additions & 0 deletions
5
...book/core/containerization/raw-containers-supporting-files/per-language/python/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM python:3.10-slim-buster | ||
|
||
WORKDIR /root | ||
|
||
COPY *.py /root/ |
30 changes: 30 additions & 0 deletions
30
...inerization/raw-containers-supporting-files/per-language/python/calculate-ellipse-area.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import math | ||
import sys | ||
|
||
def read_input(input_dir, v): | ||
with open(f'{input_dir}/{v}', 'r') as f: | ||
return float(f.read()) | ||
|
||
def write_output(output_dir, output_file, v): | ||
with open(f'{output_dir}/{output_file}', 'w') as f: | ||
f.write(str(v)) | ||
|
||
def calculate_area(a, b): | ||
return math.pi * a * b | ||
|
||
|
||
def main(input_dir, output_dir): | ||
a = read_input(input_dir, 'a') | ||
b = read_input(input_dir, 'b') | ||
|
||
area = calculate_area(a, b) | ||
|
||
write_output(output_dir, 'area', area) | ||
write_output(output_dir, 'metadata', '[from python rawcontainer]') | ||
|
||
|
||
if __name__ == '__main__': | ||
input_dir = sys.argv[1] | ||
output_dir = sys.argv[2] | ||
|
||
main(input_dir, output_dir) |
10 changes: 10 additions & 0 deletions
10
cookbook/core/containerization/raw-containers-supporting-files/per-language/r/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM r-base | ||
|
||
WORKDIR /root | ||
|
||
COPY *.R /root/ | ||
|
||
# Not sure whether this a horrible hack. I couldn't | ||
# find a better way to install a package via command | ||
# line | ||
RUN Rscript --save install-readr.R |
15 changes: 15 additions & 0 deletions
15
.../containerization/raw-containers-supporting-files/per-language/r/calculate-ellipse-area.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
library(readr) | ||
|
||
args = commandArgs(trailingOnly=TRUE) | ||
|
||
input_dir = args[1] | ||
output_dir = args[2] | ||
|
||
a = read_lines(sprintf("%s/%s", input_dir, 'a')) | ||
b = read_lines(sprintf("%s/%s", input_dir, 'b')) | ||
|
||
area <- pi * as.double(a) * as.double(b) | ||
print(area) | ||
|
||
writeLines(as.character(area), sprintf("%s/%s", output_dir, 'area')) | ||
writeLines("[from R rawcontainer]", sprintf("%s/%s", output_dir, 'metadata')) |
1 change: 1 addition & 0 deletions
1
...book/core/containerization/raw-containers-supporting-files/per-language/r/install-readr.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
install.packages("readr") |
6 changes: 6 additions & 0 deletions
6
cookbook/core/containerization/raw-containers-supporting-files/per-language/shell/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM alpine | ||
|
||
WORKDIR /root | ||
|
||
COPY calculate-ellipse-area.sh /root | ||
RUN chmod +x /root/calculate-ellipse-area.sh |
8 changes: 8 additions & 0 deletions
8
...ainerization/raw-containers-supporting-files/per-language/shell/calculate-ellipse-area.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#! /usr/bin/env sh | ||
|
||
a=$(cat $1/a) | ||
b=$(cat $1/b) | ||
|
||
echo "4*a(1) * $a * $b" | bc -l | tee $2/area | ||
|
||
echo "[from shell rawcontainer]" | tee $2/metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters