Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Adds more instructions for using and running docker #210

Merged
merged 1 commit into from
Oct 14, 2022
Merged
Changes from all commits
Commits
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
31 changes: 23 additions & 8 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ Under `model_examples` you'll find a how you could apply Hamilton to model your
Check it out to get a sense for how Hamilton could make your ML pipelines reusable/general
components...

## Running examples through docker image
Examples could also be executed through the provided docker image.
## Running examples through a docker image
Examples could also be executed through a docker image which you can build or pull yourself.
Each example directory inside docker image contains a `hamilton-env` Python virtual environment.
`hamilton-env` environment contains all the dependencies required to run the example.

NOTE: If you already have the container image you can skip to container creation (step 3)
NOTE: If you already have the container image you can skip to container initialization (step 3).

1. Change directory to `examples`
1. Change directory to `examples`.
```bash
cd hamilton/examples
```
Expand All @@ -39,16 +39,31 @@ cd hamilton/examples
docker build --tag hamilton-example .
```
Docker build takes around `6m16.298s` depending on the system configuration and network.
Alternatively, you can pull the container image from here: ...
Alternatively, you can pull the container image from https://hub.docker.com/r/skrawcz/sf-hamilton.
`docker pull skrawcz/sf-hamilton`.

3. Creating a container
3. Starting the container.
If you built it yourself:
```bash
docker run -it --rm --name hamilton-example hamilton-example
```
If you pulled it from dockerhub:
```bash
docker run -it --rm --name hamilton-example skrawcz/sf-hamilton
```
This will start the container and put you into a bash prompt.

4. Running the `hello_world` example inside the container
4. Start running examples.
E.g. running the `hello_world` example inside the container:
```bash
cd hamilton/examples/hello_world
source hamilton-env/bin/activate
source hamilton-env/bin/activate # this will activate the right python environment
python my_script.py
deactivate # this will deactivate the virtual environment so you can activate another
```
To run another example:
1. change directory to it.
2. activate the environment (`source hamilton-env/bin/activate`).
3. run the code, e.g. `python run.py`.
4. deactivate the environment (`deactivate`).
And then `exit` to quit out of the running docker container.