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
Allow the ability to store extension specific metadata in Notebook cells #96433
Comments
cc @rebornix |
Pushed first attempt for custom metadata to master, the metadata interface now looks like export interface NotebookCellMetadata {
editable?: boolean;
runnable?: boolean;
executionOrder?: number;
statusMessage?: string;
runState?: NotebookCellRunState;
runStartTime?: number;
lastRunDuration?: number;
/**
* Additional attributes of a cell metadata.
*/
custom: { [key: string]: any; }
} For a moment I was wondering if we can define the metadata as simple as export interface NotebookCellMetadata {
editable?: boolean;
...
[key: string]: any;
} which is convenient, but the catch is if we later on introduce new builtin metadata, we can't guarantee that it doesn't break existing notebooks. Considering that naming is hard, we are very likely to use names which are already used by Jupyter Notebook, the API ended up with the first proposal for now: every custom metadata should be set inside |
Not really a fan of the following: export interface NotebookCellMetadata {
editable?: boolean;
...
[key: string]: any;
} Its not easy identify what's custom vs VS Code. Will pull master and try this out now. |
@rebornix Feels like extension authors need a way to provide an identifier to a cell. |
@jrieken any idea if this was tested or needs verification? |
🤷 ping @rebornix |
We still have ongoing discussion about waht/how metadata are being copied to copy/paste. Reopen this and finalize in next iteration. |
I think we can close this for now. The PowerShell extension already takes advantage of the custom metadata and it works nicely. |
For the PowerShell extension's Notebook Mode:
The idea is: "There are two types of comment blocks:
<# #>
(aka block comments) and#
(aka line comments). While parsing a script, I want to store metadata in the cell object to say "this cell is backed by block comments not regular comments" so that when I save, the comment type can be honored."To get around this, I am using a
Map<number, CommentType (enum)>
in the extension to store this metadata:https://github.com/TylerLeonhardt/vscode-powershell/blob/fe8576bda498b81f89f05806b2667d8c50e0f6a9/src/features/PowerShellNotebooks.ts#L16
But if I could store this on the cell directly, it would be incredibly safer.
For a Jupyter extension
.ipynb
files have ametadata
section:https://gist.github.com/TylerLeonhardt/b51583af068b62be2ca2305aa4061f89?short_path=03c798a#file-azure-powershell-visualization-demo-ipynb-L5-L8
for cell specific details. If this feature was added to Notebook UI in VS Code, I could see a Jupyter extension taking advantage of it as well.
The text was updated successfully, but these errors were encountered: