-
Notifications
You must be signed in to change notification settings - Fork 1
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
[apiserver]: fix jgscm root folder creation, dependencies #1
Changes from all commits
f229798
f1bdba0
bb148ac
4ed8461
06009be
fcc4f48
149bc2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -460,7 +460,8 @@ def run_post_save_hook(self, model, os_path): | |
model=model, | ||
contents_manager=self) | ||
except Exception: | ||
self.log.error("Post-save hook failed on %s", os_path, exc_info=True) | ||
self.log.error("Post-save hook failed on %s", | ||
os_path, exc_info=True) | ||
|
||
@default("checkpoints_class") | ||
def _checkpoints_class_default(self): | ||
|
@@ -522,13 +523,15 @@ def _get_bucket(self, name, throw=False): | |
cache[name] = bucket | ||
return bucket | ||
|
||
@staticmethod | ||
def _parse_path(path): | ||
def _parse_path(self, path): | ||
""" | ||
Splits the path into bucket name and path inside the bucket. | ||
:param path: string to split. | ||
:return: tuple(bucket name, bucket path). | ||
""" | ||
if self.default_path and not path.startswith(f"{self.default_path}/"): | ||
path = f"{self.default_path}/{path}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I think I'm starting to see: path is not a URL but it may or may not include the bucket. Hmm, this doesn't do what the old code does. If default_path doesn't have a leading slash, you probably need to add it in the call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. default_path shouldn't have a leading slash https://github.com/src-d/jgscm#usage
The _parse_path needs to return the bucket_name (no slash), and the rest of the path, with the slash separating bucket_name and the rest of the path stripped. The call right below my change is: bucket, _, blobname = path.partition("/")
return bucket, blobname which splits on the first slash, and strips that first slash (because the middle argument is dropped). The behavior we want:
I've attached some examples of the call stack: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only behavior that this changes is that when you create a bucket in the root dir, and you have And I realized it actually fixes another issue. In the old jgscm, when you created 2 python files in the root dir, the 2nd would overwrite the first. This fixes that as well. See the below There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enumerating the cases makes it clear this design has a real ambiguity when there is a folder with the same name as a bucket, but let's deal with that after this goes in. Your code still breaks on the case there is a folder that starts with (but is not equal to) the bucket name, my recommendation of
You mean folder?
This really seems like a bug (creating things outside the default path), which is why I'd call it a patch release. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, I agree, I don't like the lack of separation between folder and bucket taken in jgscm. I think the more stable solution is to always prefix the filename with the bucket name, unless in the root folder, in which case the behavior will be different depending on the flag passed (and that maybe shouldn't be default_path; someone may want to be able to create buckets even when a default bucket is specified).
I will attempt to address this now.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it's addressed by checking for
This problem only affects renaming and moving, since creation uses a default name ( Here is an example of this working renaming.mp4.zip There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I propose that we defer the moving fix for another PR, so that Konrad/Liam can test other functions. However, can work further on this if you think worth it. Whatever you prefer :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd open an issue for the file/folder-as-bucket-name problem and make it low priority. Getting IO (hadoop stuff) and user isolation going seem much more important. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
bucket, _, blobname = path.partition("/") | ||
return bucket, blobname | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,18 @@ | |
setup( | ||
name="jgscm", | ||
description="Jupyter Google Cloud Storage ContentsManager", | ||
version="0.1.9", | ||
version="0.1.10-hail", | ||
license="MIT", | ||
author="Vadim Markovtsev", | ||
author_email="[email protected]", | ||
url="https://github.com/src-d/jgscm", | ||
download_url="https://github.com/src-d/jgscm", | ||
packages=["jgscm"], | ||
keywords=["jupyter", "ipython", "gcloud", "gcs"], | ||
install_requires=["google-cloud>=0.32.0", "notebook>=4.2", "nbformat>=4.1", | ||
"tornado>=4", "traitlets>=4.2"], | ||
install_requires=["google-api-python-client>=1.7", | ||
"google-cloud-storage>=1.14", | ||
"notebook>=5.7", "nbformat>=4.4", | ||
"tornado>=6.0", "traitlets>=4.3"], | ||
package_data={"": ["requirements.txt", "LICENSE", "README.md"]}, | ||
classifiers=[ | ||
"Development Status :: 3 - Alpha", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary format change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a auto-format line-length change, 79 character length, formatted by autopep8. Should I force it to save without formatting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that's fine.