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

[FIX] Remove existing annotations from data dictionaries #715

Merged
merged 6 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 11 additions & 0 deletions cypress/component/home_page.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ describe("The Home page", () => {
cy.get("[data-cy='data-dictionary-selector']").should("be.visible").contains("Choose file");
});

it("Shows a warning about not being able to reuse annotations in the data dictionary", () => {
cy.mount(homePage, {

mocks: { $store: store },
stubs: stubs,
plugins: ["bootstrap-vue"]
});

cy.get("[data-cy='cannot-reuse-annotations-button']").should('be.visible').contains("Cannot reuse annotations");
});

it("Correctly displays previews of the loaded data", () => {

// Act
Expand Down
10 changes: 10 additions & 0 deletions pages/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@
<b-row>
<b-col>
<h3>{{ uiText.dataDictionaryHeader }}</h3>
<b-button data-cy="cannot-reuse-annotations-button" v-b-toggle.collapse-2 variant="warning">Cannot reuse annotations</b-button>
<b-collapse id="collapse-2">
<br />
At the moment, the annotation tool is not able to load previously created annotations.
This means thart if you provide a data dictionary here that you created with Neurobagel,
surchs marked this conversation as resolved.
Show resolved Hide resolved
any existing semantic annotations will be removed when the data dictionary is loaded.

In practice this means that you cannot resume an aborted previous annotation.
This is a limitation we are going to address: <a href="https://github.com/neurobagel/annotation_tool/issues/601" target="_blank">#601</a>.
</b-collapse>
<file-selector
data-cy="data-dictionary-selector"
:content-type="contentTypes.dataDictionary"
Expand Down
10 changes: 7 additions & 3 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,14 @@ export const actions = {

processDataDictionary({ state, commit, getters }, { data, filename }) {

// 1. Save the user-provided data dictionary
commit("setDataDictionary", { newDataDictionary: JSON.parse(data), storeColumns: getters.getColumnNames });
// If annotations exist in the provided data, remove them first
const userDataDictionary = JSON.parse(data);

// 2. Save the filename of the user-provided data dictionary
Object.keys(userDataDictionary).forEach(key => {
delete userDataDictionary[key].Annotations;
});

commit("setDataDictionary", { newDataDictionary: userDataDictionary, storeColumns: getters.getColumnNames });
commit("setDataDictionaryFilename", filename);
},

Expand Down
Loading