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

6 Local Training #9

Merged
merged 45 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
eba3160
Create Dockerfile and trainer.sh
Oct 5, 2020
6c29fbd
Install dependencies and execute a specified project
Oct 5, 2020
783a5b6
Modify trainer.sh to take ENV variable from docker environment
Oct 5, 2020
0746a59
Change base docker image from python3.8:buster to ubuntu:20.04
Oct 5, 2020
cd5f5d6
Implement local execution option
Oct 5, 2020
3ef357c
Add print Python 3.5 compatability
Oct 5, 2020
f11b878
Change project name locating to model path
Oct 6, 2020
ce61092
Fix not finding script location issue with relative path
Oct 6, 2020
93cf6f5
Design CLI tool to run in github repo
Oct 6, 2020
f3d618e
Fix git dependency fail
Oct 6, 2020
e28cee2
Adjust remote cloning based on commit sha
Oct 6, 2020
a8a385f
Log docker output into logs/docker folder in a time stamped log file
Oct 7, 2020
a3ddcd1
Allow user to define custom branch
Oct 7, 2020
f8779d7
Add fast local run time option and refactor out github repo checks
Oct 7, 2020
8d4120a
Modify path to store logs
Oct 7, 2020
275d14f
Remove branch sepecific clone for now
Oct 7, 2020
594134a
Add conda environment.yml dependency install support
Oct 7, 2020
a27a707
Add click argument for option of training script
Oct 8, 2020
efaadb6
Modify Github Token checking to test equality with None
Oct 8, 2020
7fb9fe3
Fix wrong variable name
Oct 8, 2020
66ada80
Fix docker build image issue (not building in hydra package folder
Oct 8, 2020
400792c
Add explanation to script
Oct 8, 2020
a145c91
Report exception for non-implemented parts
Oct 8, 2020
e680d85
Add tests for utility functions
Oct 8, 2020
5493b0a
Refactor json to string
Oct 8, 2020
671bb50
Use gitpython to get branch name, refactoring
Oct 8, 2020
b1194ed
Fix minor extra arg issue
Oct 8, 2020
72cb1ac
Refactor git check code for easier testing
Oct 8, 2020
0dbda0c
Add tests for github functions
Oct 8, 2020
7578468
Add test for CLI
Oct 9, 2020
fb93254
Update requirement
Oct 9, 2020
e1057a9
Check coverage percentage
Oct 9, 2020
937c6fa
Add tests for GitRepo class
Oct 9, 2020
cb871e2
Refactor GitRepo class into its single file
Oct 9, 2020
d2308ca
Refactor out running procedures into classes
Oct 9, 2020
a85e221
Add local platform training procedure
Oct 9, 2020
7adb47e
Add Google Cloud class basic outline
Oct 9, 2020
071be9d
Order dict items for python 3.5 compat to avoid flaky tests
Oct 10, 2020
64820af
Minor name change
Oct 10, 2020
b74e4cd
Fix OrderDict import
Oct 10, 2020
81f6fd2
Add test coverage to github workflow
Oct 13, 2020
05d5397
Add help for option flag
Oct 13, 2020
6270069
Revert breaking change to workflow
Oct 13, 2020
6cb8fa2
Workflow add test coverage
Oct 13, 2020
6489642
Add dependency in github workflow
Oct 13, 2020
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: 12 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu:20.04

RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y git

RUN apt-get install python3-pip -y

ADD executor.sh /home
WORKDIR /home

ENTRYPOINT ["sh", "executor.sh"]
12 changes: 12 additions & 0 deletions docker/executor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

echo "Github Repo URL: $GIT_URL"

mkdir project
cd project

git clone -b test-samples https://$OAUTH_TOKEN:x-oauth-basic@$GIT_URL .

tsa87 marked this conversation as resolved.
Show resolved Hide resolved
cd $PROJECT_NAME
pip3 install -r requirements.txt
python3 train.py
8 changes: 8 additions & 0 deletions docker/local_execution.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
docker build -t hydra_image .

docker run \
-e GIT_URL=github.com/georgianpartners/hydra-ml-projects \
-e PROJECT_NAME=$1 \
-e OAUTH_TOKEN=$2 \
hydra_image:latest
19 changes: 12 additions & 7 deletions hydra/cli.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import click
import subprocess
from hydra.version import __version__


@click.group()
@click.version_option(__version__)
def cli():
pass


@cli.command()
@click.option('--project_name')
@click.option('--model_name')
@click.option('--cpu')
@click.option('--memory')
@click.option('--options')
def train(project_name, model_name, cpu, memory, options):
@click.option('-p', '--project_name', required=True, type=str)
tsa87 marked this conversation as resolved.
Show resolved Hide resolved
@click.option('-c', '--cpu', default=16, type=click.IntRange(0, 128), help='Number of CPU cores required')
@click.option('-r', '--memory', default=8, type=click.IntRange(0, 128), help='GB of RAM required')
@click.option('--cloud', default='local', type=click.Choice(['local', 'aws', 'gcp', 'azure'], case_sensitive=False))
@click.option('--github_token', envvar='GITHUB_TOKEN') # Takes either an option or environment var

tsa87 marked this conversation as resolved.
Show resolved Hide resolved
def train(project_name, cpu, memory, github_token, cloud):
click.echo("This is the training command")
click.echo("Running on {}.".format(cloud))

if cloud == 'local':
subprocess.run(['sh', 'docker/local_execution.sh', project_name, github_token])
tsa87 marked this conversation as resolved.
Show resolved Hide resolved