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

Version 0.2.0 #10

Merged
merged 74 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
ca1dbb1
moved ml model to independent repo
taxe10 Oct 18, 2023
cd936d0
removed unused files
taxe10 Oct 18, 2023
6e9f9ea
organized code by callbacks and components
taxe10 Oct 18, 2023
269dcf4
organized utils
taxe10 Oct 18, 2023
3ec691b
remaned css file
taxe10 Oct 18, 2023
9e3e0c2
updating requirements and removing unused packages
taxe10 Oct 20, 2023
4492f0c
fixing bugs when results plots are not ready and loading missing labe…
taxe10 Oct 20, 2023
8bb3e0c
added modal to indicate that download has started and placed download…
taxe10 Oct 20, 2023
cbe151d
restructure plot to avoid use of try-except when a plot doesn't have …
taxe10 Oct 20, 2023
818b156
reorganizing code to be more readable
taxe10 Oct 20, 2023
bc0ca9c
fixed typo
taxe10 Oct 20, 2023
1b11d53
fixing bug when retrieving labels from splash
taxe10 Oct 23, 2023
593cb9e
Create publish_docker.yml
taxe10 Oct 23, 2023
89eabd9
Update publish_docker.yml
taxe10 Oct 24, 2023
363ca2c
load ml image uri and commands from content registry
taxe10 Oct 24, 2023
51abce8
removed timeour
taxe10 Oct 24, 2023
5e42104
removed unused packages and organized mlex job schema
taxe10 Oct 24, 2023
798cc8c
removed tiled installation to be handled by file manager
taxe10 Nov 5, 2023
14b497a
changed function to retrieve env variables to make tiled key optional
taxe10 Nov 5, 2023
239ad65
updated readme and docker-compose file
taxe10 Nov 7, 2023
666a76a
added default tiled uri option
taxe10 Nov 7, 2023
2eb07d1
added further information about ML algorithm and added image to docke…
taxe10 Nov 7, 2023
f5d2603
fixed typo
taxe10 Nov 7, 2023
0b2c981
fixed bug in job table when deselecting a row
taxe10 Nov 8, 2023
116141d
added dbc.alerts
taxe10 Nov 8, 2023
3759e06
avoid updating results plot every interval unless the data changed
taxe10 Nov 8, 2023
0e507c5
removing try-except in refresh image callback
taxe10 Nov 8, 2023
f6887f9
center images in display
taxe10 Nov 10, 2023
75c318b
adding try-except to display and loading resized image
taxe10 Nov 10, 2023
6018188
Patch to avoid overloading cpu allocation due to dash_components_editor
taxe10 Nov 10, 2023
884b681
load already downloaded tiled data
taxe10 Dec 5, 2023
03323cd
changed error message due to wrong dataset
taxe10 Jan 5, 2024
d0204ee
removed unused file
taxe10 Feb 1, 2024
b5da165
simplify job table and job pop-up
taxe10 Feb 1, 2024
b0d2dde
rearranged sidebar
taxe10 Feb 1, 2024
ce1df5e
get timezone and download only tagged data
taxe10 Feb 1, 2024
10bf550
present tagging events in the correct timezone
taxe10 Feb 1, 2024
e9910af
display data with log option and get job_logs from compute api instea…
taxe10 Feb 1, 2024
3d47966
rearranged code and removed unused function
taxe10 Feb 1, 2024
6be2215
download only tagged data from tiled
taxe10 Feb 1, 2024
bace538
plot probabilities from file
taxe10 Feb 1, 2024
986fb41
Merge branch 'dev' into dev2
taxe10 Feb 1, 2024
b17c0b8
formatting
taxe10 Apr 19, 2024
b88ff4a
organizing docker files and requirements
taxe10 Apr 19, 2024
4010a5c
add action to check formatting
taxe10 Apr 19, 2024
b4349ce
update mlcoach to use latest version of FM
taxe10 Apr 24, 2024
640f8e9
fixed launching jobs and reading results
taxe10 Apr 24, 2024
d89e73f
update GET tagging events
taxe10 Apr 24, 2024
d1a7649
fixed bug when launching job with tiled
taxe10 Apr 24, 2024
3cb05e2
add loading component and fixed minor viz bugs
taxe10 Apr 24, 2024
ec38aa9
organize package and requirements
taxe10 Apr 29, 2024
50046d8
add log transform client side and rename tiled query to sub uri
taxe10 Apr 29, 2024
033bbd7
update log transform
taxe10 Apr 29, 2024
453aeee
flexible app port and host
taxe10 Apr 29, 2024
5498c91
update packages
taxe10 Apr 29, 2024
f0ba03d
replace print with logger
taxe10 Apr 29, 2024
644b876
remove version of pillow
taxe10 May 3, 2024
17173ea
add support to run outside of containers
taxe10 May 3, 2024
f55939f
fixed clearing results when no row was selected
taxe10 May 4, 2024
afdad2a
fix bug with results not showing when moving the slider
taxe10 May 16, 2024
1b2e069
make splash labels accesible outside containers
taxe10 May 16, 2024
f0b996a
adding gunicorn config
taxe10 May 18, 2024
e3f331b
Sort tagging events from newer to oldest
taxe10 May 18, 2024
c6200fa
Add loading component when loading labels
taxe10 May 18, 2024
783ffbb
Avoid missing results displayed
taxe10 May 18, 2024
23cd20a
Move job alerts to Toasts
taxe10 May 18, 2024
75b11e2
Update data project dict
taxe10 Jun 2, 2024
74de891
Adjust height of model controls
taxe10 Jul 10, 2024
be775c6
The URL to splash-ml was wrong
taxe10 Aug 7, 2024
9f57ea4
Update dockerfile and add splash-ml to docker compose
taxe10 Aug 8, 2024
4e402cf
Update getting started instructions
taxe10 Aug 8, 2024
4335035
Update requirements
taxe10 Aug 8, 2024
e452747
Add db
taxe10 Aug 8, 2024
78f201e
Merge branch 'tanny_dev' into v2.0
taxe10 Aug 8, 2024
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
24 changes: 24 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Tiled setup
TILED_KEY=<your-key>
DEFAULT_TILED_URI=https://tiled-demo.blueskyproject.io/api/v1/metadata/rsoxs/raw/
DEFAULT_TILED_QUERY="/primary/data/Small Angle CCD Detector_image"

