Skip to content

Commit

Permalink
debug github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienVig committed Oct 23, 2024
1 parent 7a9dd18 commit 31b4b7b
Show file tree
Hide file tree
Showing 9 changed files with 323 additions and 275 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/lint-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,13 @@ jobs:
test-webapp:
needs: [build-lib, build-lib-web, download-datasets]
runs-on: ubuntu-latest
# Runs tests in parallel with matrix strategy https://docs.cypress.io/guides/guides/parallelization
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
# Also see warning here https://github.com/cypress-io/github-action#parallel
strategy:
fail-fast: false # https://github.com/cypress-io/github-action/issues/48
matrix:
containers: [1, 2] # Uses 2 parallel instances
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -314,6 +321,8 @@ jobs:
working-directory: webapp
install: false
start: npm start
wait-on: 'http://localhost:8081' # Waits for above
parallel: true # Runs test in parallel using settings above
env:
VITE_SERVER_URL: http://server

Expand Down
7 changes: 7 additions & 0 deletions discojs/src/validation/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ export class Validator {
)
throw new Error("unexpected shape of dataset");

// TODO: implement WebWorker to remove this wait
// https://github.com/epfml/disco/issues/758
// When running on cpu the inference hogs the main thread
// and freezes the UI
if (tf.getBackend() === "cpu") {
await new Promise((resolve) => setTimeout(resolve, 100));
}
const prediction = await this.#model.predict(row.xs);
tf.dispose(row);
let predictions: number[];
Expand Down
4 changes: 4 additions & 0 deletions webapp/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export default defineConfig({
on("task", {
readdir: async (p: string) =>
(await fs.readdir(p)).map((filename) => path.join(p, filename)),
log: (message) => {
console.log(message)
return null
},
});
},
},
Expand Down
216 changes: 108 additions & 108 deletions webapp/cypress/e2e/datasetInput.cy.ts
Original file line number Diff line number Diff line change
@@ -1,108 +1,108 @@
import { basicTask, setupServerWith } from "../support/e2e";

// TODO move to components testing
// upstream doesn't yet allow that vuejs/test-utils#2468

describe("image dataset input by group", () => {
it("shows passed labels", () => {
setupServerWith(
basicTask({
dataType: "image",
LABEL_LIST: ["first", "second", "third"],
IMAGE_H: 100,
IMAGE_W: 100,
}),
);

cy.visit("/#/list");
cy.get("button").contains("participate").click();

cy.get("button").contains("next").click();

cy.get("button").contains("group").click();

cy.contains("Group label: first").should("exist");
cy.contains("Group label: second").should("exist");
cy.contains("Group label: third").should("exist");
});

it("allows to input images", () => {
setupServerWith(
basicTask({
dataType: "image",
LABEL_LIST: ["label"],
IMAGE_H: 100,
IMAGE_W: 100,
}),
);

cy.visit("/#/list");
cy.get("button").contains("participate").click();

cy.get("button").contains("next").click();

cy.get("button").contains("group").click();
cy.contains("select images").selectFile([
{ fileName: "first.png", contents: new Uint8Array() },
{ fileName: "second.png", contents: new Uint8Array() },
{ fileName: "third.png", contents: new Uint8Array() },
]);

cy.contains("Number of selected files: 3").should("exist");
});
});

describe("image dataset input by csv", () => {
it("allows to input CSV then images", () => {
setupServerWith(
basicTask({
dataType: "image",
LABEL_LIST: ["label"],
IMAGE_H: 100,
IMAGE_W: 100,
}),
);

cy.visit("/#/list");
cy.get("button").contains("participate").click();

cy.get("button").contains("next").click();

cy.get("button").contains("csv").click();
cy.contains("select CSV").selectFile({
fileName: "csv",
contents: new TextEncoder().encode(
"filename,label\n" +
"first,first\n" +
"second,second\n" +
"third,third\n",
),
});

cy.contains("select images").selectFile([
{ fileName: "first.png", contents: new Uint8Array() },
{ fileName: "second.png", contents: new Uint8Array() },
{ fileName: "third.png", contents: new Uint8Array() },
]);

cy.contains("Number of selected files: 3").should("exist");
});
});

describe("tabular dataset input", () => {
it("allows to input CSV", () => {
setupServerWith(basicTask({ dataType: "tabular" }));

cy.visit("/#/list");
cy.get("button").contains("participate").click();

cy.get("button").contains("next").click();

cy.contains("select CSV").selectFile({
fileName: "filename",
contents: new TextEncoder().encode("a,b,c\n1,2,3\n"),
});

cy.contains("filename").should("exist");
});
});
// import { basicTask, setupServerWith } from "../support/e2e";

// // TODO move to components testing
// // upstream doesn't yet allow that vuejs/test-utils#2468

// describe("image dataset input by group", () => {
// it("shows passed labels", () => {
// setupServerWith(
// basicTask({
// dataType: "image",
// LABEL_LIST: ["first", "second", "third"],
// IMAGE_H: 100,
// IMAGE_W: 100,
// }),
// );

// cy.visit("/#/list");
// cy.get("button").contains("participate").click();

// cy.get("button").contains("next").click();

// cy.get("button").contains("group").click();

// cy.contains("Group label: first").should("exist");
// cy.contains("Group label: second").should("exist");
// cy.contains("Group label: third").should("exist");
// });

// it("allows to input images", () => {
// setupServerWith(
// basicTask({
// dataType: "image",
// LABEL_LIST: ["label"],
// IMAGE_H: 100,
// IMAGE_W: 100,
// }),
// );

// cy.visit("/#/list");
// cy.get("button").contains("participate").click();

// cy.get("button").contains("next").click();

// cy.get("button").contains("group").click();
// cy.contains("select images").selectFile([
// { fileName: "first.png", contents: new Uint8Array() },
// { fileName: "second.png", contents: new Uint8Array() },
// { fileName: "third.png", contents: new Uint8Array() },
// ]);

// cy.contains("Number of selected files: 3").should("exist");
// });
// });

// describe("image dataset input by csv", () => {
// it("allows to input CSV then images", () => {
// setupServerWith(
// basicTask({
// dataType: "image",
// LABEL_LIST: ["label"],
// IMAGE_H: 100,
// IMAGE_W: 100,
// }),
// );

// cy.visit("/#/list");
// cy.get("button").contains("participate").click();

// cy.get("button").contains("next").click();

// cy.get("button").contains("csv").click();
// cy.contains("select CSV").selectFile({
// fileName: "csv",
// contents: new TextEncoder().encode(
// "filename,label\n" +
// "first,first\n" +
// "second,second\n" +
// "third,third\n",
// ),
// });

// cy.contains("select images").selectFile([
// { fileName: "first.png", contents: new Uint8Array() },
// { fileName: "second.png", contents: new Uint8Array() },
// { fileName: "third.png", contents: new Uint8Array() },
// ]);

// cy.contains("Number of selected files: 3").should("exist");
// });
// });

// describe("tabular dataset input", () => {
// it("allows to input CSV", () => {
// setupServerWith(basicTask({ dataType: "tabular" }));

// cy.visit("/#/list");
// cy.get("button").contains("participate").click();

// cy.get("button").contains("next").click();

// cy.contains("select CSV").selectFile({
// fileName: "filename",
// contents: new TextEncoder().encode("a,b,c\n1,2,3\n"),
// });

// cy.contains("filename").should("exist");
// });
// });
62 changes: 31 additions & 31 deletions webapp/cypress/e2e/tasks.cy.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import { defaultTasks } from "@epfml/discojs";
// import { defaultTasks } from "@epfml/discojs";

import { setupServerWith } from "../support/e2e.ts";
// import { setupServerWith } from "../support/e2e.ts";

describe("tasks page", () => {
it("displays tasks", () => {
setupServerWith(
defaultTasks.titanic,
defaultTasks.mnist,
defaultTasks.lusCovid,
defaultTasks.wikitext,
);
// describe("tasks page", () => {
// it("displays tasks", () => {
// setupServerWith(
// defaultTasks.titanic,
// defaultTasks.mnist,
// defaultTasks.lusCovid,
// defaultTasks.wikitext,
// );

cy.visit("/#/list").contains("button", "participate");
// cy.visit("/#/list").contains("button", "participate");

// Length 5 = 4 tasks and 1 div for text description
cy.get('div[id="tasks"]').children().should("have.length", 5);
});
// // Length 5 = 4 tasks and 1 div for text description
// cy.get('div[id="tasks"]').children().should("have.length", 5);
// });

it("redirects to training", () => {
setupServerWith(defaultTasks.titanic);
// it("redirects to training", () => {
// setupServerWith(defaultTasks.titanic);

cy.visit("/#/list").contains("button", "participate");
// cy.visit("/#/list").contains("button", "participate");

cy.get(`div[id="titanic"]`).find("button").click();
cy.url().should("eq", `${Cypress.config().baseUrl}#/titanic`);
// cy.get(`div[id="titanic"]`).find("button").click();
// cy.url().should("eq", `${Cypress.config().baseUrl}#/titanic`);

cy.contains("button", "previous").click();
cy.url().should("eq", `${Cypress.config().baseUrl}#/list`);
});
// cy.contains("button", "previous").click();
// cy.url().should("eq", `${Cypress.config().baseUrl}#/list`);
// });

it("displays error message", () => {
cy.intercept(
{ hostname: "server", pathname: "tasks" },
{ statusCode: 404 },
);
// it("displays error message", () => {
// cy.intercept(
// { hostname: "server", pathname: "tasks" },
// { statusCode: 404 },
// );

cy.visit("/#/list");
cy.contains("button", "reload page");
});
});
// cy.visit("/#/list");
// cy.contains("button", "reload page");
// });
// });
Loading

0 comments on commit 31b4b7b

Please sign in to comment.