-
-
Notifications
You must be signed in to change notification settings - Fork 287
fork api #944
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
Merged
Merged
fork api #944
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a9cbedf
fork api
sahithyaravi 33822b3
Merge branch 'develop' into new_fork_api
sahithyaravi 1822c99
improve docs (+1 squashed commits)
sahithyaravi ce94f93
minor change (+1 squashed commits)
sahithyaravi f0fcfbf
Merge branch 'new_fork_api' of https://github.com/openml/openml-pytho…
sahithyaravi 6767a0b
docs update
sahithyaravi b624e07
clarify example
sahithyaravi 4962697
Merge branch 'develop' into new_fork_api
PGijsbers e8e3205
Update doc/progress.rst
PGijsbers 15864f4
Fix whitespaces for docstring
PGijsbers 1aa2660
fix error
sahithyaravi eda3fd8
Use id 999999 for unknown dataset
PGijsbers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -815,12 +815,19 @@ def edit_dataset( | |
| ) -> int: | ||
| """ | ||
| Edits an OpenMLDataset. | ||
| Specify atleast one field to edit, apart from data_id | ||
| - For certain fields, a new dataset version is created : attributes, data, | ||
| default_target_attribute, ignore_attribute, row_id_attribute. | ||
| In addition to providing the dataset id of the dataset to edit (through data_id), | ||
| you must specify a value for at least one of the optional function arguments, | ||
| i.e. one value for a field to edit. | ||
|
Collaborator
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 |
||
|
|
||
| - For other fields, the uploader can edit the exisiting version. | ||
| Noone except the uploader can edit the exisitng version. | ||
| This function allows editing of both non-critical and critical fields. | ||
| Critical fields are default_target_attribute, ignore_attribute, row_id_attribute. | ||
|
|
||
| - Editing non-critical data fields is allowed for all authenticated users. | ||
| - Editing critical fields is allowed only for the owner, provided there are no tasks | ||
| associated with this dataset. | ||
|
|
||
| If dataset has tasks or if the user is not the owner, the only way | ||
| to edit critical fields is to use fork_dataset followed by edit_dataset. | ||
|
|
||
| Parameters | ||
| ---------- | ||
|
|
@@ -862,7 +869,7 @@ def edit_dataset( | |
|
|
||
| Returns | ||
| ------- | ||
| data_id of the existing edited version or the new version created and published""" | ||
| Dataset id """ | ||
|
PGijsbers marked this conversation as resolved.
Outdated
|
||
| if not isinstance(data_id, int): | ||
| raise TypeError("`data_id` must be of type `int`, not {}.".format(type(data_id))) | ||
|
|
||
|
|
@@ -897,6 +904,45 @@ def edit_dataset( | |
| return int(data_id) | ||
|
|
||
|
|
||
| def fork_dataset(data_id: int) -> int: | ||
| """ | ||
| Creates a new dataset version, with the authenticated user as the new owner. | ||
| The forked dataset can have distinct dataset meta-data, | ||
| but the actual data itself is shared with the original version. | ||
|
|
||
| This API is intended for use when a user is unable to edit the critical fields of a dataset | ||
| through the edit_dataset API. | ||
| (Critical fields are default_target_attribute, ignore_attribute, row_id_attribute.) | ||
|
|
||
| Specifically, this happens when the user is: | ||
| 1. Not the owner of the dataset. | ||
| 2. User is the owner of the dataset, but the dataset has tasks. | ||
|
|
||
| In these two cases the only way to edit critical fields is: | ||
| 1. STEP 1: Fork the dataset using fork_dataset API | ||
| 2. STEP 2: Call edit_dataset API on the forked version. | ||
|
|
||
|
|
||
| Parameters | ||
| ---------- | ||
| data_id : int | ||
| id of the dataset to be forked | ||
|
|
||
| Returns | ||
| ------- | ||
| Dataset id of the forked dataset | ||
|
|
||
| """ | ||
| if not isinstance(data_id, int): | ||
| raise TypeError("`data_id` must be of type `int`, not {}.".format(type(data_id))) | ||
| # compose data fork parameters | ||
| form_data = {"data_id": data_id} | ||
| result_xml = openml._api_calls._perform_api_call("data/fork", "post", data=form_data) | ||
| result = xmltodict.parse(result_xml) | ||
| data_id = result["oml:data_fork"]["oml:id"] | ||
| return int(data_id) | ||
|
|
||
|
|
||
| def _get_dataset_description(did_cache_dir, dataset_id): | ||
| """Get the dataset description as xml dictionary. | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.