Skip to content

Relax db #1073

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 12 commits into from
Apr 27, 2015
Merged

Relax db #1073

merged 12 commits into from
Apr 27, 2015

Conversation

josenavas
Copy link
Contributor

Note: this PR is made against the new relax-md-req.

I'm only changing the SQL layout and the populate_test_db.sql, so people can check if there is something terribly wrong.

I'm not changing any code, so tests are expected to fail.
In the next PR, (which will be build on top of this one) I'll start fixing the metadata_template objects, so some tests start passing with the new layout :-)

@josenavas josenavas mentioned this pull request Apr 17, 2015
@josenavas
Copy link
Contributor Author

@biocore/qiita-dev This is ready for review. Note that this is going to it's own branch. Tests are expected to fail. The only thing that I'm changing in this PR is the database layout and the populate test database file, so it can be successfully added after the new changes have been made.

@josenavas
Copy link
Contributor Author

@biocore/qiita-dev The relax-md-req in upstream is now based on @squirrelo's changes, so this is modifying on top of his changes. Can be this be reviewed? Note that this is only changing the database, and the idea is get some feedback in terms of "don't do this is crazy". The earlier that I get that feedback the less burden I'll have later.

sql = """SELECT DISTINCT study_id from qiita.required_sample_info"""
study_ids = set(s[0] for s in conn_handler.execute_fetchall(sql))

queue_name = "PATCH_21"
Copy link
Member

Choose a reason for hiding this comment

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

queue name should be 23, right? Not blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Changed to avoid future confusions.

@antgonza
Copy link
Member

Looks fine but it seems like all these changes can be done directly in a sql and not in python ...

@josenavas
Copy link
Contributor Author

I can investigate on how to do everything on SQL. I'll dedicate a short period of time, otherwise I'm not going to meet the deadline. If you have a suggestion it will likely help me a lot to reduce development burden.

@antgonza
Copy link
Member

antgonza commented Apr 23, 2015 via email

@josenavas
Copy link
Contributor Author

Shorter development time, I'm still getting used to more complex SQL queries, although I'm pretty exited on taking advantage of SQL.

@antgonza
Copy link
Member

OK 👍 as we do not have any rules about this what should go in a sql or py patch.

@josenavas
Copy link
Contributor Author

Great thanks

# Since that table no longer stores required metadata,
# we are going to rename it
sql = """ALTER TABLE qiita.required_sample_info
RENAME TO study_sample"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the schema implicit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will move this to SQL but just FYI, since you are changing the name of the table you don't need the schema. Actually, if you put the schema does not work (I've tested it on my system cause I also thought it was needed)

# Since that table no longer stores common prep template metadata,
# we are going to rename it
sql = """ALTER TABLE qiita.common_prep_info
RENAME TO prep_template_sample"""
Copy link
Contributor

Choose a reason for hiding this comment

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

as @wasade said above, this probably needs schema in front of the name.

@squirrelo
Copy link
Contributor

Few comments on the python patch. All in all, the logic on this is extremely hard to follow and I think it would be greatly improved if moved over to straight SQL. This would also take care of @wasade's concern about the selects being outside the queue.

@wasade
Copy link
Contributor

wasade commented Apr 24, 2015

@squirrelo, agree. I think it would be dangerous to have this patch run on a database that is not absolutely quiet (as no other connections except the one executing this patch).

@josenavas
Copy link
Contributor Author

Thanks guys, I will try to do everything in SQL, those concerns are legitimate.

@josenavas
Copy link
Contributor Author

@wasade @antgonza @squirrelo I moved everything to the SQL. Ready for review.

latitude=sv.latitude,
longitude=sv.longitude,
required_sample_info_status=sv.status
FROM sample_values sv
Copy link
Contributor

Choose a reason for hiding this comment

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

Why rename it here to sv when you can use WITH sv AS on line 52.

@squirrelo
Copy link
Contributor

Python patch is broken:

  File "/Users/jshorens/Repositories/qiita/qiita_db/support_files/patches/python_patches/23.py", line 5, in <module>
    from qiita_db.metadata_template import SampleTemplate, PrepTemplate
  File "/Users/jshorens/Repositories/qiita/qiita_db/metadata_template/__init__.py", line 9, in <module>
    from .sample_template import SampleTemplate
  File "/Users/jshorens/Repositories/qiita/qiita_db/metadata_template/sample_template.py", line 23, in <module>
    from .prep_template import PrepTemplate
  File "/Users/jshorens/Repositories/qiita/qiita_db/metadata_template/prep_template.py", line 56, in <module>
    class PrepTemplate(MetadataTemplate):
  File "/Users/jshorens/Repositories/qiita/qiita_db/metadata_template/prep_template.py", line 70, in PrepTemplate
    id_cols_handlers = {'emp_status_id': get_emp_status()}
  File "/Users/jshorens/Repositories/qiita/qiita_db/util.py", line 268, in get_emp_status
    return dict(con.execute_fetchall(sql))
  File "/Users/jshorens/Repositories/qiita/qiita_db/sql_connection.py", line 454, in execute_fetchall
    with self._sql_executor(sql, sql_args) as pgcursor:
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/Users/jshorens/Repositories/qiita/qiita_db/sql_connection.py", line 303, in _sql_executor
    (sql, str(sql_args), e)))
qiita_db.exceptions.QiitaDBExecutionError: 
Error running SQL query: select emp_status, emp_status_id from qiita.emp_status
ARGS: None
Error: relation "qiita.emp_status" does not exist
LINE 1: select emp_status, emp_status_id from qiita.emp_status

@josenavas
Copy link
Contributor Author

Yes, python patch is broken because it relies on code that it needs to be added later. Just as a remainder, this is broken up a 44 file PR that we agreed was too hard to review. The system will not be fully functional until all PR go in the branch...

@squirrelo
Copy link
Contributor

How are you testing the patch then? This needs to be complete for the patch to work at least, if it's going to be the actual patch PR.

@josenavas
Copy link
Contributor Author

I've tested only the SQL patch, as the python patch is independent of the data in the database.

I've commented out the python patch for the time being, so I can add it back once the functionality that I need is in place. @squirrelo if you don't agree with that, I'll happy to do another 44 files PR and I hope you'll have fun reviewing it.

@squirrelo
Copy link
Contributor

Since this is on a separate branch, can you please pull the python patch out of this PR and add it back in when it works, so we don't forget to test it later on.

@josenavas
Copy link
Contributor Author

Done

@squirrelo
Copy link
Contributor

👍

antgonza added a commit that referenced this pull request Apr 27, 2015
@antgonza antgonza merged commit 6177e4e into qiita-spots:relax-md-req Apr 27, 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