Skip to content

Commit

Permalink
Merge pull request #2 from UCSD-E4E/github
Browse files Browse the repository at this point in the history
feat: add docker CLI for building docker containers
  • Loading branch information
Sean1572 authored Feb 13, 2025
2 parents 2372bc2 + 8330bb2 commit 169cbb5
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 126 deletions.
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.

0 comments on commit 169cbb5

Please sign in to comment.