-
Notifications
You must be signed in to change notification settings - Fork 7
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
Updates to fork function for allowing Projects ID instead of URLs #478
base: master
Are you sure you want to change the base?
Updates to fork function for allowing Projects ID instead of URLs #478
Conversation
Thanks @shaikh-ma - this looks like a great quality-of-life change. @jjdelc @rchacon1 - what do you guys think? Do you see any issues with this change? Cheers |
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.
Looks good! I just made a couple of minor suggestions
scrunch/datasets.py
Outdated
except KeyError: | ||
# Creating full project URL for sub-folders | ||
connection = _default_connection(connection=None) | ||
site_url = connection.session.site_url |
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.
You can obtain this from self.resource.session.site_url
without having to make a new connection.
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.
Thanks for the suggestion, I've updated this. 😃
scrunch/datasets.py
Outdated
project if project.startswith("http") else get_project(project).url | ||
) | ||
try: | ||
project = get_project(project).url |
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.
project = get_project(project).url | |
project_url = get_project(project).url |
It will help to not overwrite the variable and also naming it project_url
is more clear that this is storing a URL (string) and not a Project()
instance. Ideally we'd do project_url:str = ....
but python 2 😒
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.
Agreed! 😃
This PR simplifies the fork function further by allowing the users to use either of Project path or Project ID directly as the value of project parameter.
When using the project ID for creating a dataset fork, the function automatically converts the Project ID into required URL (for subfolders) in the backend.
Earlier it was not able to create forks in sub-folders using project ID. And it required passing of the pycrunch API URL for the desired sub-folder path.
This is no longer a limitation, and the
fork()
function can now automatically generate & pass to the payload, the URL from the project ID in the backend.This however will not allow the users to create new fork dataset in "personal folder".
Since the personal folder concept is planned to be removed soon, so we believe that this will no longer be a problem and this approach aligns with the expected behavior for always using the project parameter and reduce the use of preserve_owner parameter.
The below snapshot shows that we can use the Project Path or Project ID to for creating dataset in any given project location (top level or sub-level).