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

Store original path as returned from contents API in the Contents.IModel #13216

Merged
merged 1 commit into from
Nov 4, 2022

Conversation

krassowski
Copy link
Member

References

Fixes #13155 using solution (b) as proposed solutions in #13155 (comment). I have moderate doubts on whether this is the best solution; (c) seems cleaner but I am not convinced if getting the cleaner solution is worth introducing a breaking change, see discussion in #13155 (whereas this PR could still be backported to 3.5).

Code changes

Adds optional serverPath attribute to Contents.IModel and populates it in ContentsManager methods by path returned by the server.

Note: an example of the issue was actually in our tests all along: DEFAULT_FILE has path foo/test which is correctly returned when creating a file:

it('should create a file on an additional drive', async () => {
const other = new Drive({ name: 'other', serverSettings });
contents.addDrive(other);
handleRequest(other, 201, DEFAULT_FILE);
const model = await contents.newUntitled({ path: 'other:/foo' });
expect(model.path).toBe('other:foo/test');
});

but when a file is queried with get:

it('should get a file from an additional drive', async () => {
const drive = new Drive({ name: 'other', serverSettings });
contents.addDrive(drive);
handleRequest(drive, 200, DEFAULT_FILE);
const options: Contents.IFetchOptions = { type: 'file' };
const model = await contents.get('other:/foo', options);
expect(model.path).toBe('other:foo');
});

then other:foo instead of other:foo/test gets returned. This PR adds foo/test on extra property, serverPath (which for now is optional in the interface).

User-facing changes

None.

Backwards-incompatible changes

None

in the `Contents.IModel` object.
@krassowski krassowski added this to the 3.5.0 milestone Oct 10, 2022
@jupyterlab-probot
Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

@fcollonval
Copy link
Member

@krassowski thanks for pointing out the inconsistency.

I would be in favor to force IModel.path to be consistent - it sounds to me like a bug to have a new file path not matching the one obtained for getting the same file.

Otherwise I'm 👍 to add the serverPath to allow backport.

@fcollonval fcollonval modified the milestones: 3.5.0, 3.6.0 Oct 13, 2022
@fcollonval fcollonval mentioned this pull request Oct 14, 2022
23 tasks
@krassowski krassowski marked this pull request as draft October 17, 2022 00:00
@krassowski krassowski marked this pull request as ready for review November 2, 2022 15:00
@fcollonval
Copy link
Member

CI failures are not relevant

@fcollonval fcollonval merged commit acd73cb into jupyterlab:master Nov 4, 2022
@fcollonval
Copy link
Member

@meeseeksdev please backport to 3.6.x

meeseeksmachine pushed a commit to meeseeksmachine/jupyterlab that referenced this pull request Nov 4, 2022
fcollonval pushed a commit that referenced this pull request Nov 4, 2022
… in the `Contents.IModel` (#13375)

Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Content Manager Path to notebook overridden by URL path in lab
2 participants