# Directory setup
DATA_DIR=/path/to/read/data

# Services URLs
# If running in docker
# SPLASH_URL=http://splash:80/api/v0
# MLEX_COMPUTE_URL=http://job-service:8080/api/v0
# MLEX_CONTENT_URL=http://content-api:8000/api/v0
# MONGO_DB_USERNAME=<your-username>
# MONGO_DB_PASSWORD=<your-password>
# If running locally
SPLASH_URL=http://localhost:8087/api/v0
MLEX_COMPUTE_URL=http://localhost:8080/api/v0
MLEX_CONTENT_URL=http://localhost:8001/api/v0
HOST_NICKNAME=local

# Static Tiled setup [Optional]
STATIC_TILED_URI=
STATIC_TILED_API_KEY=
7 changes: 7 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
# 127 is width of the Github code viewer,
# black default is 88 so this will only warn about comments >127
max-line-length = 127
# Ignore errors due to incompatibility with black
#https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html
extend-ignore = E203,E701
49 changes: 49 additions & 0 deletions .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Docker

on:
push:
branches: [ "main" ]
tags: [ 'v*.*.*' ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}


jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
31 changes: 31 additions & 0 deletions .github/workflows/test-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: test-and-lint

on: pull_request

jobs:
test-and-lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.11.8
uses: actions/setup-python@v3
with:
python-version: '3.11.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run isort
uses: isort/isort-action@master
- name: Test formatting with black
run: |
black . --check
177 changes: 171 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,171 @@
/data/*
*pycache*
.DS_Store
.keras
.Makefile.swp
._*
# Docker override
docker-compose.override.y*ml
database/*

# Byte-compiled / optimized / DLL files
**pycache**
**cache**
*.py[cod]
*$py.class

# C extensions
*.so

# MacOS
**.DS_Store**

# Project
data/*

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-ast
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- repo: https://github.com/gitguardian/ggshield
rev: v1.25.0
hooks:
- id: ggshield
language_version: python3
stages: [commit]
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.2.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.11
MAINTAINER THE MLEXCHANGE TEAM

RUN ls
COPY pyproject.toml pyproject.toml
COPY README.md README.md

RUN pip install --upgrade pip &&\
pip install .

WORKDIR /app/work
ENV HOME /app/work
COPY src src
COPY frontend.py frontend.py
COPY gunicorn_config.py gunicorn_config.py

CMD ["bash"]
CMD gunicorn -c gunicorn_config.py --reload frontend:server
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@
This app provides a training/testing platform for image classification with supervised deep-learning approaches.

## Running as a standalone application
First, let's install docker:

* https://docs.docker.com/engine/install/
1. Start the compute and content services in the [MLExchange platform](https://github.com/mlexchange/mlex). Before moving to the next step, please make sure that the computing API and the content registry are up and running. For more information, please refer to their respective
README files.

Next, let's setup its dependencies:
* [mlex_computing_api](https://github.com/mlexchange/mlex_computing_api)
* [mlex_content_registry](https://github.com/mlexchange/mlex_content_registry)
2. Start [splash-ml](https://github.com/als-computing/splash-ml)

Before moving to the next step, please make sure that the computing API and the content
registry are up and running. For more information, please refer to their respective
README files.
* Next, cd into mlex_mlcoach
* type `docker-compose up --build` into your terminal
2. Create a new Python environment and install dependencies:
```
conda create -n new_env python==3.11
conda activate new_env
pip install .
```

3. Create a `.env` file using `.env.example` as reference. Update this file accordingly.

4. Start example app:
```
python frontend.py
```

Finally, you can access MLCoach at:
* Dash app: http://localhost:8062/
Expand All @@ -26,10 +32,12 @@ to use this application.
# Model Description
**TF-NeuralNetworks:** Assortment of neural networks implemented in [TensorFlow](https://www.tensorflow.org).

Further information can be found in [concepts](/docs/concepts.md).
Further information can be found in [mlex_image_classification](https://github.com/mlexchange/mlex_image_classification).

To make existing algorithms available in MLCoach, make sure to upload the `model description` to the content registry.

# Copyright
MLExchange Copyright (c) 2021, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.
MLExchange Copyright (c) 2024, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.

If you have questions about your rights to use or distribute this software, please contact Berkeley Lab's Intellectual Property Office at [email protected].

Expand Down
Loading
Loading