From 891888830d2c8a8d70c05ba32b9f384fdf556d3d Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Sun, 9 Feb 2025 12:49:18 -0800 Subject: [PATCH 01/13] feat: add docker CLI for building docker containers --- .github/docker-image.yml | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/docker-image.yml diff --git a/.github/docker-image.yml b/.github/docker-image.yml new file mode 100644 index 0000000..aa28d8f --- /dev/null +++ b/.github/docker-image.yml @@ -0,0 +1,44 @@ +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:latest + push: true + - + 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.sha }} + push: true \ No newline at end of file From c42998f62152e7ac704448a9c161fa4023a72c1b Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Sun, 9 Feb 2025 12:52:43 -0800 Subject: [PATCH 02/13] fix: formatting --- .github/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/docker-image.yml b/.github/docker-image.yml index aa28d8f..db89bee 100644 --- a/.github/docker-image.yml +++ b/.github/docker-image.yml @@ -2,9 +2,9 @@ name: Docker Image CI on: push: - branches: [ "main" ] + branches: [ main ] pull_request: - branches: [ "main" ] + branches: [ main ] jobs: build: From 9caed8668fe9fcd08346c2e1afc0322e48476621 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Sun, 9 Feb 2025 12:53:38 -0800 Subject: [PATCH 03/13] fix: formatting again --- .github/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/docker-image.yml b/.github/docker-image.yml index db89bee..4589747 100644 --- a/.github/docker-image.yml +++ b/.github/docker-image.yml @@ -2,9 +2,9 @@ name: Docker Image CI on: push: - branches: [ main ] + branches: main pull_request: - branches: [ main ] + branches: main jobs: build: From 8ec4e6cf677909c432df46dba82643f35d9d80b8 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Sun, 9 Feb 2025 12:55:31 -0800 Subject: [PATCH 04/13] fix: file path --- .github/{ => workflows}/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/{ => workflows}/docker-image.yml (95%) diff --git a/.github/docker-image.yml b/.github/workflows/docker-image.yml similarity index 95% rename from .github/docker-image.yml rename to .github/workflows/docker-image.yml index 4589747..98cc4a0 100644 --- a/.github/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,9 +2,9 @@ name: Docker Image CI on: push: - branches: main + branches: ["main"] pull_request: - branches: main + branches: ["main"] jobs: build: From 0e6ebac7999dc14e5af368a61f0f3408ca5ea94f Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Sun, 9 Feb 2025 12:56:25 -0800 Subject: [PATCH 05/13] fix: formatting for tags --- .github/workflows/docker-image.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 98cc4a0..392f629 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -29,8 +29,7 @@ jobs: with: context: . file: Dockerfile - tags: - - ghcr.io/ucsd-e4e/maestro_trainer:latest + tags: ghcr.io/ucsd-e4e/maestro_trainer:latest push: true - name: Build prod and push @@ -39,6 +38,5 @@ jobs: with: context: . file: Dockerfile - tags: - - ghcr.io/ucsd-e4e/maestro_trainer:${{ github.sha }} + tags: ghcr.io/ucsd-e4e/maestro_trainer:${{ github.sha }} push: true \ No newline at end of file From 675063127e1a07384959d2696bdb5088d18ca2dd Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Sun, 9 Feb 2025 12:59:14 -0800 Subject: [PATCH 06/13] fix: path issue for dockerfile and others --- model_trainer/Dockerfile => Dockerfile | 2 +- model_trainer/README.md => README.md | 0 model_trainer/poetry.lock => poetry.lock | 0 model_trainer/pyproject.toml => pyproject.toml | 0 model_trainer/startup.sh => startup.sh | 0 5 files changed, 1 insertion(+), 1 deletion(-) rename model_trainer/Dockerfile => Dockerfile (86%) rename model_trainer/README.md => README.md (100%) rename model_trainer/poetry.lock => poetry.lock (100%) rename model_trainer/pyproject.toml => pyproject.toml (100%) rename model_trainer/startup.sh => startup.sh (100%) diff --git a/model_trainer/Dockerfile b/Dockerfile similarity index 86% rename from model_trainer/Dockerfile rename to Dockerfile index 3cc6a74..65b765a 100644 --- a/model_trainer/Dockerfile +++ b/Dockerfile @@ -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"] # \ No newline at end of file diff --git a/model_trainer/README.md b/README.md similarity index 100% rename from model_trainer/README.md rename to README.md diff --git a/model_trainer/poetry.lock b/poetry.lock similarity index 100% rename from model_trainer/poetry.lock rename to poetry.lock diff --git a/model_trainer/pyproject.toml b/pyproject.toml similarity index 100% rename from model_trainer/pyproject.toml rename to pyproject.toml diff --git a/model_trainer/startup.sh b/startup.sh similarity index 100% rename from model_trainer/startup.sh rename to startup.sh From 95bacab1d465113c4b20810a6391099406d3d273 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Sun, 9 Feb 2025 13:05:09 -0800 Subject: [PATCH 07/13] feat: swap to branch name to make things easier --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 392f629..4f67868 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -38,5 +38,5 @@ jobs: with: context: . file: Dockerfile - tags: ghcr.io/ucsd-e4e/maestro_trainer:${{ github.sha }} + tags: ghcr.io/ucsd-e4e/maestro_trainer:${{ github.head_ref }} push: true \ No newline at end of file From 2e60e9783af1854a42154adf9db5a34c37aed4f6 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Sun, 9 Feb 2025 13:09:20 -0800 Subject: [PATCH 08/13] feat: change main name --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4f67868..5fc837d 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -29,7 +29,7 @@ jobs: with: context: . file: Dockerfile - tags: ghcr.io/ucsd-e4e/maestro_trainer:latest + tags: ghcr.io/ucsd-e4e/maestro_trainer:main push: true - name: Build prod and push From 3a8c04c7ed4ab6328814fede8f84f632a4d79b33 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Sun, 9 Feb 2025 13:16:53 -0800 Subject: [PATCH 09/13] feat: caching --- .github/workflows/docker-image.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 5fc837d..de73d9a 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -31,6 +31,8 @@ jobs: file: Dockerfile tags: ghcr.io/ucsd-e4e/maestro_trainer:main push: true + cache-from: type=registry,ref=user/ghcr.io/ucsd-e4e/maestro_scheduler:main_cache + cache-to: type=registry,ref=user/ghcr.io/ucsd-e4e/maestro_scheduler:main_cache,mode=max - name: Build prod and push if: github.ref != 'refs/heads/main' @@ -39,4 +41,6 @@ jobs: context: . file: Dockerfile tags: ghcr.io/ucsd-e4e/maestro_trainer:${{ github.head_ref }} - push: true \ No newline at end of file + push: true + cache-from: type=registry,ref=user/ghcr.io/ucsd-e4e/maestro_scheduler:${{ github.head_ref }}_cache + cache-to: type=registry,ref=user/ghcr.io/ucsd-e4e/maestro_scheduler:${{ github.head_ref }}_cache,mode=max \ No newline at end of file From 878fbbd06658b9d24e1a960468e3b7694bc8ea2c Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Sun, 9 Feb 2025 13:22:20 -0800 Subject: [PATCH 10/13] fix: username for ref --- .github/workflows/docker-image.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index de73d9a..3a64b25 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -31,8 +31,8 @@ jobs: file: Dockerfile tags: ghcr.io/ucsd-e4e/maestro_trainer:main push: true - cache-from: type=registry,ref=user/ghcr.io/ucsd-e4e/maestro_scheduler:main_cache - cache-to: type=registry,ref=user/ghcr.io/ucsd-e4e/maestro_scheduler:main_cache,mode=max + cache-from: type=registry,ref=ghcr.io/ucsd-e4e/maestro_scheduler:main_cache + cache-to: type=registry,ref=ghcr.io/ucsd-e4e/maestro_scheduler:main_cache,mode=max - name: Build prod and push if: github.ref != 'refs/heads/main' @@ -42,5 +42,5 @@ jobs: file: Dockerfile tags: ghcr.io/ucsd-e4e/maestro_trainer:${{ github.head_ref }} push: true - cache-from: type=registry,ref=user/ghcr.io/ucsd-e4e/maestro_scheduler:${{ github.head_ref }}_cache - cache-to: type=registry,ref=user/ghcr.io/ucsd-e4e/maestro_scheduler:${{ github.head_ref }}_cache,mode=max \ No newline at end of file + cache-from: type=registry,ref=ghcr.io/ucsd-e4e/maestro_scheduler:${{ github.head_ref }}_cache + cache-to: type=registry,ref=ghcr.io/ucsd-e4e/maestro_scheduler:${{ github.head_ref }}_cache,mode=max \ No newline at end of file From 7267354caa95469d5b239e2c949b156bc564bc51 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Sun, 9 Feb 2025 14:18:09 -0800 Subject: [PATCH 11/13] fix: name of repo --- .github/workflows/docker-image.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3a64b25..1dc832e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -31,8 +31,8 @@ jobs: file: Dockerfile tags: ghcr.io/ucsd-e4e/maestro_trainer:main push: true - cache-from: type=registry,ref=ghcr.io/ucsd-e4e/maestro_scheduler:main_cache - cache-to: type=registry,ref=ghcr.io/ucsd-e4e/maestro_scheduler:main_cache,mode=max + 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' @@ -42,5 +42,5 @@ jobs: file: Dockerfile tags: ghcr.io/ucsd-e4e/maestro_trainer:${{ github.head_ref }} push: true - cache-from: type=registry,ref=ghcr.io/ucsd-e4e/maestro_scheduler:${{ github.head_ref }}_cache - cache-to: type=registry,ref=ghcr.io/ucsd-e4e/maestro_scheduler:${{ github.head_ref }}_cache,mode=max \ No newline at end of file + 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 \ No newline at end of file From ab918e22649842dab3264070a8a9590ba39f9c21 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Sun, 9 Feb 2025 14:40:47 -0800 Subject: [PATCH 12/13] feat: test cache with readme (removes old gitlab stuff) --- README.md | 92 +------------------------------------------------------ 1 file changed, 1 insertion(+), 91 deletions(-) diff --git a/README.md b/README.md index 715730a..456b02d 100644 --- a/README.md +++ b/README.md @@ -1,93 +1,3 @@ # model_trainer - - -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://gitlab.com/model-maestro/model_trainer.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://gitlab.com/model-maestro/model_trainer/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README - -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +An example trainer for maestro active learning system \ No newline at end of file From 703111bbaf6515c4099f74342c66fd9acd92fca8 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Sun, 9 Feb 2025 14:55:31 -0800 Subject: [PATCH 13/13] feat: simply trainer for testing --- model_trainer/src/model_trainer.py | 64 +++++++++++++++--------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/model_trainer/src/model_trainer.py b/model_trainer/src/model_trainer.py index 7aa27b1..a907654 100644 --- a/model_trainer/src/model_trainer.py +++ b/model_trainer/src/model_trainer.py @@ -1,8 +1,8 @@ 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) @@ -10,41 +10,41 @@ -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()