Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/multimask
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Apr 30, 2024
2 parents aa0e5d2 + 06d8c8d commit 1b81dfd
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 17 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/backend_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ on:
branches:
- master
- fix/build
paths:
- 'backend/**'
- '.github/workflows/backend_build.yml'
pull_request:
branches:
- master
paths:
- 'backend/**'
- '.github/workflows/backend_build.yml'

jobs:
Build_on_ubuntu:
Expand All @@ -24,9 +30,9 @@ jobs:
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 2
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/docker_publish_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
push:
branches:
- master
paths-ignore:
- '.github/workflows/backend_build.yml'
- '.github/workflows/frontend_build.yml'
- '.github/workflows/frontend_build_push.yml'

env:
REGISTRY: ghcr.io
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/frontend_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ name: Frontend Build
on:
push:
branches: [ master ]
paths:
- 'frontend/**'
- '.github/workflows/frontend_build.yml'
pull_request:
branches: [ master ]
paths:
- 'frontend/**'
- '.github/workflows/frontend_build.yml'

jobs:
Build_On_Ubuntu:
Expand All @@ -15,15 +21,14 @@ jobs:

strategy:
matrix:
node-version: [16.14.2]

node-version: [ 16.14.2, 16, 18, 20 ]

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -35,4 +40,5 @@ jobs:
- name: Build
run: |
cd frontend/
npm run build
npm run build
55 changes: 55 additions & 0 deletions .github/workflows/frontend_build_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Frontend Build and upload to S3

on:
push:
branches: [ master ]
paths:
- 'frontend/**'
- '.github/workflows/frontend_build_push.yml'
pull_request:
branches: [ master ]
paths:
- 'frontend/**'
- '.github/workflows/frontend_build_push.yml'

permissions:
id-token: write
contents: read

jobs:
build_and_upload:

runs-on: ubuntu-latest
environment: Production
env:
CI: false

strategy:
matrix:
node-version: [ 16 ]

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: cd frontend/ && npm install --legacy-peer-deps

- name: Build frontend
run: cd frontend/ && npm run build
env:
REACT_APP_API_BASE: ${{ vars.REACT_APP_API_BASE }}
REACT_APP_PREDICTOR_API_BASE: ${{ vars.REACT_APP_PREDICTOR_API_BASE }}
REACT_APP_ENV: Dev

- name: Authenticate to AWS
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: ${{ secrets.AWS_OIDC_ROLE }}
role-session-name: fAIrGithub

- name: Upload to S3
run: cd frontend/build && aws s3 sync . s3://${{ vars.FRONTEND_BUCKET }}/
3 changes: 2 additions & 1 deletion backend/aiproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
# Limiter
EPOCHS_LIMIT = env("EPOCHS_LIMIT", default=30)
BATCH_SIZE_LIMIT = env("BATCH_SIZE_LIMIT", default=8)
TRAINING_WORKSPACE_DOWNLOAD_LIMIT = env("TRAINING_WORKSPACE_DOWNLOAD_LIMIT", default=200)


# Application definition
Expand Down Expand Up @@ -97,7 +98,7 @@

CORS_ORIGIN_WHITELIST = ALLOWED_ORIGINS

# CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_ALLOW_ALL = env("CORS_ORIGIN_ALLOW_ALL", default= False)

REST_FRAMEWORK = {
"DEFAULT_SCHEMA_CLASS": "rest_framework.schemas.coreapi.AutoSchema",
Expand Down
8 changes: 5 additions & 3 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def create(self, validated_data):
validated_data.pop(key)

instance = Training.objects.create(**validated_data)

logging.info("Sending record to redis queue")
# run your function here
task = train_model.delay(
dataset_id=instance.model.dataset.id,
Expand All @@ -161,6 +161,8 @@ def create(self, validated_data):
input_contact_spacing=input_contact_spacing,
input_boundary_width=input_boundary_width,
)
logging.info("Record saved in queue")

if not instance.source_imagery:
instance.source_imagery = instance.model.dataset.source_imagery
if multimasks:
Expand Down Expand Up @@ -719,9 +721,9 @@ def get(self, request, lookup_dir):
if os.path.isdir(base_dir)
else os.path.getsize(base_dir)
) / (1024**2)
if size > 200: # if file is greater than 200 mb exit
if size > settings.TRAINING_WORKSPACE_DOWNLOAD_LIMIT: # if file is greater than 200 mb exit
return Response(
{f"Errr: File Size {size} MB Exceed More than 200 MB"}, status=403
{f"Errr: File Size {size} MB Exceed More than {settings.TRAINING_WORKSPACE_DOWNLOAD_LIMIT} MB"}, status=403
)

if os.path.isfile(base_dir):
Expand Down
10 changes: 6 additions & 4 deletions docs/Docker-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Docker Compose is created with redis , worker , postgis database , api and fron
nvidia-smi
```
4. Clonse Base Model and Create RAMP_HOME
4. Clone Base Model and Create RAMP_HOME
- Create a new folder called RAMP , outside fAIr
Expand Down Expand Up @@ -72,7 +72,8 @@ Docker Compose is created with redis , worker , postgis database , api and fron
- Check permissions for ```Read user preferences``` and Redirect URI to be ```http://127.0.0.1:3000/authenticate/``` , Give it name as ```fAIr Dev Local```
- You will get ```OSM_CLIENT_ID``` , ```OSM_CLIENT_SECRET``` Copy them
6. Create Env variables
6. Create Env variables
Backend
- Create a file ```.env``` in backend with [docker_sample_env](../backend/docker_sample_env) content
```
cd backend
Expand All @@ -82,7 +83,8 @@ Docker Compose is created with redis , worker , postgis database , api and fron
Leave rest of the items as it is unless you know what you are doing
- Create ```.env``` in /frontend
Frontend
- Create ```.env``` file in /frontend
```
cd frontend
cp .env_sample .env
Expand Down Expand Up @@ -185,4 +187,4 @@ Docker Compose is created with redis , worker , postgis database , api and fron
DATABASE_URL=postgis://postgres:admin@localhost:5434/ai
CELERY_BROKER_URL="redis://localhost:6379/0"
CELERY_RESULT_BACKEND="redis://localhost:6379/0"
```
```
2 changes: 1 addition & 1 deletion frontend/src/components/Layout/Feedback/Feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ const Feedback = (props) => {
// onDrawStop={_onEditStop}
draw={{
polyline: false,
polygon: true,
polygon: false,
rectangle: true,
circle: false,
circlemarker: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ const DatasetMap = (props) => {
// onDrawStop={_onEditStop}
draw={{
polyline: false,
polygon: true,
polygon: false,
rectangle: true,
circle: false,
circlemarker: false,
Expand Down

0 comments on commit 1b81dfd

Please sign in to comment.