-
Couldn't load subscription status.
- Fork 79
Analysis refactor db #2040
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
antgonza
merged 15 commits into
qiita-spots:analysis-refactor
from
josenavas:analysis-refactor-db
Jan 30, 2017
Merged
Analysis refactor db #2040
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
931e566
New DB structure
josenavas a2b883e
Adding python patch
josenavas e737f64
Adding a biom so we can actually execute the patch
josenavas 6bc0303
Fixing the patch to correctly transfer the information from the old s…
josenavas 331012d
Fixing patch
josenavas eabe25d
Fixing patch and a few other bits to make the patch run successfully
josenavas 0c40bc0
These files are no longer needed
josenavas ad4deea
Droping analysis status table
josenavas aa3e96f
Linking the analysis with all the artifacts
josenavas d222e08
Fixing typo
josenavas 39f6beb
Fixing HTML and dbschema files
josenavas 4dd357c
Adding analyisis jobs
josenavas ab65fa2
Adding logging column to the analysis
josenavas 43eb1ed
Addressing @antgonza's comments
josenavas d016833
Taking into account non-phylogenetic metrics in beta diversity
josenavas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| -- Jan 5, 2017 | ||
| -- Move the analysis to the plugin system. This is a major rewrite of the | ||
| -- database backend that supports the analysis pipeline. | ||
| -- After exploring the data on the database, we realized that | ||
| -- there are a lot of inconsistencies in the data. Unfortunately, this | ||
| -- makes the process of trasnferring the data from the old structure | ||
| -- to the new one a bit more challenging, as we will need to handle | ||
| -- different special cases. Furthermore, all the information needed is not | ||
| -- present in the database, since it requires checking BIOM files. Due to these | ||
| -- reason, the vast majority of the data transfer is done in the python patch | ||
| -- 47.py | ||
|
|
||
| -- In this file we are just creating the new data structures. The old | ||
| -- datastructure will be dropped in the python patch once all data has been | ||
| -- transferred. | ||
|
|
||
| -- Create the new data structures | ||
|
|
||
| -- Table that links the analysis with the initial set of artifacts | ||
| CREATE TABLE qiita.analysis_artifact ( | ||
| analysis_id bigint NOT NULL, | ||
| artifact_id bigint NOT NULL, | ||
| CONSTRAINT idx_analysis_artifact_0 PRIMARY KEY (analysis_id, artifact_id) | ||
| ); | ||
| CREATE INDEX idx_analysis_artifact_analysis ON qiita.analysis_artifact (analysis_id); | ||
| CREATE INDEX idx_analysis_artifact_artifact ON qiita.analysis_artifact (artifact_id); | ||
| ALTER TABLE qiita.analysis_artifact ADD CONSTRAINT fk_analysis_artifact_analysis FOREIGN KEY ( analysis_id ) REFERENCES qiita.analysis( analysis_id ); | ||
| ALTER TABLE qiita.analysis_artifact ADD CONSTRAINT fk_analysis_artifact_artifact FOREIGN KEY ( artifact_id ) REFERENCES qiita.artifact( artifact_id ); | ||
|
|
||
| -- Droping the analysis status column cause now it depends on the artifacts | ||
| -- status, like the study does. | ||
| ALTER TABLE qiita.analysis DROP COLUMN analysis_status_id; | ||
|
|
||
| -- Create a table to link the analysis with the jobs that create the initial | ||
| -- artifacts | ||
| CREATE TABLE qiita.analysis_processing_job ( | ||
| analysis_id bigint NOT NULL, | ||
| processing_job_id uuid NOT NULL, | ||
| CONSTRAINT idx_analysis_processing_job PRIMARY KEY ( analysis_id, processing_job_id ) | ||
| ) ; | ||
|
|
||
| CREATE INDEX idx_analysis_processing_job_analysis ON qiita.analysis_processing_job ( analysis_id ) ; | ||
| CREATE INDEX idx_analysis_processing_job_pj ON qiita.analysis_processing_job ( processing_job_id ) ; | ||
| ALTER TABLE qiita.analysis_processing_job ADD CONSTRAINT fk_analysis_processing_job FOREIGN KEY ( analysis_id ) REFERENCES qiita.analysis( analysis_id ) ; | ||
| ALTER TABLE qiita.analysis_processing_job ADD CONSTRAINT fk_analysis_processing_job_pj FOREIGN KEY ( processing_job_id ) REFERENCES qiita.processing_job( processing_job_id ) ; | ||
|
|
||
| -- Add a logging column in the analysis | ||
| ALTER TABLE qiita.analysis ADD logging_id bigint ; | ||
| CREATE INDEX idx_analysis_0 ON qiita.analysis ( logging_id ) ; | ||
| ALTER TABLE qiita.analysis ADD CONSTRAINT fk_analysis_logging FOREIGN KEY ( logging_id ) REFERENCES qiita.logging( logging_id ) ; | ||
|
|
||
| -- We can handle some of the special cases here, so we simplify the work in the | ||
| -- python patch | ||
|
|
||
| -- Special case 1: there are jobs in the database that do not contain | ||
| -- any information about the options used to process those parameters. | ||
| -- However, these jobs do not have any results and all are marked either | ||
| -- as queued or error, although no error log has been saved. Since these | ||
| -- jobs are mainly useleess, we are going to remove them from the system | ||
| DELETE FROM qiita.analysis_job | ||
| WHERE job_id IN (SELECT job_id FROM qiita.job WHERE options = '{}'); | ||
| DELETE FROM qiita.job WHERE options = '{}'; | ||
|
|
||
| -- Special case 2: there are a fair amount of jobs (719 last time I | ||
| -- checked) that are not attached to any analysis. Not sure how this | ||
| -- can happen, but these orphan jobs can't be accessed from anywhere | ||
| -- in the interface. Remove them from the system. Note that we are | ||
| -- unlinking the files but we are not removing them from the filepath | ||
| -- table. We will do that on the patch 47.py using the | ||
| -- purge_filepaths function, as it will make sure that those files are | ||
| -- not used anywhere else | ||
| DELETE FROM qiita.job_results_filepath WHERE job_id IN ( | ||
| SELECT job_id FROM qiita.job J WHERE NOT EXISTS ( | ||
| SELECT * FROM qiita.analysis_job AJ WHERE J.job_id = AJ.job_id)); | ||
| DELETE FROM qiita.job J WHERE NOT EXISTS ( | ||
| SELECT * FROM qiita.analysis_job AJ WHERE J.job_id = AJ.job_id); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
trasnferring -> transferring