Skip to content

Conversation

@davidbrochart
Copy link
Collaborator

Closes #138.

@davidbrochart davidbrochart marked this pull request as draft February 3, 2023 14:14
@davidbrochart davidbrochart added the enhancement New feature or request label Feb 3, 2023
Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @davidbrochart

Should we move forward with this? If so I have two questions:

  • What version should we use? I would be in favor of using 1.0.0 and making the next release of the package 1.0.0 as we are going to release JupyterLab 4.0.0 and we have not seen a need for changes here.
  • Should we add the version in all cell types instead of just YBaseCell?

@davidbrochart
Copy link
Collaborator Author

IIRC in #138 we were discussing the use of WebSocket subprotocols, but I guess we don't need that now that we can pass the document model version in the DocSessionHandler's reply?

  • What version should we use? I would be in favor of using 1.0.0 and making the next release of the package 1.0.0 as we are going to release JupyterLab 4.0.0 and we have not seen a need for changes here.

Sounds good to me.

  • Should we add the version in all cell types instead of just YBaseCell?

You mean so that e.g. a Markdown cell and a code cell can have different document versions? If yes, I think so.

@fcollonval
Copy link
Member

You mean so that e.g. a Markdown cell and a code cell can have different document versions? If yes, I think so.

Yes


Do you have time to push this forward? Or should I do it?

@davidbrochart
Copy link
Collaborator Author

I can do it.

@davidbrochart
Copy link
Collaborator Author

Actually I'm wondering if cells should have a version, since they are not really a document.
The Python API only provides a version for documents (notebook, file...).

@davidbrochart davidbrochart marked this pull request as ready for review March 16, 2023 11:17
@davidbrochart davidbrochart force-pushed the model_version branch 4 times, most recently from c519959 to 3902151 Compare March 16, 2023 12:14
@davidbrochart
Copy link
Collaborator Author

My idea was to have a version attribute in ISharedDocument, so that all shared documents must set a version. But since they derive from YDocument which implements ISharedDocument, I had to omit version from YDocument, and then there is this error:

src/ydocument.ts(69,7): error TS2416: Property 'changed' in type 'YDocument<T>' is not assignable to the same property in base type 'Omit<ISharedDocument, "version">'.
  Type 'ISignal<this, T>' is not assignable to type 'ISignal<ISharedDocument, DocumentChange>'.
    Type 'this' is not assignable to type 'ISharedDocument'.
      Property 'version' is missing in type 'YDocument<T>' but required in type 'ISharedDocument'.
src/ydocument.ts(76,7): error TS2416: Property 'disposed' in type 'YDocument<T>' is not assignable to the same property in base type 'Omit<ISharedDocument, "version">'.
  Type 'ISignal<this, void>' is not assignable to type 'ISignal<ISharedDocument, void>'.
    Type 'this' is not assignable to type 'ISharedDocument'.

Any idea?

@davidbrochart
Copy link
Collaborator Author

An alternative would be to have an empty version in YDocument (and nothing in ISharedDocument), but that would not enforce shared documents to have a version at compile-time.

@fcollonval
Copy link
Member

Actually I'm wondering if cells should have a version, since they are not really a document.
The Python API only provides a version for documents (notebook, file...).

Yes I agree with you it make sense to only apply it for document types.

An alternative would be to have an empty version in YDocument (and nothing in ISharedDocument), but that would not enforce shared documents to have a version at compile-time.

A solution would be to turn that class to an abstract class with version as abstract field: https://www.typescriptlang.org/docs/handbook/2/classes.html#abstract-classes-and-members

@davidbrochart
Copy link
Collaborator Author

A solution would be to turn that class to an abstract class with version as abstract field

Thanks, I tried to turn YDocument into an abstract class but then it cannot have a create method anymore, since an instance of an abstract class cannot be created. I'm not sure how to create a class of the derived class.

@fcollonval
Copy link
Member

I would be in favor of dropping it as anyway that class is not meant to be instantiated.

Pinging @hbcarlos for his opinion.

@hbcarlos
Copy link
Contributor

Yes, we can drop it.

@davidbrochart
Copy link
Collaborator Author

This yarn.lock file is driving me crazy. If I commit what I have on my machine, the CI gets a different file. If I match the CI file, it doesn't work 😠

@hbcarlos
Copy link
Contributor

This yarn.lock file is driving me crazy. If I commit what I have on my machine, the CI gets a different file. If I match the CI file, it doesn't work 😠

I think it was related to the changes in the yarn.lock. This PR should not change that file.

Copy link
Contributor

@hbcarlos hbcarlos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @davidbrochart!

@hbcarlos hbcarlos requested a review from fcollonval March 20, 2023 10:16
Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fcollonval fcollonval merged commit ae4448c into jupyter-server:main Mar 20, 2023
@davidbrochart davidbrochart deleted the model_version branch March 20, 2023 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add model version

3 participants