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

feat: add docker CLI for building docker containers #2

Merged
merged 14 commits into from
Feb 13, 2025
Merged
46 changes: 46 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Docker Image CI

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
build:
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build prod and push
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
tags: ghcr.io/ucsd-e4e/maestro_trainer:main
push: true
cache-from: type=registry,ref=ghcr.io/ucsd-e4e/maestro_trainer:main_cache
cache-to: type=registry,ref=ghcr.io/ucsd-e4e/maestro_trainer:main_cache,mode=max
-
name: Build prod and push
if: github.ref != 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
tags: ghcr.io/ucsd-e4e/maestro_trainer:${{ github.head_ref }}
push: true
cache-from: type=registry,ref=ghcr.io/ucsd-e4e/maestro_trainer:${{ github.head_ref }}_cache
cache-to: type=registry,ref=ghcr.io/ucsd-e4e/maestro_trainer:${{ github.head_ref }}_cache,mode=max
2 changes: 1 addition & 1 deletion model_trainer/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ WORKDIR /app
ADD . /app
RUN ls -la .

ENTRYPOINT ["python", "src/model_trainer.py"]
ENTRYPOINT ["python", "model_trainer/src/model_trainer.py"]
# CMD ["python", "src/model_trainer.py"]
#
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# model_trainer

An example trainer for maestro active learning system
93 changes: 0 additions & 93 deletions model_trainer/README.md

This file was deleted.

64 changes: 32 additions & 32 deletions model_trainer/src/model_trainer.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@

import os
import socketio
import time
from model import Trainer
# import socketio
# import time
# from model import Trainer

print(os.environ)
print("RUNNING PYTHON!!!", flush=True)




pod_name = os.environ['pod-name']
sio = socketio.Client()
# pod_name = os.environ['pod-name']
# sio = socketio.Client()

@sio.event
def connect():
print('connection established', flush=True)
sio.emit('job_ready', {'pod-name': pod_name})
# @sio.event
# def connect():
# print('connection established', flush=True)
# sio.emit('job_ready', {'pod-name': pod_name})

@sio.on('start_job')
def trigger_test(data):
print("importing in model")
start = time.time()
print(data, flush=True)
# Expect batch to be a list of directory of file and label
batch = data["batch"]
cfg = data["cfg"]
trainer = Trainer(cfg, batch)
trainer.build()
loss = trainer.train()
# @sio.on('start_job')
# def trigger_test(data):
# print("importing in model")
# start = time.time()
# print(data, flush=True)
# # Expect batch to be a list of directory of file and label
# batch = data["batch"]
# cfg = data["cfg"]
# trainer = Trainer(cfg, batch)
# trainer.build()
# loss = trainer.train()

end = time.time()
print("Job Done", loss, "time", end - start, flush=True)
sio.emit('job_done', {'loss': loss, "pod-name": pod_name}, callback=sio.disconnect)
# end = time.time()
# print("Job Done", loss, "time", end - start, flush=True)
# sio.emit('job_done', {'loss': loss, "pod-name": pod_name}, callback=sio.disconnect)

@sio.event
def my_message(data):
print('message received with ', data, flush=True)
sio.emit('my response', {'response': 'my response'})
# @sio.event
# def my_message(data):
# print('message received with ', data, flush=True)
# sio.emit('my response', {'response': 'my response'})

@sio.event
def disconnect():
print('disconnected from server', flush=True)
# @sio.event
# def disconnect():
# print('disconnected from server', flush=True)

sio.connect('https://test-service2.nrp-nautilus.io')
sio.wait()
# sio.connect('https://test-service2.nrp-nautilus.io')
# sio.wait()



File renamed without changes.
File renamed without changes.
File renamed without changes.