diff --git a/.github/workflows/backend_build.yml b/.github/workflows/backend_build.yml index 10fd0583..7d53f39b 100644 --- a/.github/workflows/backend_build.yml +++ b/.github/workflows/backend_build.yml @@ -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: @@ -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 diff --git a/.github/workflows/docker_publish_image.yml b/.github/workflows/docker_publish_image.yml index f52ac637..2bdb097a 100644 --- a/.github/workflows/docker_publish_image.yml +++ b/.github/workflows/docker_publish_image.yml @@ -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 diff --git a/.github/workflows/frontend_build.yml b/.github/workflows/frontend_build.yml index 2a81495b..23b091c1 100644 --- a/.github/workflows/frontend_build.yml +++ b/.github/workflows/frontend_build.yml @@ -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: @@ -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 }} @@ -35,4 +40,5 @@ jobs: - name: Build run: | cd frontend/ - npm run build \ No newline at end of file + npm run build + diff --git a/.github/workflows/frontend_build_push.yml b/.github/workflows/frontend_build_push.yml new file mode 100644 index 00000000..79b01c75 --- /dev/null +++ b/.github/workflows/frontend_build_push.yml @@ -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 }}/ diff --git a/backend/aiproject/settings.py b/backend/aiproject/settings.py index 2d62f438..d3536768 100644 --- a/backend/aiproject/settings.py +++ b/backend/aiproject/settings.py @@ -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 @@ -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", diff --git a/backend/core/views.py b/backend/core/views.py index 8eb54f48..c4d826ba 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -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, @@ -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: @@ -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): diff --git a/docs/Docker-installation.md b/docs/Docker-installation.md index 529793ec..df8ea4b3 100644 --- a/docs/Docker-installation.md +++ b/docs/Docker-installation.md @@ -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 @@ -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 @@ -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 @@ -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" - ``` \ No newline at end of file + ``` diff --git a/frontend/src/components/Layout/Feedback/Feedback.js b/frontend/src/components/Layout/Feedback/Feedback.js index 6909419c..8b986efd 100644 --- a/frontend/src/components/Layout/Feedback/Feedback.js +++ b/frontend/src/components/Layout/Feedback/Feedback.js @@ -473,7 +473,7 @@ const Feedback = (props) => { // onDrawStop={_onEditStop} draw={{ polyline: false, - polygon: true, + polygon: false, rectangle: true, circle: false, circlemarker: false, diff --git a/frontend/src/components/Layout/TrainingDS/DatasetEditor/DatasetMap.js b/frontend/src/components/Layout/TrainingDS/DatasetEditor/DatasetMap.js index c6ad873c..2cddeefb 100644 --- a/frontend/src/components/Layout/TrainingDS/DatasetEditor/DatasetMap.js +++ b/frontend/src/components/Layout/TrainingDS/DatasetEditor/DatasetMap.js @@ -718,7 +718,7 @@ const DatasetMap = (props) => { // onDrawStop={_onEditStop} draw={{ polyline: false, - polygon: true, + polygon: false, rectangle: true, circle: false, circlemarker: false,