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

Remove custom property from nb and cell metadata #207995

Merged
merged 1 commit into from
Mar 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ const apiTestSerializer: vscode.NotebookSerializer = {
},
deserializeNotebook(_content, _token) {
const dto: vscode.NotebookData = {
metadata: { custom: { testMetadata: false } },
metadata: { testMetadata: false },
cells: [
{
value: 'test',
languageId: 'typescript',
kind: vscode.NotebookCellKind.Code,
outputs: [],
metadata: { custom: { testCellMetadata: 123 } },
metadata: { testCellMetadata: 123 },
executionSummary: { timing: { startTime: 10, endTime: 20 } }
},
{
Expand All @@ -107,7 +107,7 @@ const apiTestSerializer: vscode.NotebookSerializer = {
})
],
executionSummary: { executionOrder: 5, success: true },
metadata: { custom: { testCellMetadata: 456 } }
metadata: { testCellMetadata: 456 }
}
]
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ suite('Notebook Document', function () {
const document = await vscode.workspace.openNotebookDocument(uri);

const edit = new vscode.WorkspaceEdit();
const metdataEdit = vscode.NotebookEdit.updateNotebookMetadata({ ...document.metadata, custom: { ...(document.metadata.custom || {}), extraNotebookMetadata: true } });
const metdataEdit = vscode.NotebookEdit.updateNotebookMetadata({ ...document.metadata, extraNotebookMetadata: true });
edit.set(document.uri, [metdataEdit]);
const success = await vscode.workspace.applyEdit(edit);
assert.equal(success, true);
assert.ok(document.metadata.custom.extraNotebookMetadata, `Test metadata not found`);
assert.ok(document.metadata.extraNotebookMetadata, `Test metadata not found`);
});

test('setTextDocumentLanguage for notebook cells', async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ const apiTestSerializer: vscode.NotebookSerializer = {
},
deserializeNotebook(_content, _token) {
const dto: vscode.NotebookData = {
metadata: { custom: { testMetadata: false } },
metadata: { testMetadata: false },
cells: [
{
value: 'test',
languageId: 'typescript',
kind: vscode.NotebookCellKind.Code,
outputs: [],
metadata: { custom: { testCellMetadata: 123 } },
metadata: { testCellMetadata: 123 },
executionSummary: { timing: { startTime: 10, endTime: 20 } }
},
{
Expand All @@ -115,7 +115,7 @@ const apiTestSerializer: vscode.NotebookSerializer = {
})
],
executionSummary: { executionOrder: 5, success: true },
metadata: { custom: { testCellMetadata: 456 } }
metadata: { testCellMetadata: 456 }
}
]
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ suite('ExtHostTypeConverter', function () {

const d = new extHostTypes.NotebookData([]);
d.cells.push(new extHostTypes.NotebookCellData(extHostTypes.NotebookCellKind.Code, 'hello', 'fooLang'));
d.metadata = { custom: { foo: 'bar', bar: 123 } };
d.metadata = { foo: 'bar', bar: 123 };

const dto = NotebookData.from(d);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ abstract class KernelPickerStrategyBase implements IKernelPickerStrategy {
*/
private getSuggestedLanguage(notebookTextModel: NotebookTextModel): string | undefined {
const metaData = notebookTextModel.metadata;
let suggestedKernelLanguage: string | undefined = (metaData.custom as any)?.metadata?.language_info?.name;
let suggestedKernelLanguage: string | undefined = (metaData as any)?.metadata?.language_info?.name;
// TODO how do we suggest multi language notebooks?
if (!suggestedKernelLanguage) {
const cellLanguages = notebookTextModel.cells.map(cell => cell.language).filter(language => language !== 'markdown');
Expand Down
64 changes: 32 additions & 32 deletions src/vs/workbench/contrib/notebook/test/browser/notebookDiff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ suite('NotebookCommon', () => {

test('diff different source', async () => {
await withTestNotebookDiffModel([
['x', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 3 }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { metadata: { collapsed: false }, executionOrder: 3 }],
], [
['y', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 3 }],
['y', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { metadata: { collapsed: false }, executionOrder: 3 }],
], (model, disposables, accessor) => {
const diff = new LcsDiff(new CellSequence(model.original.notebook), new CellSequence(model.modified.notebook));
const diffResult = diff.ComputeDiff(false);
Expand Down Expand Up @@ -72,10 +72,10 @@ suite('NotebookCommon', () => {

test('diff different output', async () => {
await withTestNotebookDiffModel([
['x', 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([5])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 5 }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([5])) }] }], { metadata: { collapsed: false }, executionOrder: 5 }],
['', 'javascript', CellKind.Code, [], {}]
], [
['x', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 3 }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { metadata: { collapsed: false }, executionOrder: 3 }],
['', 'javascript', CellKind.Code, [], {}]
], (model, disposables, accessor) => {
const diff = new LcsDiff(new CellSequence(model.original.notebook), new CellSequence(model.modified.notebook));
Expand Down Expand Up @@ -197,12 +197,12 @@ suite('NotebookCommon', () => {

test('diff foo/foe', async () => {
await withTestNotebookDiffModel([
[['def foe(x, y):\n', ' return x + y\n', 'foe(3, 2)'].join(''), 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([6])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 5 }],
[['def foo(x, y):\n', ' return x * y\n', 'foo(1, 2)'].join(''), 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([2])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 6 }],
[['def foe(x, y):\n', ' return x + y\n', 'foe(3, 2)'].join(''), 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([6])) }] }], { metadata: { collapsed: false }, executionOrder: 5 }],
[['def foo(x, y):\n', ' return x * y\n', 'foo(1, 2)'].join(''), 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([2])) }] }], { metadata: { collapsed: false }, executionOrder: 6 }],
['', 'javascript', CellKind.Code, [], {}]
], [
[['def foo(x, y):\n', ' return x * y\n', 'foo(1, 2)'].join(''), 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([6])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 5 }],
[['def foe(x, y):\n', ' return x + y\n', 'foe(3, 2)'].join(''), 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([2])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 6 }],
[['def foo(x, y):\n', ' return x * y\n', 'foo(1, 2)'].join(''), 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([6])) }] }], { metadata: { collapsed: false }, executionOrder: 5 }],
[['def foe(x, y):\n', ' return x + y\n', 'foe(3, 2)'].join(''), 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([2])) }] }], { metadata: { collapsed: false }, executionOrder: 6 }],
['', 'javascript', CellKind.Code, [], {}]
], (model, disposables, accessor) => {
const diff = new LcsDiff(new CellSequence(model.original.notebook), new CellSequence(model.modified.notebook));
Expand Down Expand Up @@ -407,15 +407,15 @@ suite('NotebookCommon', () => {

test('LCS', async () => {
await withTestNotebookDiffModel([
['# Description', 'markdown', CellKind.Markup, [], { custom: { metadata: {} } }],
['x = 3', 'javascript', CellKind.Code, [], { custom: { metadata: { collapsed: true } }, executionOrder: 1 }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 1 }],
['x', 'javascript', CellKind.Code, [], { custom: { metadata: { collapsed: false } } }]
['# Description', 'markdown', CellKind.Markup, [], { metadata: {} }],
['x = 3', 'javascript', CellKind.Code, [], { metadata: { collapsed: true }, executionOrder: 1 }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { metadata: { collapsed: false }, executionOrder: 1 }],
['x', 'javascript', CellKind.Code, [], { metadata: { collapsed: false } }]
], [
['# Description', 'markdown', CellKind.Markup, [], { custom: { metadata: {} } }],
['x = 3', 'javascript', CellKind.Code, [], { custom: { metadata: { collapsed: true } }, executionOrder: 1 }],
['x', 'javascript', CellKind.Code, [], { custom: { metadata: { collapsed: false } } }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 1 }]
['# Description', 'markdown', CellKind.Markup, [], { metadata: {} }],
['x = 3', 'javascript', CellKind.Code, [], { metadata: { collapsed: true }, executionOrder: 1 }],
['x', 'javascript', CellKind.Code, [], { metadata: { collapsed: false } }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { metadata: { collapsed: false }, executionOrder: 1 }]
], async (model) => {
const diff = new LcsDiff(new CellSequence(model.original.notebook), new CellSequence(model.modified.notebook));
const diffResult = diff.ComputeDiff(false);
Expand All @@ -440,18 +440,18 @@ suite('NotebookCommon', () => {

test('LCS 2', async () => {
await withTestNotebookDiffModel([
['# Description', 'markdown', CellKind.Markup, [], { custom: { metadata: {} } }],
['x = 3', 'javascript', CellKind.Code, [], { custom: { metadata: { collapsed: true } }, executionOrder: 1 }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 1 }],
['x', 'javascript', CellKind.Code, [], { custom: { metadata: { collapsed: false } } }],
['# Description', 'markdown', CellKind.Markup, [], { metadata: {} }],
['x = 3', 'javascript', CellKind.Code, [], { metadata: { collapsed: true }, executionOrder: 1 }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { metadata: { collapsed: false }, executionOrder: 1 }],
['x', 'javascript', CellKind.Code, [], { metadata: { collapsed: false } }],
['x = 5', 'javascript', CellKind.Code, [], {}],
['x', 'javascript', CellKind.Code, [], {}],
['x', 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([5])) }] }], {}],
], [
['# Description', 'markdown', CellKind.Markup, [], { custom: { metadata: {} } }],
['x = 3', 'javascript', CellKind.Code, [], { custom: { metadata: { collapsed: true } }, executionOrder: 1 }],
['x', 'javascript', CellKind.Code, [], { custom: { metadata: { collapsed: false } } }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 1 }],
['# Description', 'markdown', CellKind.Markup, [], { metadata: {} }],
['x = 3', 'javascript', CellKind.Code, [], { metadata: { collapsed: true }, executionOrder: 1 }],
['x', 'javascript', CellKind.Code, [], { metadata: { collapsed: false } }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { metadata: { collapsed: false }, executionOrder: 1 }],
['x = 5', 'javascript', CellKind.Code, [], {}],
['x', 'javascript', CellKind.Code, [{ outputId: 'someId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([5])) }] }], {}],
['x', 'javascript', CellKind.Code, [], {}],
Expand Down Expand Up @@ -528,11 +528,11 @@ suite('NotebookCommon', () => {

test('diff output', async () => {
await withTestNotebookDiffModel([
['x', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 3 }],
['y', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([4])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 3 }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { metadata: { collapsed: false }, executionOrder: 3 }],
['y', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([4])) }] }], { metadata: { collapsed: false }, executionOrder: 3 }],
], [
['x', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 3 }],
['y', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([5])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 3 }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { metadata: { collapsed: false }, executionOrder: 3 }],
['y', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([5])) }] }], { metadata: { collapsed: false }, executionOrder: 3 }],
], (model, disposables, accessor) => {
const diff = new LcsDiff(new CellSequence(model.original.notebook), new CellSequence(model.modified.notebook));
const diffResult = diff.ComputeDiff(false);
Expand All @@ -557,11 +557,11 @@ suite('NotebookCommon', () => {

test('diff output fast check', async () => {
await withTestNotebookDiffModel([
['x', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 3 }],
['y', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([4])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 3 }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { metadata: { collapsed: false }, executionOrder: 3 }],
['y', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([4])) }] }], { metadata: { collapsed: false }, executionOrder: 3 }],
], [
['x', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 3 }],
['y', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([5])) }] }], { custom: { metadata: { collapsed: false } }, executionOrder: 3 }],
['x', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([3])) }] }], { metadata: { collapsed: false }, executionOrder: 3 }],
['y', 'javascript', CellKind.Code, [{ outputId: 'someOtherId', outputs: [{ mime: Mimes.text, data: VSBuffer.wrap(new Uint8Array([5])) }] }], { metadata: { collapsed: false }, executionOrder: 3 }],
], (model, disposables, accessor) => {
const diff = new LcsDiff(new CellSequence(model.original.notebook), new CellSequence(model.modified.notebook));
const diffResult = diff.ComputeDiff(false);
Expand Down
Loading