Skip to content

Conversation

@sahithyaravi
Copy link
Member

@sahithyaravi sahithyaravi commented May 13, 2020

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,

  1. description
  2. creator
  3. contributor
  4. collection_date
  5. language
  6. citation
  7. original_data_url
  8. paper_url

These meta-features/ data will just need to call create_dataset api and create a new version: (python api)

  1. attributes
  2. data - the data itself
  3. default_target_attribute
  4. ignore_attribute
  5. row_id_attribute

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

image
example data.xml:

<oml:data_edit_parameters xmlns:oml="http://openml.org/openml">
<oml:description> Testing description changes </oml:description>
<oml:creator> sahi </oml:creator>
<oml:contributor> Joaquin Vanschoren</oml:contributor>
<oml:collection_date> 2020 </oml:collection_date>
<oml:language>English</oml:language>
<oml:citation>xxx</oml:citation>
<oml:original_data_url>http://openml.org/d/1</oml:original_data_url>
<oml:paper_url>http://openml.org/d/1</oml:paper_url>
</oml:data_edit_parameters>

Copy link
Member

@janvanrijn janvanrijn left a 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.


private function data_edit() {
// Get columns to be update from post data
$data_id = $this->input->post('data_id');
Copy link
Member

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.


// If data id is not given
if( $data_id == false ) {
$this->returnError( 110, $this->version );
Copy link
Member

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.

// where data id
$where_data = 'where did='. $data_id;

$this->Dataset->query('update dataset set '. $update_total . $where_data);
Copy link
Member

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)

$where_data = 'where did='. $data_id;

$this->Dataset->query('update dataset set '. $update_total . $where_data);

Copy link
Member

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

$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 );
Copy link
Member

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

Copy link
Member

@janvanrijn janvanrijn left a 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.

@joaquinvanschoren joaquinvanschoren merged commit bcc97b8 into develop Jul 10, 2020
@sahithyaravi sahithyaravi deleted the data_edit_api branch August 5, 2020 12:35
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.

4 participants