Skip to content

Fix extend functionality #1072

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 11 commits into from
Apr 21, 2015
Merged

Fix extend functionality #1072

merged 11 commits into from
Apr 21, 2015

Conversation

josenavas
Copy link
Contributor

Some background:

The extend functionality was first introduced to add new samples to a sample template. However, if there was a new column, that new column was also added to the database. The problem is that at the beginning of the function, the existing samples were filtered from the metadata template so the existing samples didn't get the values for the new column.

This PR includes:

  • the bug described above is fixed in a way that now extend can be used to add new columns, new samples or both.
    • moving part of the extend functionality to the base class, in preparation for adding it to the prep template (it will be needed in the refactor).
  • the tests of the extend function were quite limited (they just tested that the sample id was there). I created a bunch of new tests, so the functionality is better tested in all the possible paths the function can be executed.

@josenavas josenavas added this to the Alpha 0.1 milestone Apr 17, 2015
@josenavas josenavas mentioned this pull request Apr 17, 2015
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 7324daf on josenavas:fix-extend into * on biocore:master*.

@josenavas
Copy link
Contributor Author

yay!!!!!!!

@ElDeveloper
Copy link
Contributor

I'm going to start reviewing this.

On (Apr-17-15|14:46), josenavas wrote:

yay!!!!!!!


Reply to this email directly or view it on GitHub:
#1072 (comment)

"""
# Check if we are adding new samples
sample_ids = md_template.index.tolist()
sql = """SELECT sample_id FROM qiita.{0}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm kinda surprised we don't have an ids method for the templates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's what an oversight on my end... we have self.keys(), changed.

@ElDeveloper
Copy link
Contributor

Looks good, just a couple questions.

@ElDeveloper
Copy link
Contributor

And comments.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 79.66% when pulling 2fb6558 on josenavas:fix-extend into 3b51c0d on biocore:master.


# Check if we are adding new columns
table_name = self._table_name(self._id)
# Get the required columns from the DB
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an excessive number of comments, to the point it makes the code hard to read.

@squirrelo
Copy link
Contributor

One comment, non-blocking.

# modified (see update for that functionality)
min_md_template = md_template[new_cols].loc[existing_samples]
values = as_python_types(min_md_template, new_cols)
values.append(existing_samples)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add an explanation for this and the following line? It's a bit confusing.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 79.66% when pulling f8f0a6d on josenavas:fix-extend into 3b51c0d on biocore:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 79.66% when pulling f8f0a6d on josenavas:fix-extend into 3b51c0d on biocore:master.

@squirrelo
Copy link
Contributor

👍

ElDeveloper added a commit that referenced this pull request Apr 21, 2015
@ElDeveloper ElDeveloper merged commit 162144c into qiita-spots:master Apr 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants