Skip to content

Commit

Permalink
Merge pull request #8 from aws-samples/housekeeping
Browse files Browse the repository at this point in the history
Housekeeping
  • Loading branch information
matteofigus authored Dec 5, 2019
2 parents 938b542 + d801381 commit 55227e3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/cfn/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Globals:
CREATE_CLOUDFRONT_DISTRIBUTION: !Ref CreateCloudFrontDistribution
REGION: !Ref AWS::Region
TO_BUCKET: !Ref WebUIBucket
VERSION: "0.15"
VERSION: "0.16"

Parameters:
AdminEmail:
Expand Down
2 changes: 1 addition & 1 deletion src/web-ui/src/components/FileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default ({ id, onChange }) => (
<div className="form-prompt">
Use your own image
<div className="form-instructions">
Image must be .jpeg or .png format and no larger than 5MB. Your image
Image must be .jpeg or .png format and no larger than 4MB. Your image
isn't stored.
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/web-ui/src/components/ImageMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default ({ gateway, projectVersionArn }) => {
"data:image/png;base64"
].includes(type);

const validSize = size < 5000000;
const validSize = size < 4000000;
const result = { isValid: validType && validSize };
const errors = [];
if (!validType) errors.push("the image format is not valid");
Expand Down
14 changes: 10 additions & 4 deletions src/web-ui/src/components/ProjectActions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React, { useState } from "react";
import { Alert, Button, Form, Modal } from "react-bootstrap";

import { formatErrorMessage } from "../utils";

export default ({ gateway, onError, project, refreshProjects }) => {
const [errorMessage, setErrorMessage] = useState(undefined);
const [formState, setFormState] = useState("initial");
const [minInferenceUnits, setMinInferenceUnits] = useState("");
const [show, setShow] = useState(false);
Expand All @@ -26,7 +29,10 @@ export default ({ gateway, onError, project, refreshProjects }) => {
parseInt(minInferenceUnits, 10)
)
.then(() => setFormState("saved"))
.catch(() => setFormState("error"));
.catch(e => {
setErrorMessage(formatErrorMessage(e));
setFormState("error");
});
};

const stopModel = e => {
Expand Down Expand Up @@ -70,8 +76,8 @@ export default ({ gateway, onError, project, refreshProjects }) => {
</Modal.Header>
<Modal.Body>
<p>
Starting a model takes a while to complete. To check the current
state of the model, refresh the Projects page.
A model might take a while to start. To check the current state of
the model, refresh the Projects page.
<br />
<br />
<b>
Expand All @@ -86,7 +92,7 @@ export default ({ gateway, onError, project, refreshProjects }) => {
<Alert variant="warning">Please wait</Alert>
)}
{formState === "error" && (
<Alert variant="danger">An error happened. Retry.</Alert>
<Alert variant="danger">{errorMessage}</Alert>
)}
{formState === "saved" && (
<Alert variant="success">The model is starting.</Alert>
Expand Down
4 changes: 2 additions & 2 deletions src/web-ui/src/components/ProjectsSummary.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from "react";
import { Alert, Button, Card, Spinner, Table } from "react-bootstrap";
import { mapResults } from "../utils";
import { formatErrorMessage, mapResults } from "../utils";

import ProjectActions from "./ProjectActions";

Expand All @@ -22,7 +22,7 @@ export default ({ gateway, onHelp, onVersionClick }) => {
)
).then(x => setProjects(mapResults(x)))
)
.catch(e => setErrorDetails(e.toString()));
.catch(e => setErrorDetails(formatErrorMessage(e)));
}, [gateway, projectsRefreshCycle]);

return (
Expand Down
11 changes: 11 additions & 0 deletions src/web-ui/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,14 @@ export const retryWrapper = (p, timeout, retryN) =>
);
})
);

export const formatErrorMessage = e => {
let msg = "An error happened";
if (e.response) {
if (e.response.status) msg += ` (${e.response.status} status code)`;
if (e.response.data && e.response.data.Message)
msg += `: ${e.response.data.Message}`;
}

return msg;
};

0 comments on commit 55227e3

Please sign in to comment.