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

Production deploy Jan 19, 2023 #40

Merged
merged 9 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/chartpress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.6'
python-version: '3.11'
- name: Setup git
run: git config --global user.email "noreply@developmentseed.org" && git config --global user.name "Github Action"
- name: Create more disk space
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: batch/v1beta1
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ template "lulc-helm.fullname" . }}-kubejanitor
Expand Down
18 changes: 18 additions & 0 deletions services/api/doc/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,24 @@ Note: this will not affect currently running instances of the model
*/


/**
* @api {post} /user POST /user
* @apiVersion 1.0.0
* @apiName POST-/user
* @apiGroup Default
* @apiPermission Unknown
*
* @apidescription
* No Description
*

*
*
*
*
*/


/**
* @api {get} /tiles List Tiles
* @apiVersion 1.0.0
Expand Down
520 changes: 295 additions & 225 deletions services/api/package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion services/api/routes/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,17 @@ export default async function router(schema, config) {
try {
if (!req.body.mosaic || !Mosaic.list().mosaics.includes(req.body.mosaic)) throw new Err(400, null, 'Invalid Mosaic');

const model = await Model.from(config.pool, req.body.model_id);

if (!model.storage) throw new Err(400, null, 'Model has not been uploaded');
if (!model.active) throw new Err(400, null, 'Model has not been set as active');

const proj = await Project.generate(config.pool, {
...req.body,
uid: req.auth.id
});

const json = proj.serialize();
const model = await Model.from(config.pool, json.model_id);
json.model_name = model.name;
return res.json(json);
} catch (err) {
Expand Down
5 changes: 5 additions & 0 deletions services/api/schema/req.body.CreateModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"type": "boolean",
"description": "Can the model be used for gpu instances"
},
"storage": {
"type": "boolean",
"description": "Has the model been uploaded to azure - this is normally set by the server and not the client",
"default": false
},
"model_type": {
"type": "string",
"description": "Underlying model type",
Expand Down
1 change: 1 addition & 0 deletions services/api/test/fixtures/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"body": {
"name": "NAIP Supervised",
"active": true,
"storage": true,
"model_type": "pytorch_example",
"model_inputshape": [240,240,4],
"model_zoom": 17,
Expand Down
123 changes: 121 additions & 2 deletions services/api/test/project.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,125 @@ test('POST /api/project (Invalid Mosaic)', async (t) => {
t.end();
});

test('PATCH /api/model/1 - storage: false, active: false', async (t) => {
try {
await flight.request({
json: true,
url: '/api/model/1',
method: 'PATCH',
headers: {
Authorization: `Bearer ${flight.token.ingalls}`
},
body: {
storage: false,
active: true
}
}, t);
} catch (err) {
t.error(err, 'no errors');
}

t.end();
});

test('POST /api/project - Model not uploaded', async (t) => {
try {
const res = await flight.request({
json: true,
url: '/api/project',
method: 'POST',
headers: {
Authorization: `Bearer ${flight.token.ingalls}`
},
body: {
name: 'Test Project',
model_id: 1,
mosaic: 'naip.latest'
}
}, false);

t.deepEquals(res.body, {
status: 400,
message:'Model has not been uploaded',
messages:[]
});
} catch (err) {
t.error(err, 'no errors');
}

t.end();
});

test('PATCH /api/model/1 - storage: true, active: false', async (t) => {
try {
await flight.request({
json: true,
url: '/api/model/1',
method: 'PATCH',
headers: {
Authorization: `Bearer ${flight.token.ingalls}`
},
body: {
storage: true,
active: false
}
}, t);
} catch (err) {
t.error(err, 'no errors');
}

t.end();
});

test('POST /api/project - Model not active', async (t) => {
try {
const res = await flight.request({
json: true,
url: '/api/project',
method: 'POST',
headers: {
Authorization: `Bearer ${flight.token.ingalls}`
},
body: {
name: 'Test Project',
model_id: 1,
mosaic: 'naip.latest'
}
}, false);

t.deepEquals(res.body, {
status: 400,
message:'Model has not been set as active',
messages:[]
});
} catch (err) {
t.error(err, 'no errors');
}

t.end();
});

test('PATCH /api/model/1 - storage: true, active: true', async (t) => {
try {
await flight.request({
json: true,
url: '/api/model/1',
method: 'PATCH',
headers: {
Authorization: `Bearer ${flight.token.ingalls}`
},
body: {
storage: true,
active: true
}
}, t);
} catch (err) {
t.error(err, 'no errors');
}

t.end();
});

test('POST /api/project', async (t) => {
try {
const res = await flight.request({
Expand Down Expand Up @@ -219,7 +338,7 @@ test('GET /api/project', async (t) => {
4
],
'model_zoom': 17,
'storage': false,
'storage': true,
'classes': [
{
'name': 'Water',
Expand Down Expand Up @@ -345,7 +464,7 @@ test('GET /api/project?name=lulc', async (t) => {
4
],
'model_zoom': 17,
'storage': false,
'storage': true,
'classes': [
{
'name': 'Water',
Expand Down