File tree 4 files changed +75
-0
lines changed
4 files changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+ FROM python:3.9
2
+
3
+ RUN apt update -y &&\
4
+ apt install git openjdk-11-jdk -y &&\
5
+ git clone https://github.com/bovem/hamilton.git --branch=examples-dockerfile &&\
6
+ cd hamilton/examples &&\
7
+ bash make_python_virtualenv.sh
8
+
9
+ ENTRYPOINT ["/bin/bash" ]
Original file line number Diff line number Diff line change @@ -21,3 +21,34 @@ folders.
21
21
Under ` model_examples ` you'll find a how you could apply Hamilton to model your ML workflow.
22
22
Check it out to get a sense for how Hamilton could make your ML pipelines reusable/general
23
23
components...
24
+
25
+ ## Running examples through docker image
26
+ Examples could also be executed through the provided docker image.
27
+ Each example directory inside docker image contains a ` hamilton-env ` Python virtual environment.
28
+ ` hamilton-env ` environment contains all the dependencies required to run the example.
29
+
30
+ NOTE: If you already have the container image you can skip to container creation (step 3)
31
+
32
+ 1 . Change directory to ` examples `
33
+ ``` bash
34
+ cd hamilton/examples
35
+ ```
36
+
37
+ 2 . Build the container image.
38
+ ``` bash
39
+ docker build --tag hamilton-example .
40
+ ```
41
+ Docker build takes around ` 6m16.298s ` depending on the system configuration and network.
42
+ Alternatively, you can pull the container image from here: ...
43
+
44
+ 3 . Creating a container
45
+ ``` bash
46
+ docker run -it --rm --name hamilton-example hamilton-example
47
+ ```
48
+
49
+ 4 . Running the ` hello_world ` example inside the container
50
+ ``` bash
51
+ cd hamilton/examples/hello_world
52
+ source hamilton-env/bin/activate
53
+ python my_script.py
54
+ ```
Original file line number Diff line number Diff line change 1
1
aiohttp
2
+ async
2
3
fastapi
4
+ sf-hamilton
3
5
uvicorn
Original file line number Diff line number Diff line change
1
+ # This script is used to create separate python virtual environments for individual examples
2
+ # A python virtual environment named "hamilton-env" is created in every directory containing requirements.txt file
3
+
4
+ # USAGE (inside hamilton/examples directory): bash make_python_virtualenv.sh
5
+
6
+ # Get a list of all the folders containing "requirements.txt" file
7
+ export folders=$( find . -name ' requirements.txt' -printf ' %h\n' ) ;
8
+
9
+ echo " List of all folders containing requirements.txt" ;
10
+ echo $folders ;
11
+
12
+ for folder in $folders ; do
13
+ # Change directory
14
+ pushd $folder ;
15
+
16
+ # Remove previous hamilton python virtual environment
17
+ rm -rf ./hamilton-env;
18
+
19
+ # Create a new python virtual environment named "hamilton"
20
+ python3 -m venv hamilton-env;
21
+
22
+ # Change to that virtual environment
23
+ source ./hamilton-env/bin/activate;
24
+
25
+ # Install the requirements listed in hamilton virtual environment
26
+ pip install -r requirements.txt;
27
+
28
+ # Deactivate the virtual environment
29
+ deactivate;
30
+
31
+ # Return to the examples folder
32
+ popd ;
33
+ done
You can’t perform that action at this time.
0 commit comments