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

Study and StudyPerson object #70

Merged
merged 71 commits into from
Jun 12, 2014
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
b926cf3
inital study create function
squirrelo May 1, 2014
406e5c1
fixed return and SQL
squirrelo May 1, 2014
5acb8c1
break dict info checks out to util.py funcs
squirrelo May 19, 2014
e1f0d27
initial fleshout of properties
squirrelo May 19, 2014
6f857b9
Merge remote-tracking branch 'upstream/master' into addstudy
squirrelo May 20, 2014
1443068
updating populate_test_db and teardown_qiita_schema
squirrelo May 21, 2014
62bfcd8
pep8 cleanup
squirrelo May 21, 2014
bea579c
added clean_sql-results
squirrelo May 21, 2014
34b5a96
fleshing out the study object
squirrelo May 21, 2014
04acc84
docstrings
squirrelo May 21, 2014
d53b091
fleshing out tests
squirrelo May 21, 2014
8507bb1
add study test info
squirrelo May 21, 2014
cbf8509
study test changes
squirrelo May 21, 2014
207bd93
Merge branch 'master' of github.com:biocore/qiita into addstudy
squirrelo May 23, 2014
cb606d5
added efo addition for study
squirrelo May 23, 2014
84163ef
fix check_table_cols function
squirrelo May 23, 2014
bc18758
study insert now works
squirrelo May 23, 2014
b0ef52e
check errors raised properly
squirrelo May 23, 2014
f2f805d
more tests added
squirrelo May 23, 2014
caa68ac
Added StudyPerson object
squirrelo May 25, 2014
a0b3b09
make study creation/update check for objects and pull ids
squirrelo May 25, 2014
ae7707f
merged upstream
squirrelo May 29, 2014
1df40c5
everything but delete written
squirrelo May 29, 2014
741de07
more tests
squirrelo May 29, 2014
89a7275
Merge branch 'master' of github.com:biocore/qiita into addstudy
squirrelo May 29, 2014
0f0edb2
Merge branch 'master' of github.com:biocore/qiita into addstudy
squirrelo May 30, 2014
ee9b677
More test and study updates for bugfixes
squirrelo May 30, 2014
d128aa1
Merge remote-tracking branch 'upstream/master' into addstudy
squirrelo Jun 2, 2014
4b92c89
Merge branch 'master' of github.com:biocore/qiita into addstudy
squirrelo Jun 2, 2014
7748910
more test code and bugfixes
squirrelo Jun 2, 2014
69ff05e
Merge branch 'master' of github.com:biocore/qiita into addstudy
squirrelo Jun 2, 2014
67acbdc
Merge branch 'master' of github.com:biocore/qiita into addstudy
squirrelo Jun 2, 2014
843c458
initial complete study object
squirrelo Jun 2, 2014
6d144b4
More tests, 99% coverage
squirrelo Jun 2, 2014
61ed70b
Docstring stuff
squirrelo Jun 2, 2014
7f8bfb3
ALL THE DOCSTRINGS
squirrelo Jun 2, 2014
ac49f38
EVEN MORE DOCSTRINGS
squirrelo Jun 2, 2014
db5eaff
slight fix
squirrelo Jun 2, 2014
17e8220
fix copy/paste issue
squirrelo Jun 2, 2014
3c24b1d
Take care of @josenavas suggestions
squirrelo Jun 3, 2014
10c4c04
A bit more docstring
squirrelo Jun 3, 2014
b061b2e
pep8 fixes
squirrelo Jun 3, 2014
51da641
import THE FUTURE
squirrelo Jun 4, 2014
0d755d0
import THE FUTURE AGAIN
squirrelo Jun 4, 2014
7bfa663
moving the future
squirrelo Jun 4, 2014
e506ccf
addressing @wasade comments
squirrelo Jun 4, 2014
0e691b4
cleaner join in info.setter
squirrelo Jun 4, 2014
678df7a
pep8 test_util
squirrelo Jun 4, 2014
352dbda
add lock on setters for public study
squirrelo Jun 4, 2014
e29947c
fix docstring
squirrelo Jun 4, 2014
e41bc7c
Merge branch 'master' of github.com:biocore/qiita into addstudy
squirrelo Jun 4, 2014
136007d
fix tests for new test data
squirrelo Jun 4, 2014
f5c333e
fix pep8
squirrelo Jun 4, 2014
69af985
fixing more code
squirrelo Jun 9, 2014
b99c43b
merging upstream/master
squirrelo Jun 9, 2014
95c4629
fix some travis failures
squirrelo Jun 9, 2014
ea5973a
some more changes
squirrelo Jun 11, 2014
5a09f9e
calm before the storm
squirrelo Jun 11, 2014
5f86893
merge upstream/master
squirrelo Jun 11, 2014
fadcaa7
remote testcode
squirrelo Jun 11, 2014
28eea2f
Merge branch 'master' of github.com:biocore/qiita into addstudy
squirrelo Jun 11, 2014
ddb9972
fixing tests
squirrelo Jun 11, 2014
3a1df46
fix _non_info bug, comments
squirrelo Jun 12, 2014
6503a78
fix the last bits....hopefully
squirrelo Jun 12, 2014
2332ba1
merge upstream/master
squirrelo Jun 12, 2014
9007a91
100%
squirrelo Jun 12, 2014
18c2edf
fix some merge conflict issues
squirrelo Jun 12, 2014
c4a2234
Taking care of @adamrp suggestions
squirrelo Jun 12, 2014
e03e612
applying @josenavas sugestions
squirrelo Jun 12, 2014
e06472b
empty efo fix
squirrelo Jun 12, 2014
4d74534
move efo checks
squirrelo Jun 12, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions qiita_db/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def status(self):
"{0}_id = %s)".format(self._table),
(self._id, ))[0]

def _status_setter_checks(self):
def _status_setter_checks(self, conn_handler):
r"""Perform any extra checks that needed to be done before setting the
object status on the database. Should be overwritten by the subclasses
"""
Expand All @@ -218,10 +218,10 @@ def status(self, status):
self._check_subclass()

# Perform any extra checks needed before we update the status in the DB
self._status_setter_checks()
conn_handler = SQLConnectionHandler()
Copy link
Member

Choose a reason for hiding this comment

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

This is strange, conn_handler is a parameter but the first thing it does is conn_handler = SQLConnectionHandler()

self._status_setter_checks(conn_handler)

# Update the status of the object
conn_handler = SQLConnectionHandler()
conn_handler.execute(
"UPDATE qiita.{0} SET {0}_status_id = "
"(SELECT {0}_status_id FROM qiita.{0}_status WHERE status = %s) "
Expand Down
11 changes: 8 additions & 3 deletions qiita_db/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ class QiitaDBConnectionError(QiitaDBError):
pass


class QiitaDBColumnError(QiitaDBError):
"""Exception when missing table information or excess information passed"""
pass


class QiitaDBDuplicateError(QiitaDBError):
"""Exception when duplicating something in the database"""
pass


class QiitaDBColumnError(QiitaDBError):
"""Exception when database column info missing or incorrect"""
class QiitaDBStatusError(QiitaDBError):
"""Exception when editing is done with an unallowed status"""
pass


Expand All @@ -45,4 +50,4 @@ class QiitaDBUnknownIDError(QiitaDBError):
def __init__(self, missing_id, table):
super(QiitaDBUnknownIDError, self).__init__()
self.args = ("The object with ID '%s' does not exists in table '%s"
% (missing_id, table))
% (missing_id, table),)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this comma is needed, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's needed to turn the args into a tuple so they can be processed correctly.

14 changes: 14 additions & 0 deletions qiita_db/metadata_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ class MetadataTemplate(QiitaStatusObject):
# instantiate this base class
_table_prefix = None
_column_table = None
_id_column = None

def _check_id(self, id_, conn_handler=None):
# PLACEHOLDER SO TESTS PASS. Jose will rewrite for metadata pr
r""""""
self._check_subclass()
conn_handler = (conn_handler if conn_handler is not None
else SQLConnectionHandler())
return conn_handler.execute_fetchone(
"SELECT EXISTS(SELECT * FROM qiita.{0} WHERE "
"{1}=%s)".format(self._table, self._id_column),
Copy link
Contributor

Choose a reason for hiding this comment

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

Neat! never knew you could combine the {0}-style notation with the %s-style notation like this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's really handy for SQL like this.

(id_, ))[0]

@classmethod
def _get_table_name(cls, study_id):
Expand Down Expand Up @@ -262,8 +274,10 @@ def has_single_category_values(self, category):

class SampleTemplate(MetadataTemplate):
""""""
_table = "required_sample_info"
_table_prefix = "sample_"
_column_table = "study_sample_columns"
_id_column = "study_id"


class PrepTemplate(MetadataTemplate):
Expand Down