Skip to content

[WIP] Create GISDocuments as untitled when no path provided #630

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mfisher87
Copy link
Member

@mfisher87 mfisher87 commented Apr 14, 2025

Description

Always back GISDocuments with files -- it's a document, after all!

As pointed out by @fperez having the document sometimes be file-backed and other times not file-backed could be confusing to users. Fernando drew comparison between Notebooks and consoles; Notebooks are obviously documents, and consoles are obviously ephemeral. They tell you this from visual context. Presenting an identical interface for a document and ephemeral environment will likely confuse some users.

@brichet proposes a way forward to explicitly create an ephemeral environment with visual indicators here: #596 (comment)

Reverts #595 : Because we are now creating untitled documents when no path is passed (i.e. GISDocument()), users can now use the JupyterLab facilities to rename their documents.

Checklist

  • PR has a descriptive title and content.
  • PR description contains references to any issues the PR resolves, e.g. Resolves #XXX.
  • PR has one of the labels: documentation, bug, enhancement, feature, maintenance
  • Checks are passing.
    Failing lint checks can be resolved with:
    • pre-commit run --all-files
    • jlpm run lint

…s()`

We now create untitled documents when no path is passed in, so users can
use the JupyterLab facilities to rename the document.
@mfisher87 mfisher87 added the enhancement New feature or request label Apr 14, 2025
Copy link
Contributor

Binder 👈 Launch a Binder on branch mfisher87/jupytergis/untitled-documents-by-default

@@ -46,8 +46,6 @@ class GISDocument(CommWidget):
:param path: the path to the file that you would like to open. If not provided, a new empty document will be created.
"""

path: Optional[Path]

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't know the path when we create an untitled document; it could be untitled.jGIS or untitled99.jGIS. The Javascript side knows, but how do we get that info into Python land? See #629

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should require the path argument in the GISDocument, to avoid

Copy link
Collaborator

Choose a reason for hiding this comment

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

Otherwise the untitled.jGIS should probably be created from the kernel itself.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, that's also what I commented in #629


self.path = path

comm_metadata = GISDocument._path_to_comm(str(self.path) if self.path else None)
Copy link
Member Author

Choose a reason for hiding this comment

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

We're only using this variable in one place.

comm_metadata=dict(ymodel_name="@jupytergis:widget", **comm_metadata),
comm_metadata={
"ymodel_name": "@jupytergis:widget",
**self._path_to_comm(path),
Copy link
Member Author

Choose a reason for hiding this comment

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

Instance methods can call class methods from self, which is less brittle than calling it from GISDocument.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changing from dict() to {} was just personal preference. No strong feeling.

@mfisher87 mfisher87 force-pushed the untitled-documents-by-default branch from 27b0739 to a7ca246 Compare April 14, 2025 18:41
Copy link
Contributor

github-actions bot commented Apr 14, 2025

Integration tests report: appsharing.space

@mfisher87 mfisher87 marked this pull request as draft April 14, 2025 19:02
assert (tmp_path / fn).is_file()
GISDocument()
assert len(list(tmp_path.iterdir())) == 2
assert (tmp_path / "untitled1.jGIS").is_file()
Copy link
Member Author

@mfisher87 mfisher87 Apr 14, 2025

Choose a reason for hiding this comment

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

This seemed like the natural way to test this, but I believe because there is no JupyterLab instance running, the JavaScript code which actually creates the files is not being exercised. Is there a better way to test this? Please advise :)

@mfisher87
Copy link
Member Author

Lite tests are timing out again!

@mfisher87 mfisher87 marked this pull request as ready for review April 14, 2025 19:19
@mfisher87 mfisher87 added the help wanted Extra attention is needed label Apr 14, 2025
@mfisher87 mfisher87 changed the title Create GISDocuments as untitled when no path provided [WIP] Create GISDocuments as untitled when no path provided Apr 14, 2025
@mfisher87
Copy link
Member Author

Bug: It creates the file, but it's empty and changes to the widget to not update the file.

@trungleduc
Copy link
Collaborator

You need to add default values to format and contentType here, they are undefined in your workflow.

@mfisher87
Copy link
Member Author

Thanks Trung! I'm going to move this one back to a draft as I think we don't have consensus that this behavior is what we want.

@mfisher87 mfisher87 marked this pull request as draft April 18, 2025 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants