-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
Data edit api #1044
Data edit api #1044
Conversation
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.
Code looking good @sahithyaravi1493, I could only find some small things that should be improved.
@@ -232,6 +237,66 @@ private function data_list($segs) { | |||
$this->xmlContents('data', $this->version, array('datasets' => $datasets)); | |||
} | |||
|
|||
private function data_edit() { | |||
// Get columns to be update from post data | |||
$data_id = $this->input->post('data_id'); |
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.
For consistency, it would be great if we would solve this with a XML (and new XSD) as well.
openml_OS/models/api/v1/Api_data.php
Outdated
|
||
// If data id is not given | ||
if( $data_id == false ) { | ||
$this->returnError( 110, $this->version ); |
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.
For consistency, the API error codes are setup in such a way that we have a "range" of error codes per error function. It would be good to claim the range 1060 - 1069 for this function, and duplicate all error messages that are now reused.
openml_OS/models/api/v1/Api_data.php
Outdated
// where data id | ||
$where_data = 'where did='. $data_id; | ||
|
||
$this->Dataset->query('update dataset set '. $update_total . $where_data); |
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.
please use Codeigniter official Query for this (it's $this->Dataset->update or something like that)
openml_OS/models/api/v1/Api_data.php
Outdated
$where_data = 'where did='. $data_id; | ||
|
||
$this->Dataset->query('update dataset set '. $update_total . $where_data); | ||
|
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.
please also 'catch' the return value of that function (boolean) and handle it if there is an error
openml_OS/models/api/v1/Api_data.php
Outdated
$this->Dataset->query('update dataset set '. $update_total . $where_data); | ||
|
||
// Return edited dataset, for user to verify changes | ||
$this->xmlContents( 'data-get', $this->version, $dataset ); |
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.
For consistency (with upload/delete fns), I would suggest to create a 'data-edit' and to only show data id
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 making this PR! It looks great.
As discussed, this api can edit some meta-features of the dataset:
List of meta-features can be edited/ updated via data_edit API call,
These meta-features/ data will just need to call create_dataset api and create a new version: (python api)
After the data_edit API is ready, I can create a single python API to handle both of these cases.
Based on the arguments (None or otherwise). We can either create a new dataset or call the data_edit API.
How to test this API?
Create a post request:
Request URL: localhost/api/v1/json/data/edit
Request body: Specify the data_id and atleast one of the 7 fields to edit as an XML
example data.xml: