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

Updates to fork function for allowing Projects ID instead of URLs #478

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

shaikh-ma
Copy link
Contributor

@shaikh-ma shaikh-ma commented Jan 17, 2025

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).

image

@shaikh-ma shaikh-ma marked this pull request as draft January 17, 2025 14:25
@shaikh-ma shaikh-ma marked this pull request as ready for review January 21, 2025 12:45
@alexbuchhammer
Copy link

alexbuchhammer commented Jan 28, 2025

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
Alex

@jamesrkg jamesrkg requested review from jjdelc and rchacon1 February 4, 2025 14:11
Copy link
Contributor

@jjdelc jjdelc left a 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

except KeyError:
# Creating full project URL for sub-folders
connection = _default_connection(connection=None)
site_url = connection.session.site_url
Copy link
Contributor

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.

Copy link
Contributor Author

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. 😃

project if project.startswith("http") else get_project(project).url
)
try:
project = get_project(project).url
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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 😒

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants